Bird
Raised Fist0
FreeRTOSprogramming~10 mins

Why scheduling determines real-time behavior in FreeRTOS - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a FreeRTOS task with the correct priority.

FreeRTOS
xTaskCreate(taskFunction, "Task1", 1000, NULL, [1], NULL);
Drag options to blanks, or click blank then click option'
AtskIDLE_PRIORITY
BconfigMAX_PRIORITIES
C0
DportMAX_DELAY
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or portMAX_DELAY as priority causes unexpected scheduling.
2fill in blank
medium

Complete the code to start the FreeRTOS scheduler.

FreeRTOS
int main(void) {
    // Setup code
    [1]();
    for(;;) {}
}
Drag options to blanks, or click blank then click option'
AvTaskSuspend
BxTaskCreate
CvTaskDelay
DvTaskStartScheduler
Attempts:
3 left
💡 Hint
Common Mistakes
Calling task creation functions instead of starting the scheduler.
3fill in blank
hard

Fix the error in the task delay call to ensure the task yields correctly.

FreeRTOS
void taskFunction(void *pvParameters) {
    for(;;) {
        // Do work
        vTaskDelay([1]);
    }
}
Drag options to blanks, or click blank then click option'
A1000
BportMAX_DELAY
C1000 / portTICK_PERIOD_MS
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using raw milliseconds causes incorrect delay timing.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps task names to their priorities for tasks with priority greater than 1.

FreeRTOS
task_priorities = {task.name: task.priority for task in tasks if task.priority [1] [2]
Drag options to blanks, or click blank then click option'
A>
B1
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or == will select wrong tasks.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase task names to their stack sizes for tasks with stack size greater than 512.

FreeRTOS
task_info = { [1]: [2] for task in tasks if task.stack_size [3] 512 }
Drag options to blanks, or click blank then click option'
Atask.name.upper()
Btask.stack_size
C>
Dtask.name
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names or wrong comparison operator.

Practice

(1/5)
1. Why is scheduling important in FreeRTOS for real-time behavior?
easy
A. It decides which task runs and when, affecting response time.
B. It controls the memory allocation for tasks.
C. It manages the power consumption of the system.
D. It handles the input/output operations automatically.

Solution

  1. Step 1: Understand scheduling role

    Scheduling in FreeRTOS controls task execution order and timing.
  2. Step 2: Connect scheduling to real-time

    By deciding which task runs and when, scheduling affects how fast the system reacts to events.
  3. Final Answer:

    It decides which task runs and when, affecting response time. -> Option A
  4. Quick Check:

    Scheduling controls task timing = It decides which task runs and when, affecting response time. [OK]
Hint: Scheduling controls task timing and response speed [OK]
Common Mistakes:
  • Confusing scheduling with memory management
  • Thinking scheduling manages power or I/O directly
  • Ignoring the impact on response time
2. Which FreeRTOS function is used to start the scheduler?
easy
A. vTaskDelay()
B. xTaskCreate()
C. vTaskStartScheduler()
D. xQueueSend()

Solution

  1. Step 1: Identify scheduler start function

    The function to start the FreeRTOS scheduler is vTaskStartScheduler().
  2. Step 2: Differentiate from other functions

    xTaskCreate() creates tasks, vTaskDelay() delays tasks, xQueueSend() sends to queues.
  3. Final Answer:

    vTaskStartScheduler() -> Option C
  4. Quick Check:

    Start scheduler function = vTaskStartScheduler() [OK]
Hint: Scheduler starts with vTaskStartScheduler() function [OK]
Common Mistakes:
  • Confusing task creation with scheduler start
  • Using delay or queue functions to start scheduler
  • Misspelling function names
3. Given two tasks with priorities 3 and 5, which task will FreeRTOS schedule first?
medium
A. Task with priority 5
B. Task created first runs first
C. Both run simultaneously
D. Task with priority 3

Solution

  1. Step 1: Understand priority meaning

    In FreeRTOS, higher numeric priority means higher importance.
  2. Step 2: Compare priorities 3 and 5

    Priority 5 is higher than 3, so the task with priority 5 runs first.
  3. Final Answer:

    Task with priority 5 -> Option A
  4. Quick Check:

    Higher priority runs first = Task with priority 5 [OK]
Hint: Higher numeric priority runs before lower [OK]
Common Mistakes:
  • Assuming lower number means higher priority
  • Thinking tasks run simultaneously
  • Believing creation order affects scheduling
4. What is wrong with this FreeRTOS code snippet?
void task1(void *pvParameters) {
  while(1) {
    // do work
  }
}

int main() {
  xTaskCreate(task1, "Task1", 1000, NULL, 1, NULL);
  // Missing scheduler start
  return 0;
}
medium
A. Task stack size is too large.
B. Scheduler is not started, so tasks never run.
C. Task priority is invalid.
D. Task function has wrong signature.

Solution

  1. Step 1: Check for scheduler start

    The code creates a task but does not call vTaskStartScheduler(), so no tasks run.
  2. Step 2: Verify other parts

    Stack size 1000 and priority 1 are valid; task signature is correct.
  3. Final Answer:

    Scheduler is not started, so tasks never run. -> Option B
  4. Quick Check:

    Missing scheduler start = Scheduler is not started, so tasks never run. [OK]
Hint: Always call vTaskStartScheduler() after creating tasks [OK]
Common Mistakes:
  • Forgetting to start the scheduler
  • Thinking stack size or priority causes no run
  • Assuming task signature is incorrect
5. How does using task priorities in FreeRTOS help meet real-time deadlines?
hard
A. Priorities automatically optimize CPU clock speed.
B. Priorities reduce memory usage for tasks.
C. Priorities allow tasks to run in parallel on a single core.
D. Higher priority tasks preempt lower ones, ensuring timely execution.

Solution

  1. Step 1: Understand preemption by priority

    FreeRTOS scheduler lets higher priority tasks interrupt lower priority ones.
  2. Step 2: Connect preemption to deadlines

    This ensures critical tasks run quickly to meet real-time deadlines.
  3. Final Answer:

    Higher priority tasks preempt lower ones, ensuring timely execution. -> Option D
  4. Quick Check:

    Priority preemption ensures deadlines = Higher priority tasks preempt lower ones, ensuring timely execution. [OK]
Hint: Higher priority tasks run first to meet deadlines [OK]
Common Mistakes:
  • Thinking priorities affect memory or CPU speed
  • Believing tasks run truly in parallel on one core
  • Ignoring preemption's role in timing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard