Bird
Raised Fist0
FreeRTOSprogramming~20 mins

Real-time vs general-purpose OS in FreeRTOS - Practice Questions

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Real-time OS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Key difference between Real-time OS and General-purpose OS

Which statement best describes the main difference between a Real-time Operating System (RTOS) and a General-purpose Operating System (GPOS)?

ARTOS guarantees task completion within strict time limits; GPOS focuses on maximizing throughput without strict timing guarantees.
BGPOS always runs tasks faster than RTOS because it uses more CPU cores.
CRTOS cannot run multiple tasks simultaneously, while GPOS can run many tasks at once.
DGPOS is designed only for embedded devices, while RTOS is for desktop computers.
Attempts:
2 left
💡 Hint

Think about what makes real-time systems special in terms of timing.

❓ Predict Output
intermediate
1:30remaining
Task scheduling behavior in FreeRTOS

Consider two tasks in FreeRTOS: Task A with higher priority and Task B with lower priority. If both are ready to run, which task will the scheduler run first?

ATask B runs first because FreeRTOS uses round-robin scheduling regardless of priority.
BTask B runs first because tasks are run in the order they were created.
CBoth tasks run simultaneously on separate cores by default.
DTask A runs first because FreeRTOS always runs the highest priority ready task.
Attempts:
2 left
💡 Hint

Remember how priority affects task scheduling in FreeRTOS.

❓ Predict Output
advanced
2:00remaining
Output of FreeRTOS task delay example

What will be the output of the following FreeRTOS code snippet?

