{"id":15561049,"url":"https://github.com/ebyrds/szymanskis_mutex","last_synced_at":"2025-04-23T21:48:01.128Z","repository":{"id":59157131,"uuid":"152611566","full_name":"EByrdS/szymanskis_mutex","owner":"EByrdS","description":"Algorithm devised by Boleslaw Szymanski. This MutEx has linear wait and only 5 communication variables","archived":false,"fork":false,"pushed_at":"2018-10-12T18:10:36.000Z","size":33,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T19:44:26.416Z","etag":null,"topics":["mutex","mutex-lock","mutex-synchronisation","mutexes","race-conditions","ruby","rubygem","szymanski"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EByrdS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-11T15:09:37.000Z","updated_at":"2021-10-21T04:24:41.000Z","dependencies_parsed_at":"2022-09-13T20:10:54.010Z","dependency_job_id":null,"html_url":"https://github.com/EByrdS/szymanskis_mutex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EByrdS%2Fszymanskis_mutex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EByrdS%2Fszymanskis_mutex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EByrdS%2Fszymanskis_mutex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EByrdS%2Fszymanskis_mutex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EByrdS","download_url":"https://codeload.github.com/EByrdS/szymanskis_mutex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522297,"owners_count":21444510,"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":["mutex","mutex-lock","mutex-synchronisation","mutexes","race-conditions","ruby","rubygem","szymanski"],"created_at":"2024-10-02T16:05:03.315Z","updated_at":"2025-04-23T21:48:01.101Z","avatar_url":"https://github.com/EByrdS.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/EByrdS/szymanskis_mutex.png?branch=master)](https://travis-ci.org/EByrdS/szymanskis_mutex)\n[![Inline docs](http://inch-ci.org/github/EByrdS/szymanskis_mutex.svg?branch=master)](http://inch-ci.org/github/EByrdS/szymanskis_mutex)\n![](https://ruby-gem-downloads-badge.herokuapp.com/szymanskis_mutex?extension=png)\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n[![Gem](https://img.shields.io/gem/v/szymanskis_mutex.svg?style=flat)](http://rubygems.org/gems/szymanskis_mutex \"View this project in Rubygems\")\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)\n\n# Szymański's Mutual Exclusion Algorithm\n\nThis algorithm is modeled on a waiting room with an entry and exit doorway.\nInitially the entry door is open and the exit door is closed.\nAll processes which request entry into the critical section at the same time\nenter the waiting room; the last of them closes the entry door and opens\nthe exit door. The processes then enter the critical section one by one.\nThe last process to leave the critical section closes the exit door and\nreopens the entry door so he next batch of processes may enter.\n\n## Getting Started\nInstall the gem or add it to the Gemfile.\n```\n$ gem install szymanskis_mutex\n```\n\nProvide a block containing the critical section to the class method\n`mutual_exclusion(concern)`. The parameter `concern` is used so that\nyou can have different use cases without them accessing the same variables.\n(You can have as many separate MutEx as you want.)\n\n```ruby\nclass RaceConditionReproducer\n @@value = 0\n\n def mutex_increment\n   SzymanskisMutex.mutual_exclusion(:add) { unsafe_increment }\n end\n\n def unsafe_increment\n   sleep 2\n   temp = @@value\n\n   sleep 2\n   temp += 1\n\n   sleep 2\n   @@value = temp\n end\nend\n```\n\nThe MutEx will work across different instances of the same class as\nit works with class variables.\n\n## Contribution\nPull Requests will be reviewed before merging. Issues are being addressed.\nAll Pull Requests must contain specs for the changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febyrds%2Fszymanskis_mutex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febyrds%2Fszymanskis_mutex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febyrds%2Fszymanskis_mutex/lists"}