
Preemptive vs Cooperative Scheduling in Embedded Systems
Preemptive schedulers take the CPU away on their own, cooperative ones wait for a task to yield. Compare latency, safety and code cost with FreeRTOS examples.
Tag
255 posts

Preemptive schedulers take the CPU away on their own, cooperative ones wait for a task to yield. Compare latency, safety and code cost with FreeRTOS examples.

Use HAL_I2C_Mem_Read and HAL_I2C_Mem_Write on STM32 for sensor and EEPROM registers: shifted address, memory address size, timeouts and errors.

Learn the HLASM instructions that move data between registers and storage, L, ST, LR, LA, STM and LM, with a traced example showing every register value.

Wrap per-thread atomics in crossbeam_utils::CachePadded to keep each on its own cache line in Rust, with size checks, scoped threads and a repr(align) option.

Follow a FreeRTOS context switch on Cortex-M4F from the yield request to the PendSV handler, and see which registers hardware stacks and which software saves.

Get memory aligned to 32, 64 or 4096 bytes with posix_memalign or C11 aligned_alloc, learn their rules and error codes, and pick the right one for SIMD or DMA.

Create an I2C bus with i2c_new_master_bus, attach a device with i2c_master_bus_add_device, and read registers with i2c_master_transmit_receive in ESP-IDF 5.3.

Write assembler programs that call and return the standard z/OS way, with registers on entry, an 18-word save area chain and a return code in register 15.

Use C++17's std::hardware_destructive_interference_size to pad against false sharing, with the feature-test macro, the GCC warning and a safe fallback constant.

Compare FreeRTOS, Zephyr, NuttX and ThreadX on licensing, scope, hardware support and learning curve, then pick the right RTOS with a decision table.

Understand why HLASM needs a base register, how USING and DROP tell the assembler which register addresses which storage, and how to fix ASMA307E errors.

Fix false sharing in C++17 by giving each thread's data its own cache line with alignas(64), explicit padding, static_assert checks and aligned heap allocation.