University of Ottawa
Software Engineering - Quiz 3 Participation
Review: RTOS Scheduling, Trust Zone
Memory Security, and Interrupt Handling
Course: SEG 4145
,Question 1 — Préemption vs time slicing (piège conceptuel)
#define configUSE_PREEMPTION 1
#define configUSE_TIME_SLICING 1
const osThreadAttr_t Task1_attributes = { .priority = 3 };
const osThreadAttr_t Task2_attributes = { .priority = 2 };
const osThreadAttr_t Task3_attributes = { .priority = 2 };
void StartTask1(void *argument)
{
for(;;) { countTask1++; } // never blocks
}
void StartTask2(void *argument)
{
for(;;) { countTask2++; }
}
void StartTask3(void *argument)
{
for(;;) { countTask3++; }
}
Question:
Which statement best describes the runtime behavior?
A. Task2 and Task3 alternate fairly because time slicing is enabled
B. All three tasks share CPU time equally
, C. Task1 dominates execution; Task2 and Task3 may never run
D. Task2 and Task3 preempt Task1 periodically
Correct answer: C
Key idea:
Time slicing does NOT override priority. Preemption ensures the highest-priority READY
task always runs.
Question 2 — Time slicing only among equals
#define configUSE_PREEMPTION 1
#define configUSE_TIME_SLICING 1
const osThreadAttr_t Task1_attributes = { .priority = 2 };
const osThreadAttr_t Task2_attributes = { .priority = 2 };
const osThreadAttr_t Task3_attributes = { .priority = 2 };
void StartTask1(void *argument) { for(;;) { countTask1++; } }
void StartTask2(void *argument) { for(;;) { countTask2++; } }
void StartTask3(void *argument) { for(;;) { countTask3++; } }
Question:
What is the most accurate description?
A. Only the first-created task runs continuously
B. Tasks run one after another in a fixed order
C. Tasks alternate execution in time slices
D. The task with the smallest stack runs more often
Correct answer: C
Key idea:
With configUSE_TIME_SLICING = 1, equal-priority READY tasks share the CPU.