This lab builds upon previous labs by focusing on managing multiple tasks in a FreeRTOS environment. You will learn how to create, prioritize, and schedule multiple tasks to work together effectively in a real-time operating system.
- Create and manage multiple tasks in a FreeRTOS environment
- Understand task priorities and their effect on scheduling
- Implement task synchronization techniques
- Monitor task performance and resource usage
- Practice effective multi-tasking design patterns
- TM4C123GH6PM LaunchPad Evaluation Kit
- USB cable for programming and debugging
- Optional: Additional LEDs or peripherals for visual feedback
- Keil µVision IDE
- FreeRTOS kernel (included in the project)
main.c: Main application code with task definitions and initializationtm4c123gh6pm.h: TM4C123 hardware definitionsRTE/: Run-Time Environment folder containing FreeRTOS configuration
- Open the
lab5.uvprojxfile in Keil µVision - Review the main.c file to understand the task structure
- Build the project using F7 or the Build button
- Flash the program to your TM4C123 board
- Observe the behavior of multiple tasks running concurrently
This lab demonstrates:
- Creating multiple tasks with different priorities using
xTaskCreate() - Controlling task execution through priorities
- Managing shared resources between tasks
- Implementing periodic tasks with different execution frequencies
- Using task utilities such as
vTaskDelay()andvTaskDelayUntil()
- Multiple tasks execute according to their assigned priorities
- Higher priority tasks preempt lower priority tasks when needed
- Tasks demonstrate cooperation by yielding control when appropriate
- The application shows predictable real-time behavior
This lab explores various ways tasks can be synchronized:
- Priority-based Preemption: Higher priority tasks interrupt lower priority tasks
- Time Slicing: Tasks of equal priority share CPU time
- Explicit Yielding: Tasks voluntarily give up processor time
- Timed Delays: Tasks suspend themselves for specific time periods
- Assign priorities based on task importance and deadlines
- Keep critical sections short to avoid blocking other tasks
- Use appropriate delay mechanisms for periodic tasks
- Be mindful of stack usage for each task
- Consider using task notifications for simple task-to-task signaling
- Tasks Not Running: Verify priority assignments and ensure the scheduler is started
- Stack Overflow: Increase stack size for tasks that use more stack space
- Timing Issues: Check delay calculations and timer tick configuration
- System Hangs: Look for potential deadlocks or priority inversion situations
Try these extensions to deepen your understanding:
- Add more tasks with different behaviors and priorities
- Implement a task that monitors and reports on other tasks' performance
- Experiment with different scheduling policies by modifying FreeRTOSConfig.h
- Add resource sharing between tasks with proper protection mechanisms