What is the difference between a thread and a process?
A process is an independent execution unit with its own address space, including code, data, heap, and stack segments. Processes are isolated from each other by the OS — one process cannot directly access another process's memory. This isolation requires hardware support such as an MMU (Memory Management Unit).
A thread is a lightweight execution unit that exists within a process. Multiple threads in the same process share the same address space (code, data, heap) but each has its own stack and register context. Because threads share memory, inter-thread communication is fast (just read/write shared variables, with proper synchronization), but this also makes concurrency bugs like race conditions possible.
In most embedded RTOS environments (FreeRTOS, Zephyr on Cortex-M without MPU), there is no MMU and therefore no true process isolation. What the RTOS calls "tasks" are essentially threads — they all share the same flat address space. This means a bug in one task (e.g., a buffer overflow) can corrupt another task's data or the kernel itself. Some RTOS kernels support an MPU (Memory Protection Unit) to provide limited isolation, but it is coarser than full MMU-based protection. This is a common interview question because it tests whether the candidate understands the practical implications for embedded systems where full process isolation is often unavailable.
Source: Operating Systems & RTOS Q&A
