{"id":20858138,"url":"https://github.com/arkasarkar19/multi-reader-writer-with-synchronization","last_synced_at":"2025-09-02T02:34:19.376Z","repository":{"id":84065814,"uuid":"227435592","full_name":"ArkaSarkar19/Multi-reader-writer-with-Synchronization","owner":"ArkaSarkar19","description":"Refer Readme.md","archived":false,"fork":false,"pushed_at":"2020-06-18T07:55:01.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T14:43:13.898Z","etag":null,"topics":["client-server-architecture","mutex-synchronisation","operating-system","reader-writer","semaphores-locking","shared-memory","threading"],"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/ArkaSarkar19.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":"2019-12-11T18:41:40.000Z","updated_at":"2020-06-20T08:26:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"44833b1d-89be-4cb3-976d-319d698f15d2","html_url":"https://github.com/ArkaSarkar19/Multi-reader-writer-with-Synchronization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ArkaSarkar19/Multi-reader-writer-with-Synchronization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArkaSarkar19%2FMulti-reader-writer-with-Synchronization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArkaSarkar19%2FMulti-reader-writer-with-Synchronization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArkaSarkar19%2FMulti-reader-writer-with-Synchronization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArkaSarkar19%2FMulti-reader-writer-with-Synchronization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArkaSarkar19","download_url":"https://codeload.github.com/ArkaSarkar19/Multi-reader-writer-with-Synchronization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArkaSarkar19%2FMulti-reader-writer-with-Synchronization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273220467,"owners_count":25066393,"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-09-02T02:00:09.530Z","response_time":77,"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":["client-server-architecture","mutex-synchronisation","operating-system","reader-writer","semaphores-locking","shared-memory","threading"],"created_at":"2024-11-18T04:44:51.398Z","updated_at":"2025-09-02T02:34:19.357Z","avatar_url":"https://github.com/ArkaSarkar19.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-reader-writer-with-Synchronization\n\n### IMPLEMENTATION\n* I have Implemented mlti Reader Writer with synchronization (no race conditions ). The code is in C.\n\nThe **main.c**  file handles every operation of writers and readers, the **rw.c** file has a\nclient-server relationship with main.c. \u003c/br\u003e\n\nThe global shared queue is an array which keeps two pointers front \u0026 rear for the shared\nqueue, each element of this shared queue can be accessed via multiple threads at the\nsame time hence each element has locks in a form of a **binary semaphore** (r2_mutex)\nensuring no race conditions. \u003c/br\u003e\n\nSince only one write can update the queue at a certain moment a binary semaphore\nwrite_mutex which ensures no other reader or writer can access the queue at that point\nin time. Similarly dequeuing \u0026 enqueuing is also atomic among readers/writers hence\nbinary semaphore **deq_mutex \u0026 enq_mutex** is implemented to ensure the same. \u003c/br\u003e\n\nTo ensure multiple readers can read a certain element concurrently, r_num is implement\nwhich stores the number of threads accessing a certain element, also r1_mutex is\nimplemented to ensure there are no race conditions in r_num. \u003c/br\u003e\nMain.c spawns new threads for every reader and writer and waits for user commands from rw.c.\n\n### COMPILE AND TEST\n\n* To compile use command ‘make’\n  * ./main to run the server (MUST BE STEP 1)\n  * ./rw to run reader or writers\n* Ensure that only one main is running.\n* Once main program is running, on a new terminal run the rw program. The program can handle almost 100 readers and 100 writers.\n\n### USER INPUTS\n* For writer :\n  * To enqueue enter (1) followed by the element to be enqueued\n  * To overwrite enter (2) followed by the index of the array to be overridden.\n  \n        $ Select Operation to be performed\n         1 - overwrite data\n         2 - enqueue data\n         \n* For reader:\n  * To read a certain element from queue enter (1) followed by the index\n  * To dequeue a element from queue enter (2)\n  \n        Select Operation to be performed\n        1 - read data\n        2 - dequeue data\n    \n### EXPECTED OUTPUT\nOnce given the command the program prints out the output of the program to the\ncorresponding terminal running it.\n\n### ERROR HANDLING\n* Prompts the user if index requested for any operation is out of bounds of the queue followed by an error message \u003c/br\u003e\n* Doesn’t allow writer to enqueue to a full queue. \u003c/br\u003e\n* Doesn’t allow reader to dequeue an empty queue. \u003c/br\u003e\n* Prompts if user enters anything other than 1 or 2 to request operations for readers and writers. \u003c/br\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkasarkar19%2Fmulti-reader-writer-with-synchronization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farkasarkar19%2Fmulti-reader-writer-with-synchronization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkasarkar19%2Fmulti-reader-writer-with-synchronization/lists"}