To install StudyMoose App tap and then “Add to Home Screen”
Save to my list
Remove from my list
This laboratory report presents the results obtained from experiments conducted on real-time operating systems (RTOS) and the analysis of these results. The objective of the experiments was to explore and implement pre-emptive and cooperative multitasking of program threads using the Mbed NXP LPC 1768 microcontroller. Through this experimentation, we aimed to demonstrate the ability of the microcontroller to handle multiple tasks concurrently, a concept commonly referred to as threading.
In the context of this study, a "thread of execution" refers to the smallest sequence of programmed instructions managed independently by a scheduler.
The initial focus was on implementing interrupts, allowing the microcontroller to execute specific functions when triggered by external events, such as a button press. Real-time operating systems (RTOS) are essential in systems where data processing must occur as it arrives, often without significant buffering delays. These systems demand quick response times, often in increments as short as a tenth of a second.
RTOS achieves this rapid response by efficiently switching between tasks, creating the illusion that multiple tasks are executed simultaneously on a single processing core.
FreeRTOS, a type of RTOS, is designed to be compact and is commonly used in microcontroller applications, although its utility extends beyond microcontrollers. It primarily provides core real-time scheduling functionality, inter-task communication, timing, and synchronization primitives.
The overarching goal of this laboratory experiment was to develop a game that could be played on the Mbed microcontroller. While we encountered challenges that led to delays during the experiment, these obstacles provided valuable learning experiences, deepening our understanding of the subject matter.
This knowledge will prove beneficial if we encounter similar tasks in the future. This report provides a comprehensive background analysis of the subject, details the results obtained, and concludes with a summary of the laboratory experiment's findings.
The primary hardware used in this experiment was the Mbed NXP LPC 1768, which is part of the ARM microcontroller development board series designed for rapid prototyping. Specifically, the LPC 1768 is tailored for prototyping various devices, including those equipped with Ethernet and USB interfaces, as well as a wide range of peripheral interfaces and FLASH memory. Key features of the Mbed NXP LPC 1768 include:
The Mbed Microcontrollers offer experienced embedded developers a powerful platform for building proof-of-concepts. For those new to 32-bit microcontrollers, Mbed provides an accessible prototyping solution supported by libraries, resources, and a collaborative community.
[2]Image of Mbed: [Insert Figure 1 Here]
The procedure for this experiment involved utilizing example code provided by the Mbed website, which is publicly accessible. This code was used to gain a better understanding of how the Mbed's functions operate and how various functions of the board are utilized. Once familiarity was achieved with the platform, we proceeded to address the specific tasks at hand. The challenges and difficulties encountered during this process will be elaborated upon in greater detail in the results section.
The primary aim of this laboratory experiment was to gain a comprehensive understanding of the Mbed's functionality as a microcontroller and its application in developing a Real-Time Operating System (RTOS). Additionally, we aimed to explore how threads and interrupts are implemented in practical scenarios. The RTOS application designed in this experiment allowed us to evaluate its performance and included tasks related to scheduling, pre-emptive multitasking of threads, processes, and synchronization.
The overarching goal of the laboratory sessions was to familiarize ourselves with the Mbed hardware, comprehend the functioning of RTOS components, and learn how to implement them to perform various user-defined tasks. Over the course of several weeks, we were assigned tasks that aimed to enhance our knowledge of RTOS applications, culminating in the development of a game leveraging the features of the LPC1768 board. This involved programming for the LCD display, joystick, and LEDs provided by the board.
Unfortunately, I was unable to complete all the tasks from section 4.4 within the allotted time. However, I did attempt some of the tasks and achieved success in them. Throughout this process, I gained a deeper understanding of the inner workings of an operating system and recognized the significance of both threads and interrupts in programming for the Mbed platform.
The first task of this laboratory experiment focused on the implementation and comprehension of threads and their role in the RTOS application. Threads are integral to the creation of the RTOS application, facilitating pre-emptive and cooperative multitasking of programmed threads. This approach gives the Mbed the appearance of simultaneously executing multiple actions, a concept known as multithreading.
The code snippet presented below illustrates the concurrent execution of two separate processes using threads. These processes involve a shifting LED pattern and a bubble leveling demonstration, each running on a dedicated thread.
[Insert Your Code Here]
To execute this code, it is essential to include the necessary libraries at the beginning of the program, as depicted in Figure 2. These libraries grant access to specific functionalities, such as the LCD display manipulation through 'C12832.lcd.h.' However, overlooking the inclusion of required libraries may lead to compilation errors, a challenge I initially encountered. Once I resolved these library-related issues, I could successfully compile and upload the code to my Mbed.
[Insert Your Code Here]
[Insert Your Code Here]
The code provided in above demonstrates the concurrent execution of the leveling bubble code and the LED shifting lights. These two separate threads run seamlessly, each serving its intended purpose without any issues.
Additionally, the code exhibits the code responsible for managing the speaker tone and joystick control. This code grants the user control over the game running on the Mbed display, enhancing the interactive experience.
In conclusion, the initial part of the RTOS experiment (Task 4.3) was executed successfully. Both threads operated as intended, effectively demonstrating pre-emptive and cooperative multitasking capabilities on the Mbed platform.
Task 4.4 posed significant challenges, and I was unable to complete the entire task due to some missing components in the code. However, I did make progress in implementing interrupts, which I will describe in this section. One of the aspects I worked on was creating a game where the user's objective was to time a pulse correctly, with a successful press advancing the user to the next level. The implemented code also included an alarm tone that signaled successful level completion.
[Insert Your Code Here]
The code snippet represents a portion of the second part of this RTOS laboratory experiment, where I focused on successfully incorporating interrupts into the code.
Task 4.4 proved to be more challenging compared to the previous task. I believe part of the challenge stemmed from spending too much time researching without making substantial progress, resulting in a significant time constraint during the laboratory sessions. Consequently, I was unable to complete all the tasks associated with the interrupts section of the RTOS laboratory experiment. Nevertheless, the code presented above illustrates that I achieved some success in various aspects of the second task.
The Mbed LPC1768 utilizes both pre-emptive and cooperative multitasking of program threads, enabling the microcontroller to appear as though it is executing multiple actions simultaneously. This is achieved by allowing the microcontroller to allocate time to different tasks based on specific criteria.
By default, a device like the Mbed can only execute one action at a time, as it processes instructions sequentially. However, pre-emptive multitasking allocates time to each task based on priority and time slices, allowing the microcontroller to switch between tasks rapidly. Cooperative multitasking, on the other hand, allows processes to voluntarily yield control when idle or blocked, facilitating the concurrent execution of multiple applications. Together, these techniques create the illusion of multitasking, which is commonly referred to as threading.
Multithreaded applications offer several advantages:
However, multithreaded applications come with certain disadvantages:
Interrupts, in the context of microcontrollers, are mechanisms that disrupt the normal sequence of program execution. When an interrupt occurs, the processor saves the current program counter, blocks interrupts of the same or lower priority, and transfers control to an interrupt service routine (ISR). The ISR executes the necessary operations before returning to the main program.
Alternative methods for creating games could involve techniques such as polling, where the program continuously checks the status of a specific input or condition. However, using interrupts is generally a more efficient and responsive approach, especially in real-time applications where timing precision is crucial.
The interrupt controller (PIC) plays a vital role in managing interrupts. It combines multiple sources of interrupts onto one or more processor lines, allowing for prioritization of interrupts. The PIC determines which interrupt request has the highest priority and issues an interrupt to the CPU based on this determination.
In conclusion, this laboratory experiment has provided me with valuable insights into the functionalities of real-time operating systems (RTOS) and how the Mbed platform can be leveraged to create more complex programs. Throughout the experiment, I gained a deeper understanding of pre-emptive and cooperative multitasking of program threads and learned how to combine different techniques to design an interactive game.
While I faced challenges during Task 4.4, specifically related to interrupts, I did manage to make some progress and incorporate interrupts into my code. Although I was unable to complete all tasks to the highest standard, I familiarized myself with the functions and capabilities of interrupts, which contributed to my overall learning experience.
This RTOS laboratory experiment allowed me to demonstrate a technical performance of a contemporary operating system within the context of a smart environment. However, due to the time constraints and challenges faced, I could not complete all tasks to the highest standards, which provides opportunities for further exploration and improvement in the future.
Lab Report on Real Time Operating Systems (RTOS). (2024, Jan 02). Retrieved from https://studymoose.com/document/lab-report-on-real-time-operating-systems-rtos
👋 Hi! I’m your smart assistant Amy!
Don’t know where to start? Type your requirements and I’ll connect you to an academic expert within 3 minutes.
get help with your assignment