{"id":25257004,"url":"https://github.com/maripeshko/42_philosophers","last_synced_at":"2025-08-23T06:03:33.321Z","repository":{"id":264370374,"uuid":"893165192","full_name":"MariPeshko/42_Philosophers","owner":"MariPeshko","description":"The project of 42Berlin school. Learning the basics of threading, deadlock and data race.","archived":false,"fork":false,"pushed_at":"2024-12-14T01:02:05.000Z","size":1696,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-23T06:02:20.394Z","etag":null,"topics":["deadlock"],"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/MariPeshko.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":"2024-11-23T17:50:19.000Z","updated_at":"2024-12-14T01:02:09.000Z","dependencies_parsed_at":"2024-12-12T16:29:38.327Z","dependency_job_id":"03f8aa3a-ff26-4fe8-8adf-f19e21036ab6","html_url":"https://github.com/MariPeshko/42_Philosophers","commit_stats":null,"previous_names":["maripeshko/42_philosophers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MariPeshko/42_Philosophers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MariPeshko%2F42_Philosophers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MariPeshko%2F42_Philosophers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MariPeshko%2F42_Philosophers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MariPeshko%2F42_Philosophers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MariPeshko","download_url":"https://codeload.github.com/MariPeshko/42_Philosophers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MariPeshko%2F42_Philosophers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271745659,"owners_count":24813515,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["deadlock"],"created_at":"2025-02-12T06:32:29.505Z","updated_at":"2025-08-23T06:03:33.259Z","avatar_url":"https://github.com/MariPeshko.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 42_Philosophers\n\n### \"The unexamined life is not worth living.\"\n— Socrates\n\n42Berlin school project created by Maryna Peshko (mpeshko) in November of 2024. Studying the basics of multithreading. More details in the topic \"Philosophers.subject.pdf\"\n\n### Logic\n\nThe two most important functions to understand a logic:\n* `void\t*routine(void *arg)`\n* `int\tft_fork(t_philo *philo)`\n* `int\tft_think(t_philo *philo)`\n\n\u003cbr /\u003eIn routine() all even philosophers start later than all odd ones.\n```\nif (philo-\u003ephilo_id % 2 == 0)\n\t\tft_usleep(5);\n```\n`ft_fork()` has diferrent logic in taking forks for even and odd philosophers.\n\u003cbr /\u003e`ft_think()`  is used to delay a philosopher before he takes a fork, so that he doesn't get there early and steal it from another philosopher who waited longer. This prevents some philosopher from waiting too long for his fork and dying.\n\n### The program input:\n`./philo`\n\u003cbr /\u003e`   [number_of_philosophers]`\n\u003cbr /\u003e`   [time_to_die]`\n\u003cbr /\u003e`   [time_to_eat]`\n\u003cbr /\u003e`   [time_to_sleep]`\n\u003cbr /\u003e`   _(optional argument)`_\n\u003cbr /\u003e`   [number_of_times_each_philosopher_must_eat]`\n\u003cbr /\u003e  \u003cbr /\u003e According to the subject, all tests are limited to 200 philosophers, and the minimum time is 60 ms.\n\n### Examples\n\nPhilosopher should not eat and should die.\n\u003cbr /\u003e`./philo 1 800 200 200`\n\u003cbr /\u003e\u003cbr /\u003e\nNo Philosopher should die.\n\u003cbr /\u003e`./philo 5 800 200 200`\n\u003cbr /\u003e\u003cbr /\u003e\nNo Philosopher should die and the simulation should stop when every philosopher has eaten at least 7 times.\n\u003cbr /\u003e`./philo 5 800 200 200 3`\n\u003cbr /\u003e\u003cbr /\u003e\nNo Philosopher should die.\n\u003cbr /\u003e`./philo 4 410 200 200`\n\u003cbr /\u003e\u003cbr /\u003e\nOne Philosopher should die.\n\u003cbr /\u003e`./philo 4 299 200 100`\n\u003cbr /\u003e\u003cbr /\u003e\nOne Philosopher should die.\n\u003cbr /\u003e`./philo 10 299 2000 100`\n\u003cbr /\u003e\u003cbr /\u003e\nNo one should die\n\u003cbr /\u003e`./philo 10 299 2000 100`\n\u003cbr /\u003e\u003cbr /\u003e\nParsing tests\n\u003cbr /\u003e`./philo 2 \"\" \"\" \"\"`\n\u003cbr /\u003e`./philo -2 100 100 100`\n\u003cbr /\u003e`./philo f 100 100 100`\n\n### How to check for data races \n`valgrind --tool=helgrind`\n\n### How to check used function\n\n`nm -u ./philo`\n\n### Contacts\nhttps://www.linkedin.com/in/maryna-peshko/\n\u003cbr /\u003eemail: marunapeshko@gmail.com\n\n(c) Maryna Peshko","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaripeshko%2F42_philosophers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaripeshko%2F42_philosophers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaripeshko%2F42_philosophers/lists"}