philosophers_prep/subjects/18_philosophers_bonus.txt
Rui Ribeiro 2128325237 Added new exercices to better cover philosophers_bonus requirements
- Added exercices:
  - Added process basics.
  - Added semaphores basics.
  - Added process communication
  - Added process termination
  - Added process_philosophers
  - Renamed and reordered philosophers_bonus
2025-10-14 16:37:24 +01:00

24 lines
1.0 KiB
Plaintext

Assignment name: philosophers_bonus
Expected files: philosophers_bonus.c
Allowed functions: memset, printf, malloc, free, write, fork, kill, exit,
pthread_create, pthread_detach, pthread_join, usleep, gettimeofday,
waitpid, sem_open, sem_close, sem_post, sem_wait, sem_unlink
-------------------------------------------------------------------------
Implement the bonus version of Philosophers:
- Each philosopher is a separate process (not thread)
- Use named POSIX semaphores for coordination
- Parent process monitors all child processes
- If a philosopher dies, kill all other processes
Additional features:
- Proper cleanup of named semaphores
- Signal handling (SIGINT, SIGTERM)
- Final report with statistics
Usage: `./philosophers_bonus 5 800 200 200 7`
Hint: Bonus part uses processes instead of threads.
Named POSIX semaphores allow communication between processes.
Use fork() to create child processes and waitpid() to monitor.
Semaphore cleanup is crucial - use sem_unlink() and signal handling for cleanup in case of interruption.