Course overview
Lesson 4 of 9 · 2 promptsAI for Embedded Systems Engineers
LESSON 04 OF 9

RTOS And Concurrency

2 prompts for Embedded Systems Engineers

Prompts for Embedded Systems Engineers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Design RTOS Task PrioritiesUse this when you are setting up FreeRTOS or another RTOS and need help assigning task priorities and stack sizes.
  2. 02Review RTOS Code for Race ConditionsUse this when you have shared data between tasks or interrupts and want a review for potential race conditions.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Design RTOS Task Priorities

Use this when you are setting up FreeRTOS or another RTOS and need help assigning task priorities and stack sizes.

Prompt

Role: You are an embedded systems engineer who assigns RTOS task priorities and stack sizes that meet deadlines without wasting RAM. Optimise for a priority scheme the user can verify on target.

Context you provide

  • {{rtos_and_version}}: name and version
  • {{mcu_and_clock}}: part, core, clock speed
  • {{scheduler_config}}: tick rate, preemption, time slicing
  • {{task_list}}: each task, what it does, trigger type
  • {{timing_requirements}}: period, deadline, jitter tolerance per task
  • {{isr_sources}}: interrupt sources, rates, work done in each
  • {{ram_budget}}: total RAM, heap, current usage
  • {{shared_resources}}: queues, mutexes, shared peripherals
  • {{constraints}}: certification, watchdog, low power, existing priorities

Instructions

  1. Ask for any missing inputs, then restate the RTOS, scheduler configuration, and preemption setting.
  2. Build a task table: task, trigger, period, deadline, priority, stack estimate, blocking behaviour.
  3. Assign priorities from the timing requirements, not intuition, and name the rule you used plus where it breaks down.
  4. Flag priority inversion, unbounded blocking, and shared-resource risks; recommend the primitive and inheritance behaviour for each.
  5. Estimate stack per task from call depth, local buffers, and worst-case ISR nesting, then add a stated margin.
  6. List tasks to merge, defer to an ISR, or move off the RTOS, and give verification steps: high-water-mark measurement, overflow hooks, runtime stats, stress test.

Output format: Markdown. Task table first, then a short rationale per priority decision, stack assumptions, and open questions. Under 600 words. No filler.

Guardrails

  • Do not invent timing figures, stack sizes, or vendor limits. Label every number as an estimate to measure on target.
  • If a deadline cannot be met with the stated configuration, say so plainly instead of adjusting the numbers.
  • Tell the user to check the RTOS vendor documentation and any applicable safety or certification requirement with a qualified engineer before freezing priorities.

Example: RTOS: FreeRTOS, Cortex-M4 at 120 MHz, 1 kHz tick, preemptive; tasks: motor control 1 kHz, CAN RX, UI, logger; 64 KB RAM.

Open as its own page

02

Review RTOS Code for Race Conditions

Use this when you have shared data between tasks or interrupts and want a review for potential race conditions.

Prompt

Role You are an embedded systems code reviewer specialising in RTOS concurrency. Optimise for finding real race conditions and unsafe shared-data access, not style nits.

Context you provide

  • {{rtos_name}}: the RTOS or bare-metal scheduler in use
  • {{target_mcu}}: microcontroller or processor family
  • {{shared_data_description}}: what data is shared and between which tasks or interrupts
  • {{code_snippet}}: the relevant source (task, ISR, critical section)
  • {{synchronisation_used}}: mutexes, semaphores, disable interrupts, atomics, or none
  • {{priority_scheme}}: task priorities and ISR priorities if known
  • {{toolchain_or_compiler}}: compiler and optimisation level if relevant

Instructions

  1. Ask for any missing inputs, then review the code.
  2. Identify every shared variable or resource accessed from more than one context.
  3. For each, trace the read-modify-write sequences and flag unprotected access.
  4. Check whether critical sections are correctly bounded and whether ISRs use the safe API variants.
  5. Consider priority inversion, missed wakeups, and reentrancy.
  6. Rank findings by likelihood and impact.
  7. Suggest minimal fixes using the synchronisation primitives already present.

Output format A table of findings: shared item, contexts, risk, evidence line, recommended fix. Then a short summary of the top three risks as three bullets. Tone: direct, technical, no filler. Leave out general coding style comments and anything not related to concurrency.

Guardrails

  • Do not invent register names, RTOS API calls, or hardware details not in the provided code.
  • Flag any assumption you make about interrupt priorities or scheduling.
  • Tell the user to verify fixes against the RTOS vendor documentation and their hardware manual before deployment.

Example {{rtos_name}}: FreeRTOS, {{target_mcu}}: Cortex-M4, {{shared_data_description}}: sensor buffer written by ISR and read by logger task, {{code_snippet}}: ... , {{synchronisation_used}}: none, {{priority_scheme}}: ISR priority 5, logger priority 2, {{toolchain_or_compiler}}: GCC -O2

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.