void Task1(void *pvParameters) {
    for (;;) {
        printf("Task1 running\n");
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

void Task2(void *pvParameters) {
    for (;;) {
        printf("Task2 running\n");
        vTaskDelay(pdMS_TO_TICKS(500));
    }
}

Assuming both tasks start at the same time and have the same priority, what is the expected output pattern?

AOnly Task1 prints because Task2 is blocked indefinitely.
BTask1 and Task2 print alternately every 1000ms each.
CTask1 running every 1000ms and Task2 running every 500ms, with Task2 printing twice as often.
DBoth tasks print simultaneously every 500ms.
Attempts:
2 left
💡 Hint

Consider how vTaskDelay affects task execution timing.

🔧 Debug
advanced
2:00remaining
Identify the error in FreeRTOS task creation

What error will occur when running this FreeRTOS code snippet?

void main() {
    xTaskCreate(TaskFunction, "Task", 100, NULL, 2, NULL);
    vTaskStartScheduler();
}

void TaskFunction(void *params) {
    for (;;) {
        // Task code
    }
}

Note: The task function is defined after main.

ACompilation error because TaskFunction is used before it is declared.
BRuntime error because the task stack size is too small.
CNo error; the code runs correctly.
DLinker error due to missing FreeRTOS library.
Attempts:
2 left
💡 Hint

Think about C language rules for function usage.

🚀 Application
expert
2:30remaining
Choosing OS type for a safety-critical embedded system

You are designing a safety-critical embedded system that must respond to sensor inputs within 10 milliseconds to avoid hazards. Which OS type is best suited for this system?

AA General-purpose Operating System (GPOS) because it supports more applications.
BA Real-time Operating System (RTOS) because it guarantees task deadlines are met.
CNo OS, just run bare-metal code for fastest response.
DA batch processing OS because it handles tasks in groups efficiently.
Attempts:
2 left
💡 Hint

Consider the importance of timing guarantees in safety-critical systems.

Practice

(1/5)
1. Which of the following best describes a real-time operating system (RTOS) like FreeRTOS?
easy
A. It responds quickly and predictably to events.
B. It is designed mainly for running desktop applications.
C. It delays tasks unpredictably to save power.
D. It only runs one task at a time without multitasking.

Solution

  1. Step 1: Understand RTOS purpose

    RTOS is designed to respond quickly and predictably to events, ensuring timing is guaranteed.
  2. Step 2: Compare options

    Options B, C, and D describe general-purpose OS or incorrect behavior.
  3. Final Answer:

    It responds quickly and predictably to events. -> Option A
  4. Quick Check:

    RTOS = predictable quick response [OK]
Hint: RTOS means fast and predictable response to events [OK]
Common Mistakes:
  • Confusing RTOS with general-purpose OS
  • Thinking RTOS delays tasks unpredictably
  • Assuming RTOS runs only one task
2. Which syntax correctly creates a FreeRTOS task in C?
easy
A. createTask(TaskFunction, "Task1", 1000, NULL, 1, NULL);
B. xTaskCreate(TaskFunction, "Task1", 1000, NULL, 1, NULL);
C. xTaskStart(TaskFunction, "Task1", 1000, NULL, 1, NULL);
D. TaskCreate(xTask, "Task1", 1000, NULL, 1, NULL);

Solution

  1. Step 1: Recall FreeRTOS task creation function

    The correct function to create a task is xTaskCreate with parameters: function, name, stack size, parameters, priority, and handle.
  2. Step 2: Check each option

    Only xTaskCreate(TaskFunction, "Task1", 1000, NULL, 1, NULL); uses the correct function name and parameter order. Others use wrong function names.
  3. Final Answer:

    xTaskCreate(TaskFunction, "Task1", 1000, NULL, 1, NULL); -> Option B
  4. Quick Check:

    FreeRTOS task creation = xTaskCreate [OK]
Hint: FreeRTOS task creation always uses xTaskCreate() [OK]
Common Mistakes:
  • Using incorrect function names like createTask or xTaskStart
  • Mixing up parameter order
  • Omitting required parameters
3. Given this FreeRTOS code snippet, what will be the output sequence printed?
void Task1(void *pvParameters) {
  for (int i = 0; i < 3; i++) {
    printf("Task1: %d\n", i);
    vTaskDelay(10);
  }
  vTaskDelete(NULL);
}

void Task2(void *pvParameters) {
  for (int i = 0; i < 3; i++) {
    printf("Task2: %d\n", i);
    vTaskDelay(10);
  }
  vTaskDelete(NULL);
}
medium
A. Task1: 0 Task1: 1 Task1: 2 Task2: 0 Task2: 1 Task2: 2
B. Task2: 0 Task2: 1 Task2: 2 Task1: 0 Task1: 1 Task1: 2
C. Task1: 0 Task2: 1 Task1: 2 Task2: 0 Task1: 1 Task2: 2
D. Task1: 0 Task2: 0 Task1: 1 Task2: 1 Task1: 2 Task2: 2

Solution

  1. Step 1: Understand vTaskDelay effect

    vTaskDelay causes the current task to pause, allowing other tasks of equal priority to run.
  2. Step 2: Trace task execution order

    Task1 prints 0, delays; Task2 runs, prints 0, delays; then Task1 prints 1, and so on, alternating output.
  3. Final Answer:

    Task1: 0 Task2: 0 Task1: 1 Task2: 1 Task1: 2 Task2: 2 -> Option D
  4. Quick Check:

    vTaskDelay causes task switching, so output alternates [OK]
Hint: vTaskDelay switches tasks, output alternates between tasks [OK]
Common Mistakes:
  • Assuming one task runs fully before the other
  • Ignoring vTaskDelay effect
  • Mixing output order
4. Identify the error in this FreeRTOS task creation code:
void Task(void *pvParameters) {
  while(1) {
    // Task code
  }
}

int main() {
  xTaskCreate(Task, "Task", 1000, NULL, 1, NULL);
  return 0;
}
medium
A. The task function must call vTaskDelete(NULL) to end.
B. Stack size 1000 is too large and causes error.
C. vTaskStartScheduler() is missing and should be added.
D. The task function should not have an infinite loop.

Solution

  1. Step 1: Analyze main function

    A task is created with xTaskCreate, but the scheduler is never started.
  2. Step 2: Recall FreeRTOS startup

    vTaskStartScheduler() must be called after creating initial tasks to begin scheduling and multitasking.
  3. Final Answer:

    vTaskStartScheduler() is missing and should be added. -> Option C
  4. Quick Check:

    FreeRTOS requires vTaskStartScheduler() call [OK]
Hint: vTaskStartScheduler() starts the RTOS scheduler [OK]
Common Mistakes:
  • Thinking infinite loop is wrong in RTOS tasks
  • Missing vTaskStartScheduler call
  • Assuming stack size causes error
5. You are designing a system that must control a robotic arm with precise timing to avoid damage. Which OS choice is best and why?
hard
A. Use a real-time OS like FreeRTOS because it guarantees predictable timing.
B. Use a real-time OS because it delays tasks unpredictably to save power.
C. Use a general-purpose OS because it has better user interfaces.
D. Use a general-purpose OS because it handles many tasks simultaneously.

Solution

  1. Step 1: Identify system requirements

    Precise timing is critical to avoid damage, so predictable response is needed.
  2. Step 2: Match OS type to requirement

    Real-time OS guarantees predictable timing; general-purpose OS may delay unpredictably.
  3. Final Answer:

    Use a real-time OS like FreeRTOS because it guarantees predictable timing. -> Option A
  4. Quick Check:

    Precise timing needs RTOS, not general OS [OK]
Hint: Precise timing needs RTOS, not general OS [OK]
Common Mistakes:
  • Choosing general-purpose OS for timing-critical tasks
  • Confusing power saving with timing guarantees
  • Ignoring predictability requirement
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