{"id":19253455,"url":"https://github.com/eschirni/philosophers","last_synced_at":"2025-08-21T20:12:44.693Z","repository":{"id":214887108,"uuid":"473751775","full_name":"eschirni/philosophers","owner":"eschirni","description":"I never thought philosophy would be so deadly","archived":false,"fork":false,"pushed_at":"2022-03-24T21:25:52.000Z","size":1379,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-05T07:15:43.032Z","etag":null,"topics":["42","42heilbronn","c","datarace","mutex","mutex-lock","philosophers","philosophers-dinner-problem","threads"],"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/eschirni.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}},"created_at":"2022-03-24T19:47:20.000Z","updated_at":"2022-03-24T21:31:33.000Z","dependencies_parsed_at":"2023-12-31T18:22:59.194Z","dependency_job_id":"fdadfc18-fad9-4893-9038-fea06a3ef90c","html_url":"https://github.com/eschirni/philosophers","commit_stats":null,"previous_names":["eschirni/philosophers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschirni%2Fphilosophers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschirni%2Fphilosophers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschirni%2Fphilosophers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eschirni%2Fphilosophers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eschirni","download_url":"https://codeload.github.com/eschirni/philosophers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240347981,"owners_count":19787237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","42heilbronn","c","datarace","mutex","mutex-lock","philosophers","philosophers-dinner-problem","threads"],"created_at":"2024-11-09T18:31:07.114Z","updated_at":"2025-02-23T17:13:01.749Z","avatar_url":"https://github.com/eschirni.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# philosophers\n### I never thought philosophy would be so deadly\n\u003cimg width=\"225\" src=\"https://github.com/eschirni/philosophers/blob/master/readme_src/100.png\"\u003e\u003cimg width=\"600\" height=\"233.5\" src=\"https://github.com/eschirni/philosophers/blob/master/readme_src/philosophers.png\"\u003e\n\n## Description of the subject\nPhilosophers is a project about solving the [dining philosophers problem](https://en.wikipedia.org/wiki/Dining_philosophers_problem) by writing a simulation of philosophers sitting around a table. The philosophers alternatively eat, think, or sleep. Once a philosophers is done eating he will sleep, afterwards think and then eat again. There is a fork for every philosopher and 2 forks are needed for a philosopher to eat. Once a philosopher starts eating his time to die will be reset and the other philosophers can't access the forks anymore while he eats. If a philosopher dies the simulation will stop.\n\nThis project is about writing effective code, learning about [threads](https://www.geeksforgeeks.org/multithreading-c-2/), [mutexes](https://www.delftstack.com/howto/c/mutex-in-c/) and all the problems that may come along with it, like [data races](https://en.wikipedia.org/wiki/Race_condition).\n\n#### For more details: [subject.pdf](https://github.com/eschirni/philosophers/blob/master/readme_src/philosophers.pdf)\n\n## Installation and execution\n1. git clone or fork the repository\n2. run `make` to create the executeable\n3. run it with `./philo` and the needed arguments (amount of philos, time to die, time to eat, time to sleep, \\*number of meals)\n\n\\*number of meals is not necessary for the simulation to work\n\n## Sources and tips for 42 students\n- I really recommend watching the threads videos by [CodeVault](https://www.youtube.com/watch?v=d9s_d28yJq0\u0026list=PLfqABt5AS4FmuQf70psXrsMLEDQXNkLq2) to get started with threads\n- Even though I didn't use one, I recommend using a \\*\"reaper thread\" because it makes your simulation way faster\n- Mutex lock everytime you access a shared variable to avoid data races, bools don't need to be locked necessarily because they only have 2 values\n\n\\*a reaper thread is a thread running along with the philosophers checking if one of them died and if so exiting the program\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschirni%2Fphilosophers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feschirni%2Fphilosophers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feschirni%2Fphilosophers/lists"}