{"id":46048418,"url":"https://github.com/ryjen/scheduling-algos","last_synced_at":"2026-03-01T08:07:07.169Z","repository":{"id":145316182,"uuid":"141757304","full_name":"ryjen/scheduling-algos","owner":"ryjen","description":"some operating system related algorithm kata","archived":false,"fork":false,"pushed_at":"2024-02-29T20:33:29.000Z","size":615,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-29T21:49:11.105Z","etag":null,"topics":["algorithms","c","operating-systems","scheduling-algorithms","shell"],"latest_commit_sha":null,"homepage":null,"language":"C","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/ryjen.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-07-20T20:59:46.000Z","updated_at":"2021-10-17T23:22:22.000Z","dependencies_parsed_at":"2024-02-29T21:53:16.081Z","dependency_job_id":null,"html_url":"https://github.com/ryjen/scheduling-algos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ryjen/scheduling-algos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryjen%2Fscheduling-algos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryjen%2Fscheduling-algos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryjen%2Fscheduling-algos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryjen%2Fscheduling-algos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryjen","download_url":"https://codeload.github.com/ryjen/scheduling-algos/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryjen%2Fscheduling-algos/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29964203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T06:55:38.174Z","status":"ssl_error","status_checked_at":"2026-03-01T06:53:04.810Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["algorithms","c","operating-systems","scheduling-algorithms","shell"],"created_at":"2026-03-01T08:07:06.623Z","updated_at":"2026-03-01T08:07:07.153Z","avatar_url":"https://github.com/ryjen.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scheduling algorithms\n\n## design\n\n### model\n\n#### queue\n\nQueue's represent a doubly linked list of processes.  Used in:\n\n* scheduler new process arrivals\n* an algorithm processing queue\n* scheduler completed processes for post processing\n\n#### processes\n\nRepresents a process in the scheduler.  The key information is:\n\n* arrival time\n* service time\n* completion time\n\nThey also maintains a state of their current clock ticks.\n\n#### algorithms\n\nRepresents an algorithm to handle queue operations through various callbacks.\n\n* OnProcessArrive: used by the scheduler to put arrivals onto the queue\n* OnProcessReady: used by the scheduler to test for queued processes\n* OnProcessGet: used by the scheduler to obtain a process for a time slice (tick)\n* OnProcessPut: used by the scheduler to finish a process time slice\n\nArbitrary data can be passed as an argument to the callbacks.\n\n### logic\n\n#### scheduler\n\nA producer/consumer design pattern that:\n\n1. accepts new arrivals on arrival time\n2. sends processes to the algorithm queues\n3. consumes scheduled processes\n4. performs completion statistics\n\nThe scheduler maintains a clock tick for time sliced processing.\n\n\n#### first come, first serve (ftfs)\n\nself explanatory\n\n#### shortest process next (spn)\n\nSee [wiki](https://en.wikipedia.org/wiki/Shortest_job_next)\n\n#### shortest time remaining (str)\n\nSee [wiki](https://en.wikipedia.org/wiki/Shortest_remaining_time)\n\n#### round robin (rr)\n\nAccepts a quantum integer as input with a default of 3.\n\nself explanatory.  see [wiki](https://en.wikipedia.org/wiki/Round-robin_scheduling)\n\n#### multi level feedback queue\n\nAccepts a quantum and the number of queues as input (defaults of 3).\n\nSee [wiki](https://en.wikipedia.org/wiki/Multilevel_feedback_queue)\n  \n#### lottery\n\nThe [lottery algorithm](https://en.wikipedia.org/wiki/Lottery_scheduling) uses process tickets and randomization to schedule the next process.\n\nThe way processes get tickets is left to the implementation.  I've chosen to have a global maximum tickets of 100.\nA random number betweeen 0 and 99 generates the winning ticket.  \n\n\nIf a ticket is greater than the winning lottery number, it gets processed.\n\n**Implementation 1**\n\nThe total tickets is divided evenly between processes.  For example, 2 processes will get 50 tickets each. Meaning process A will have 0-49 and process B will have 50-99.\n\n**Implementation 2**\n\nThe total tickets is divided based on a percentage of the process service time.  The processes are sorted based on service time. Since the list is sorted, the processes with the greatest amount of tickets are first.\n\nFor example, if process A has a service time of 9 and process B has a service time of 3 then the total service time is 12.  \nMeaning process A will get 75 tickets and process B will get 25 tickets.\n\n## testing\n\n```make test```\n\n```./generate-processes | ./fcfs.verify```\n\n```./generate-processes | ./lottery.verify```\n\netc.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryjen%2Fscheduling-algos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryjen%2Fscheduling-algos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryjen%2Fscheduling-algos/lists"}