How amarqs/philosophers works
Project type and purpose
• This is an educational C‐based concurrency simulation implementing the classic “Dining Philosophers” problem.
• The mandatory version uses pthreads and mutexes; each philosopher is a thread, each fork is protected by a mutex.
• The goal is to model philosopher states (thinking, eating, sleeping), safe fork acquisition/release, and detect starvation.
File structure
• Top level:
• Makefile, philo/ directory containing ./include and ./src
• philo/include/philo.h: central structs (philosopher, fork mutex array, timing, shared data)
• philo/src modules:
• main.c & init.c: parse args, initialize data, spawn threads
• thread.c & routine.c: philosopher thread creation and lifecycle loop
• actions.c: grab forks, eat, sleep, think
• monitors.c & check.c: watcher threads/functions that detect death
• utils.c & basic_functions.c: time helpers, printing/logging
• errors.c: error reporting, graceful exit
• Build artifacts guided by Makefile rules (all, clean, fclean, re).
README for additional insights
• Describes command-line args, allowed library functions, expected console logs.
• Emphasizes no data races, accurate timing, correct mutex usage.