{"id":20604944,"url":"https://github.com/shuygena/philosophers","last_synced_at":"2026-04-17T23:03:01.663Z","repository":{"id":170876078,"uuid":"493286821","full_name":"shuygena/Philosophers","owner":"shuygena","description":":spaghetti: :plate_with_cutlery: The dining philosopher's problem: solution with mutexes","archived":false,"fork":false,"pushed_at":"2022-07-01T20:39:18.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T16:54:10.260Z","etag":null,"topics":["42","42projects","multithreading","mutexes","philosophers-dinner-problem"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuygena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-17T14:29:16.000Z","updated_at":"2022-09-19T18:16:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd53140b-3e51-4fed-802d-7389995b3822","html_url":"https://github.com/shuygena/Philosophers","commit_stats":null,"previous_names":["shuygena/philosophers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shuygena/Philosophers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuygena%2FPhilosophers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuygena%2FPhilosophers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuygena%2FPhilosophers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuygena%2FPhilosophers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuygena","download_url":"https://codeload.github.com/shuygena/Philosophers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuygena%2FPhilosophers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31949435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42projects","multithreading","mutexes","philosophers-dinner-problem"],"created_at":"2024-11-16T09:25:50.627Z","updated_at":"2026-04-17T23:03:01.619Z","avatar_url":"https://github.com/shuygena.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Philosophers\nEat, Sleep, Spaghetti, repeat. This project is about learning how threads work by precisely timing a group of philosophers on when to pick up forks and eat spaghetti without dying from hunger.\n\n## :toolbox: Requirements:  \nGCC compiler  \nGNU Make\n\n## :link: Download \u0026 Compile\nClone repository:\n```\ngit clone https://github.com/shuygena/Philosophers philosophers\n```\nGo to directory:\n```\ncd philosophers\n```\nFor compile program run:   \n```\nmake\n```  \n\n## :clipboard: Task  \n### Overview\nHere are the things you need to know if you want to succeed this assignment:  \n• One or more philosophers sit at a round table.   \nThere is a large bowl of spaghetti in the middle of the table.  \n• The philosophers alternatively eat, think, or sleep.  \nWhile they are eating, they are not thinking nor sleeping; while thinking, they are not eating nor sleeping; and, of course, while sleeping, they are not eating nor thinking.  \n• There are also forks on the table. There are as many forks as philosophers.  \n• Because serving and eating spaghetti with only one fork is very inconvenient, a philosopher takes their right and their left forks to eat, one in each hand.  \n• When a philosopher has finished eating, they put their forks back on the table and start sleeping. Once awake, they start thinking again. The simulation stops when\na philosopher dies of starvation.  \n• Every philosopher needs to eat and should never starve.  \n• Philosophers don’t speak with each other.  \n• Philosophers don’t know if another philosopher is about to die.  \n• No need to say that philosophers should avoid dying!  \n### The rules  \nYou have to write a program for the mandatory part and another one for the bonus part\n(if you decide to do the bonus part). They both have to comply with the following rules:  \n• Global variables are forbidden!  \n• Your(s) program(s) should take the following arguments:  \nnumber_of_philosophers time_to_die time_to_eat time_to_sleep\n[number_of_times_each_philosopher_must_eat]  \n◦ number_of_philosophers: The number of philosophers and also the number\nof forks.  \n◦ time_to_die (in milliseconds): If a philosopher didn’t start eating time_to_die\nmilliseconds since the beginning of their last meal or the beginning of the simulation, they die.   \n◦ time_to_eat (in milliseconds): The time it takes for a philosopher to eat.  \nDuring that time, they will need to hold two forks.  \n◦ time_to_sleep (in milliseconds): The time a philosopher will spend sleeping.  \n◦ number_of_times_each_philosopher_must_eat (optional argument): If all\nphilosophers have eaten at least number_of_times_each_philosopher_must_eat\ntimes, the simulation stops. If not specified, the simulation stops when a\nphilosopher dies.  \n• Each philosopher has a number ranging from 1 to number_of_philosophers.  \n• Philosopher number 1 sits next to philosopher number number_of_philosophers.  \nAny other philosopher number N sits between philosopher number N - 1 and philosopher number N + 1.  \nAbout the logs of your program:  \n• Any state change of a philosopher must be formatted as follows:  \n◦ timestamp_in_ms X has taken a fork  \n◦ timestamp_in_ms X is eating  \n◦ timestamp_in_ms X is sleeping  \n◦ timestamp_in_ms X is thinking  \n◦ timestamp_in_ms X died  \nReplace timestamp_in_ms with the current timestamp in milliseconds\nand X with the philosopher number.  \n• A displayed state message should not be mixed up with another message.  \n• A message announcing a philosopher died should be displayed no more than 10 ms\nafter the actual death of the philosopher.  \n• Again, philosophers should avoid dying!  \n  \n### The \"philo\" program  \n• Each philosopher should be a thread.  \n• There is one fork between each pair of philosophers. Therefore, if there are several\nphilosophers, each philosopher has a fork on their left side and a fork on their right\nside. If there is only one philosopher, there should be only one fork on the table.  \n• To prevent philosophers from duplicating forks, you should protect the forks state\nwith a mutex for each of them.  \n\n## :mortar_board: Tutorial\n[Unix threads in C (videos)](https://www.youtube.com/playlist?list=PLfqABt5AS4FmuQf70psXrsMLEDQXNkLq2)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuygena%2Fphilosophers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuygena%2Fphilosophers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuygena%2Fphilosophers/lists"}