{"id":22736572,"url":"https://github.com/fredwangwang/cpu-scheduling-simulator","last_synced_at":"2025-03-30T02:44:06.159Z","repository":{"id":129385095,"uuid":"84265266","full_name":"fredwangwang/cpu-scheduling-simulator","owner":"fredwangwang","description":null,"archived":false,"fork":false,"pushed_at":"2017-10-04T14:19:30.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T05:22:46.389Z","etag":null,"topics":["cpp","scheduling-algorithms","simulator"],"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/fredwangwang.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,"publiccode":null,"codemeta":null}},"created_at":"2017-03-08T01:42:12.000Z","updated_at":"2017-05-30T05:47:19.000Z","dependencies_parsed_at":"2023-03-25T19:33:46.430Z","dependency_job_id":null,"html_url":"https://github.com/fredwangwang/cpu-scheduling-simulator","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/fredwangwang%2Fcpu-scheduling-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fcpu-scheduling-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fcpu-scheduling-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fcpu-scheduling-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredwangwang","download_url":"https://codeload.github.com/fredwangwang/cpu-scheduling-simulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246269911,"owners_count":20750319,"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":["cpp","scheduling-algorithms","simulator"],"created_at":"2024-12-10T21:27:45.905Z","updated_at":"2025-03-30T02:44:06.137Z","avatar_url":"https://github.com/fredwangwang.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPU Scheduling Simulator\n\nHuan Wang\n\nall source files are in src folder, which contains:\n\n  Brust.h // contains data structure for brust\n  Event.h // contains event data type\n  Parse_flag.h // contains methods to interpret flags\n  Parse_flag.cpp // implementation\n  Priority_type.h // const for representing priority\n  priority_type.cpp // implementation\n  Process.h // contains data structure for Process\n  Thread.h // contains data structure for Thread\n  Simulator.h // main logic controlling the program flow\n  Simulator.cpp // implementation\n  scheduling_algo:\n    Scheduling_algorithm.h // virtual class for all algorithms\n    algo_CUSTOM.h // custom algorithm\n    ... // various implementations\n\ninteresting feature:\n\n  The implementation of the simulator and the scheduling algorithm are separated. The simulator can work with any scheduling as long as it is the child class of Scheduling_algorithm\n\nTime:\n10+?\n\nFor the custom algorithm, there are 4 priority queues used. Each of them holds the thread from different priorities. The priority queues themselves keep the oldest thread in the front to prevent starvation. And when scheduling, a weighted random choose is implemented for fairness (randomness is a good friend of fairness). The weight I used in the algorithm is 1:2:3:4 for batch:normal:interactive:system. If the selected priority doesn't have any ready threads in the queue, a thread is chosen in the decreasing order of priority (e.g. if there is ready threads in system queue, that thread is chosen). And to compensate the \"uneven fairness\" due to the weighted probability, a different time slice is assigned to different priorities. System has a shortest slice of 3 unit, interactive and normal can run up to 4 unit of time until preemption. And batch thread has the longest time of 7 units.\n\nCombining random choosing and priority queues, this algorithm is good at resisting aging and starvation caused by different priorities. However, starvation is still possible. Starvation will happen only if the thread adding into the system much faster than the system can process. Because the newly added threads are considered as \"oldest\" threads to optimize for response time. This is a nice feature, but it will cause starvation if new threads keep coming all the time. The the scheduler will always pick the newly added threads.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwangwang%2Fcpu-scheduling-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredwangwang%2Fcpu-scheduling-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwangwang%2Fcpu-scheduling-simulator/lists"}