Embedded Computer Systems
Embedded Computer Systems
Assignment 1
ID: 2401845
1- Introduction:
Real-Time Operating Systems (RTOS) are designed to manage multiple tasks
efficiently, ensuring predictable behavior and real-time constraints. FreeRTOS, a
popular open-source RTOS, provides various task management functions, including
vTaskDelay and vTaskDelayUntil. These functions allow tasks to delay their
execution, which plays a crucial role in task scheduling and resource management.
This report explores their functionality, interaction with the RTOS scheduler, and
key differences.
How It Works:
• The function takes one parameter, xTicksToDelay, which specifies the number of
tick interrupts to wait.
• After the delay period, the task transitions back to the Ready state, where it waits
for the scheduler to allocate CPU time.
Interaction with RTOS Scheduler:
• vTaskDelay is a relative delay function, meaning the delay starts from the
moment it is called.
• The function allows the RTOS scheduler to execute other tasks while the calling
task is delayed.
• It does not guarantee precise periodic execution but simply ensures a minimum
delay.
Example Usage:
The following example demonstrates a task that blinks an LED every 500ms using
vTaskDelay:
for (;;)
Use Cases:
• Blinking an LED at fixed intervals.
How It Works:
• The pxPreviousWakeTime parameter holds the last wake-up time and must be
maintained across function calls.
• When a task calls vTaskDelayUntil, it calculates the next wake-up time and
enters the Blocked state until that time is reached.
Example Usage:
The following example demonstrates a task that reads a sensor every 500ms using
vTaskDelayUntil:
void SensorTask(void *pvParameters)
TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();
for (;;)
vTaskDelayUntil(&xLastWakeTime, xFrequency);
Use Cases:
5- Conclusion
Both vTaskDelay and vTaskDelayUntil serve essential roles in FreeRTOS task
management. vTaskDelay is useful for simple delays where timing precision is not
critical, while vTaskDelayUntil is preferred for periodic tasks requiring precise
execution timing. Understanding their differences and appropriate use cases helps
in designing efficient and predictable real-time systems.
6- Video Link:
https://drive.google.com/drive/folders/1meZyox2he7F8lKiqVc7yhIYXcC5Z1fqy?
usp=sharing