
Pack Structs With __attribute__((packed)) and Know the Costs
Remove struct padding with __attribute__((packed)) to match a wire format, then see the unaligned-access cost, the pointer warning and the memcpy alternative.
Tag
362 posts

Remove struct padding with __attribute__((packed)) to match a wire format, then see the unaligned-access cost, the pointer warning and the memcpy alternative.

Use GDB's break command with a function name, a line number, file:line, an address or an offset, then list, disable, delete and make breakpoints temporary.

Eclipse ThreadX is a small real-time kernel that began at Express Logic, became Azure RTOS, and moved to the Eclipse Foundation under an open license in 2023.

Create a child process in C with fork on Linux, tell parent from child by the return value, and avoid the mistakes that run code twice.

Copy .data from flash and zero .bss in a Cortex-M reset handler without bugs: alignment, the memset trap, empty sections and a debugger check to run.

Register, use and release an interrupt handler with request_irq and free_irq in a Linux 6.12 platform driver, with flags, return codes and common errors.

Declare a logging function with __attribute__((format(printf, ...))) so GCC and Clang check each call's format and arguments, and pair it with vsnprintf.

Word size is the native width of a CPU's registers and addresses. See what 32-bit and 64-bit change for pointers and long, with a C program and its output.

A race condition is a bug where the result depends on thread timing. See a lost-update counter in C with pthreads and how a mutex makes the update atomic.

Declare a function that calls exit or abort as noreturn so GCC drops dead code, silences false warnings and lays out the error path correctly.

Send fixed-size messages between Zephyr threads and from ISRs with k_msgq, using K_MSGQ_DEFINE, put and get with timeouts, peek, purge and sizing rules.

A process is a running program plus the kernel's record of it: a PID, a private address space and a table entry. See each part in C on Linux.