{"id":18250737,"url":"https://github.com/devarshi16/multicoaster-semaphore","last_synced_at":"2025-06-12T14:08:05.582Z","repository":{"id":260077507,"uuid":"111272560","full_name":"devarshi16/Multicoaster-Semaphore","owner":"devarshi16","description":"5.8 The roller coaster problem This problem is from Andrews’s Concurrent Programming [1], but he attributes it to J. S. Herman’s Master’s thesis. Suppose there are n passenger threads and a car thread. The passengers repeatedly wait to take rides in the car, which can hold C passengers, where C \u003c n. The car can go around the tracks only when it is full. Here are some additional details: • Passengers should invoke board and unboard. • The car should invoke load, run and unload. • Passengers cannot board until the car has invoked load • The car cannot depart until C passengers have boarded. • Passengers cannot unboard until the car has invoked unload. Puzzle: Write code for the passengers and car that enforces these constraints.","archived":false,"fork":false,"pushed_at":"2022-04-27T17:27:27.000Z","size":1597,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T21:48:31.018Z","etag":null,"topics":["puzzle","pygame","python","roller-coaster-problem","semaphores","threading"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/devarshi16.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":"2017-11-19T07:05:17.000Z","updated_at":"2022-04-27T17:27:30.000Z","dependencies_parsed_at":"2024-10-29T12:50:01.326Z","dependency_job_id":null,"html_url":"https://github.com/devarshi16/Multicoaster-Semaphore","commit_stats":null,"previous_names":["devarshi16/multicoaster-semaphore"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devarshi16/Multicoaster-Semaphore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devarshi16%2FMulticoaster-Semaphore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devarshi16%2FMulticoaster-Semaphore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devarshi16%2FMulticoaster-Semaphore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devarshi16%2FMulticoaster-Semaphore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devarshi16","download_url":"https://codeload.github.com/devarshi16/Multicoaster-Semaphore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devarshi16%2FMulticoaster-Semaphore/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259479593,"owners_count":22864362,"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":["puzzle","pygame","python","roller-coaster-problem","semaphores","threading"],"created_at":"2024-11-05T09:45:42.815Z","updated_at":"2025-06-12T14:08:05.493Z","avatar_url":"https://github.com/devarshi16.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multicoaster-Semaphore\n5.8 The roller coaster problem This problem is from Andrews’s Concurrent Programming [1],\nbut he attributes it to J. S. Herman’s Master’s thesis. Suppose there are n passenger threads and a car thread. \nThe passengers repeatedly wait to take rides in the car, which can hold C passengers, where C \u0026lt; n. \nThe car can go around the tracks only when it is full. Here are some additional details: \n• Passengers should invoke board and unboard. • The car should invoke load, run and unload. \n• Passengers cannot board until the car has invoked load • The car cannot depart until C passengers have boarded. \n• Passengers cannot unboard until the car has invoked unload. \nPuzzle: Write code for the passengers and car that enforces these constraints.\n\n5.8.3 Multi-car Roller Coaster problem\nThis solution does not generalize to the case where there is more than one car.\nIn order to do that, we have to satisfy some additional constraints:\n• Only one car can be boarding at a time.\n• Multiple cars can be on the track concurrently.\n• Since cars can’t pass each other, they have to unload in the same order\nthey boarded.\n• All the threads from one carload must disembark before any of the threads\nfrom subsequent carloads.\nPuzzle: modify the previous solution to handle the additional constraints.\nYou can assume that there are m cars, and that each car has a local variable\nnamed i that contains an identifier between 0 and m − 1.\n\nsimulation of code on the above code in the link below\nhttps://www.youtube.com/watch?v=X4MdaWIQv_o\u0026t=135s\n\n## Installation requirement\nNote that currently the code only works with python 2 may upgrade in future.\nIf you don't have `git` already installed you may do so by\n```\nsudo apt get install git\n```\nThen clone this repo by\n```\ngit clone https://github.com/devarshi16/Multicoaster-Semaphore\n```\nChange directory into the cloned repository\n```\ncd Multicoaster-Semaphore\n```\nInstall pygame(for the graphics)\n```\npip install pygame\n```\nRun the code\n```\npython multicoaster.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevarshi16%2Fmulticoaster-semaphore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevarshi16%2Fmulticoaster-semaphore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevarshi16%2Fmulticoaster-semaphore/lists"}