Which statement best describes a hard real-time system?
Think about what happens if a deadline is missed in safety-critical systems.
Hard real-time systems require strict adherence to deadlines. Missing a deadline can cause system failure or hazards.
Consider two FreeRTOS tasks: TaskA with priority 3 and TaskB with priority 2. TaskA must complete within 10ms. What happens if TaskB runs longer than expected?
What is the likely outcome regarding TaskA's deadline?
void TaskA(void *pvParameters) {
// Critical task
for(;;) {
// Must finish within 10ms
vTaskDelay(pdMS_TO_TICKS(5));
// Perform critical work
}
}
void TaskB(void *pvParameters) {
for(;;) {
// Runs longer than expected
vTaskDelay(pdMS_TO_TICKS(20));
}
}Remember how FreeRTOS schedules tasks based on priority.
In FreeRTOS, higher priority tasks preempt lower priority ones. TaskA with priority 3 will run before TaskB with priority 2, so TaskA meets its deadline.
In a soft real-time system, what is the typical behavior when a task misses its deadline?
Consider this FreeRTOS task code snippet:
void SoftTask(void *pvParameters) {
for(;;) {
// Simulate variable processing time
vTaskDelay(pdMS_TO_TICKS(rand() % 15));
// Process data
}
}Soft real-time systems allow some flexibility in timing.
Soft real-time systems tolerate occasional deadline misses without catastrophic failure; tasks continue running.
Which scenario best requires a hard real-time system?
Think about when timing failures cause physical harm or damage.
Industrial robots require strict timing to avoid accidents, so hard real-time is necessary.
A FreeRTOS hard real-time task sometimes misses its deadline. Which of the following code snippets is the most likely cause?
void HardTask(void *pvParameters) {
for(;;) {
// Critical work
vTaskDelay(pdMS_TO_TICKS(5));
// Heavy processing
for(int i=0; i<1000000; i++) {
// Busy wait
}
}
}Consider how busy waiting affects multitasking in FreeRTOS.
Busy waiting blocks the CPU, preventing other tasks from running and causing deadline misses in hard real-time tasks.