
Pass Arguments to and Return Values from pthreads
Pass arguments to a pthread through void pointers and get results back with pthread_join, a result struct or pthread_exit, without dangling pointers.
Tag
362 posts

Pass arguments to a pthread through void pointers and get results back with pthread_join, a result struct or pthread_exit, without dangling pointers.

Initialize C structs, arrays and malloc buffers so Valgrind reports no uninitialised reads, including the padding bytes that surprise you when data is written.

Move slow work out of a Zephyr interrupt handler with k_work_submit and the system workqueue, with the work item rules, a GPIO example and sizing tips.

strerror_r has two incompatible signatures in glibc. Learn which one you get, how to write code that works with both, and how strerror_l avoids the problem.

Learn the Cortex-M vector table layout: system entries, device IRQs, the Thumb bit, how VTOR finds the table, and why it must sit at the start of flash.

Build a game loop in C with GLFW 3.4 that updates physics at a fixed 60 Hz step, renders at any rate, and interpolates between states for smooth motion.

A stack canary is a secret value placed before the return address and checked before ret. See how GCC emits it, where glibc stores it, and what it misses.

A clock cycle is one tick of the signal that paces a processor. Learn what GHz measures, why it is not performance, and how to convert cycles to time in C.

Replace select with poll and struct pollfd to serve many clients in C without the FD_SETSIZE limit, and learn the POLLIN, POLLHUP and POLLNVAL revents.

Run code every N milliseconds in Zephyr with k_timer, including one-shot and periodic modes, the expiry callback rules and how to wake a thread from it.

A cheat sheet of the errno values you meet most on Linux, such as ENOENT, EACCES, EINTR and EAGAIN, with the cause, the reaction and when not to retry.

Build an STM32F4 blinky with no HAL: one C file, a short linker script, a vector table and the arm-none-eabi-gcc commands that produce a flashable binary.