Challenge - 5 Problems
Embedded Execution Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of bare-metal loop execution
Consider this bare-metal style embedded C code running on a microcontroller. What will be the output on the serial console?
Embedded C
#include <stdio.h> int main() { int count = 0; while (count < 3) { printf("Tick %d\n", count); count++; } return 0; }
Attempts:
2 left
💡 Hint
Count starts at 0 and increments until it reaches 3, but loop stops before printing count 3.
✗ Incorrect
The loop runs while count is less than 3, so it prints Tick 0, Tick 1, and Tick 2, then stops.
❓ Predict Output
intermediate2:00remaining
RTOS task scheduling output
Given this simplified RTOS task code, what is the output order on the console?
Embedded C
#include <stdio.h> #include <unistd.h> void task1() { printf("Task 1 start\n"); sleep(1); printf("Task 1 end\n"); } void task2() { printf("Task 2 start\n"); sleep(1); printf("Task 2 end\n"); } int main() { task1(); task2(); return 0; }
Attempts:
2 left
💡 Hint
Tasks run one after another in this code, no real multitasking.
✗ Incorrect
Since task1() runs fully before task2(), output is task1 start/end then task2 start/end.
🧠 Conceptual
advanced2:00remaining
Difference in execution models
Which statement best describes the difference between bare-metal and RTOS execution models?
Attempts:
2 left
💡 Hint
Think about how tasks are managed and switched.
✗ Incorrect
Bare-metal typically runs one main loop without task switching; RTOS allows multiple tasks with preemption.
🔧 Debug
advanced2:00remaining
Identify the RTOS scheduling bug
This RTOS task code is intended to print alternating messages from two tasks. What is the bug causing only one task to print repeatedly?
Embedded C
#include <stdio.h> #include <pthread.h> #include <unistd.h> void* task1(void* arg) { while(1) { printf("Task 1 running\n"); sleep(1); } return NULL; } void* task2(void* arg) { while(1) { printf("Task 2 running\n"); sleep(1); } return NULL; } int main() { pthread_t t1, t2; pthread_create(&t1, NULL, task1, NULL); pthread_join(t1, NULL); pthread_create(&t2, NULL, task2, NULL); pthread_join(t2, NULL); return 0; }
Attempts:
2 left
💡 Hint
Check what happens after pthread_join(t1) is called.
✗ Incorrect
pthread_join(t1) waits for task1 to finish, blocking main thread and preventing task2 from running.
🚀 Application
expert3:00remaining
Choosing execution model for a real-time sensor system
You design a sensor system that must read data every 10ms and process it without delay. Which execution model is best and why?
Attempts:
2 left
💡 Hint
Consider timing predictability and overhead.
✗ Incorrect
Bare-metal systems have minimal overhead and predictable timing, ideal for strict real-time sensor reading.