Skip to content

๐Ÿ“š Study Docs โ€” Codexion (42 Porto)

This folder contains study notes prepared before tackling Codexion, a POSIX-threads project modeled on the classic dining philosophers problem โ€” coders competing for shared USB dongles instead of philosophers competing for forks.

Each file below covers one concept needed to understand and defend the project.

Dining philosophers problem visualized

๐Ÿ—‚๏ธ Topics

File Covers
01-dining-philosophers.md The classic problem, Coffman's 4 conditions, deadlock vs starvation vs livelock, the N=1 edge case
02-pthreads-sync.md pthread_mutex_t, pthread_cond_t, wait/signal/broadcast, critical sections
03-scheduling-fifo-edf.md FIFO vs Earliest Deadline First scheduling, tie-breaking, real-time scheduling basics
04-heap-priority-queue.md Binary min-heap implemented from scratch, insert/extract-min, use as a scheduler queue
05-timing-precision.md gettimeofday() vs clock_gettime(), usleep() drift, timedwait vs wait, when a coder notices should_stop, hitting the 10ms burnout window
06-concurrency-debugging.md Valgrind, Helgrind, ThreadSanitizer โ€” catching leaks, races, and deadlocks

๐ŸŽฏ How this maps to Codexion

Codexion concept Study topic
Dongles = forks, coders = philosophers 01
Mutex per dongle, cond var for waiting queue 02
scheduler argument (fifo / edf) 03
"You must implement a priority queue (heap)" 04
Burnout log within 10ms, monitor thread 05
Norm + no leaks + no races during defense 06

โœ… Suggested study order

  1. 01 โ†’ understand why the problem is hard
  2. 02 โ†’ learn the C tools to solve it
  3. 03 and 04 โ†’ the two mandatory scheduling/data-structure requirements
  4. 05 โ†’ the precision constraints that make testing tricky
  5. 06 โ†’ how to verify your own solution before submitting