
Set Process Priority with nice and setpriority
Lower or raise a process's nice value with nice and setpriority on Linux 6.12 and glibc 2.40, handle the -1 return trap, and know when root is required.
Tag
44 posts

Lower or raise a process's nice value with nice and setpriority on Linux 6.12 and glibc 2.40, handle the -1 return trap, and know when root is required.

Read CPU time, peak memory, page faults and context switches for your own process with getrusage on Linux with glibc 2.40, and know which fields are filled.

Use unnamed POSIX semaphores in a shared mapping with sem_init and pshared set to 1 to build a bounded producer and consumer buffer between forked processes.

Synchronize unrelated processes with named POSIX semaphores: sem_open, sem_wait, sem_post, a ping and pong example, sem_timedwait and sem_unlink on Linux 6.12.

Send and receive messages between processes with POSIX message queues: mq_open, priorities, the mq_receive buffer rule, limits and cleanup on Linux 6.12.

Share memory between unrelated processes with POSIX shm_open, ftruncate and mmap, add a writer and a reader, and learn the cleanup with shm_unlink. Linux 6.12.

Compare Linux IPC options for beginners: pipes, FIFOs, Unix sockets, shared memory, message queues, semaphores and signals, and which fits which job.

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.

Write a DNS client in C that builds an A query by hand, sends it over UDP, and decodes the reply including name compression, following RFC 1035.

Build a small HTTP/1.1 server in C with POSIX sockets: parse the request line, send correct headers and Content-Length, and handle keep-alive and bad requests.

Understand big-endian network byte order, why x86 and ARM hosts differ, and when to call htons, htonl, ntohs and ntohl in C socket code.

Use waitpid in C on Linux to wait for a child, poll with WNOHANG, and decode the exit status with WIFEXITED, WEXITSTATUS and WTERMSIG.