{"id":23185848,"url":"https://github.com/thesupercd/cpu_scheduler","last_synced_at":"2025-04-05T04:44:17.905Z","repository":{"id":266440354,"uuid":"898354788","full_name":"TheSUPERCD/CPU_Scheduler","owner":"TheSUPERCD","description":"A simple and rudimentary program written in C++ that simulates the operation of a CPU task scheduler using three distinct methodologies - namely FIFO, SJF and Priority scheduling algorithms. ","archived":false,"fork":false,"pushed_at":"2024-12-08T08:03:51.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T12:43:22.637Z","etag":null,"topics":["cpp","cpu-scheduling","cpu-scheduling-algorithms","fifo","preemptive-scheduling","priority-scheduling","scheduler","scheduling-algorithms","scheduling-simulator","sjf-scheduling"],"latest_commit_sha":null,"homepage":"","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/TheSUPERCD.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":"2024-12-04T08:46:34.000Z","updated_at":"2024-12-08T08:03:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c1f86d6-e7c6-4cb6-b2c1-f56d0f38bdbd","html_url":"https://github.com/TheSUPERCD/CPU_Scheduler","commit_stats":null,"previous_names":["thesupercd/cpu_scheduler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FCPU_Scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FCPU_Scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FCPU_Scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheSUPERCD%2FCPU_Scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheSUPERCD","download_url":"https://codeload.github.com/TheSUPERCD/CPU_Scheduler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289398,"owners_count":20914464,"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","cpu-scheduling","cpu-scheduling-algorithms","fifo","preemptive-scheduling","priority-scheduling","scheduler","scheduling-algorithms","scheduling-simulator","sjf-scheduling"],"created_at":"2024-12-18T10:13:02.449Z","updated_at":"2025-04-05T04:44:17.896Z","avatar_url":"https://github.com/TheSUPERCD.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Introduction\n\nThis project is a rough attempt at simulating the core logic of a modern CPU task scheduler, while utilizing basic C++ functions to achieve this goal. This project is aimed to understand the algorithm many operating system kernels (e.g. Windows, Linux, and Unix) implement under the hood to seamlessly switch between innumerable user-space programs depending on their levels of priority to give us the typical smooth experience of using a modern computing system.\n\n## How to compile and run the program\n\nFor the sake of convenience, this project includes a `Makefile` in the root directory. Simply typing in the following in a typical Unix-like command shell (Terminal) will be sufficient to compile and run the program, and even clean up afterwards to save up on a little bit of disk space ;D\n\n```shell\n$ make\n$ ./scheduler ./data/Datafile.txt\n============================= FIFO Scheduler =============================\nArrival time\tCPU Burst length\tPriority \tCompletion Times\n    10  \t\t 22  \t\t 1  \t\t\t   32\n    68  \t\t 12  \t\t 6  \t\t\t   80\n    98  \t\t 34  \t\t 8  \t\t\t  132\n   148  \t\t 28  \t\t10  \t\t\t  176\n   192  \t\t  3  \t\t 3  \t\t\t  195\n   223  \t\t  8  \t\t 3  \t\t\t  231\n   266  \t\t 18  \t\t 2  \t\t\t  284\n   268  \t\t 14  \t\t10  \t\t\t  298\n   268  \t\t 30  \t\t 4  \t\t\t  328\n   296  \t\t 10  \t\t 7  \t\t\t  338\n   354  \t\t  6  \t\t 3  \t\t\t  360\n   375  \t\t  2  \t\t 8  \t\t\t  377\n   377  \t\t 31  \t\t 2  \t\t\t  408\n   406  \t\t 10  \t\t 4  \t\t\t  418\n   457  \t\t 21  \t\t 9  \t\t\t  478\n   469  \t\t  1  \t\t10  \t\t\t  479\n   529  \t\t  9  \t\t 6  \t\t\t  538\n   559  \t\t 12  \t\t 5  \t\t\t  571\n   581  \t\t 39  \t\t 1  \t\t\t  620\n   630  \t\t 17  \t\t 8  \t\t\t  647\n\n=================== SJF Scheduler (Without Preemption) ===================\nArrival time\tCPU Burst length\tPriority \tCompletion Times\n    10  \t\t 22  \t\t 1  \t\t\t   32\n    68  \t\t 12  \t\t 6  \t\t\t   80\n    98  \t\t 34  \t\t 8  \t\t\t  132\n   148  \t\t 28  \t\t10  \t\t\t  176\n   192  \t\t  3  \t\t 3  \t\t\t  195\n   223  \t\t  8  \t\t 3  \t\t\t  231\n   266  \t\t 18  \t\t 2  \t\t\t  284\n   268  \t\t 14  \t\t10  \t\t\t  298\n   268  \t\t 30  \t\t 4  \t\t\t  338\n   296  \t\t 10  \t\t 7  \t\t\t  308\n   354  \t\t  6  \t\t 3  \t\t\t  360\n   375  \t\t  2  \t\t 8  \t\t\t  377\n   377  \t\t 31  \t\t 2  \t\t\t  408\n   406  \t\t 10  \t\t 4  \t\t\t  418\n   457  \t\t 21  \t\t 9  \t\t\t  478\n   469  \t\t  1  \t\t10  \t\t\t  479\n   529  \t\t  9  \t\t 6  \t\t\t  538\n   559  \t\t 12  \t\t 5  \t\t\t  571\n   581  \t\t 39  \t\t 1  \t\t\t  620\n   630  \t\t 17  \t\t 8  \t\t\t  647\n\n================== PRIORITY Scheduler (With Preemption) ==================\nArrival time\tCPU Burst length\tPriority \tCompletion Times\n    10  \t\t 22  \t\t 1  \t\t\t   32\n    68  \t\t 12  \t\t 6  \t\t\t   80\n    98  \t\t 34  \t\t 8  \t\t\t  132\n   148  \t\t 28  \t\t10  \t\t\t  176\n   192  \t\t  3  \t\t 3  \t\t\t  195\n   223  \t\t  8  \t\t 3  \t\t\t  231\n   266  \t\t 18  \t\t 2  \t\t\t  338\n   268  \t\t 14  \t\t10  \t\t\t  282\n   268  \t\t 30  \t\t 4  \t\t\t  322\n   296  \t\t 10  \t\t 7  \t\t\t  306\n   354  \t\t  6  \t\t 3  \t\t\t  360\n   375  \t\t  2  \t\t 8  \t\t\t  377\n   377  \t\t 31  \t\t 2  \t\t\t  418\n   406  \t\t 10  \t\t 4  \t\t\t  416\n   457  \t\t 21  \t\t 9  \t\t\t  479\n   469  \t\t  1  \t\t10  \t\t\t  470\n   529  \t\t  9  \t\t 6  \t\t\t  538\n   559  \t\t 12  \t\t 5  \t\t\t  571\n   581  \t\t 39  \t\t 1  \t\t\t  620\n   630  \t\t 17  \t\t 8  \t\t\t  647\n```\n\n...And just as shown above, the program will take a file populated with data that describes an inflow of programs being sent to the scheduler's queue to be executed, and output the results of the simulation in a tabular format (truncated in the case shown above) - for each of the three basic scheduling algorithms implemented in our rudimentary project.\n\nAlso, the program can of course be modified to show the full output instead of a truncated version with a simple command-line argument being appended at the end, as shown in the following example:\n\n```shell\n$ ./scheduler ./data/Datafile.txt --display-all\n============================= FIFO Scheduler =============================\nDisplaying All Processes:\n\nArrival time\tCPU Burst length\tPriority \tCompletion Times\n    10  \t\t 22  \t\t 1  \t\t\t   32\n    68  \t\t 12  \t\t 6  \t\t\t   80\n    98  \t\t 34  \t\t 8  \t\t\t  132\n   148  \t\t 28  \t\t10  \t\t\t  176\n   192  \t\t  3  \t\t 3  \t\t\t  195\n   223  \t\t  8  \t\t 3  \t\t\t  231\n   266  \t\t 18  \t\t 2  \t\t\t  284\n   268  \t\t 14  \t\t10  \t\t\t  298\n   268  \t\t 30  \t\t 4  \t\t\t  328\n   296  \t\t 10  \t\t 7  \t\t\t  338\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n\n=================== SJF Scheduler (Without Preemption) ===================\nDisplaying All Processes:\n\nArrival time\tCPU Burst length\tPriority \tCompletion Times\n    10  \t\t 22  \t\t 1  \t\t\t   32\n    68  \t\t 12  \t\t 6  \t\t\t   80\n    98  \t\t 34  \t\t 8  \t\t\t  132\n   148  \t\t 28  \t\t10  \t\t\t  176\n   192  \t\t  3  \t\t 3  \t\t\t  195\n   223  \t\t  8  \t\t 3  \t\t\t  231\n   266  \t\t 18  \t\t 2  \t\t\t  284\n   268  \t\t 14  \t\t10  \t\t\t  298\n   268  \t\t 30  \t\t 4  \t\t\t  338\n   296  \t\t 10  \t\t 7  \t\t\t  308\n   354  \t\t  6  \t\t 3  \t\t\t  360\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n\n================== PRIORITY Scheduler (With Preemption) ==================\nDisplaying All Processes:\n\nArrival time\tCPU Burst length\tPriority \tCompletion Times\n    10  \t\t 22  \t\t 1  \t\t\t   32\n    68  \t\t 12  \t\t 6  \t\t\t   80\n    98  \t\t 34  \t\t 8  \t\t\t  132\n   148  \t\t 28  \t\t10  \t\t\t  176\n   192  \t\t  3  \t\t 3  \t\t\t  195\n   223  \t\t  8  \t\t 3  \t\t\t  231\n   266  \t\t 18  \t\t 2  \t\t\t  338\n   268  \t\t 14  \t\t10  \t\t\t  282\n   268  \t\t 30  \t\t 4  \t\t\t  322\n   296  \t\t 10  \t\t 7  \t\t\t  306\n   354  \t\t  6  \t\t 3  \t\t\t  360\n   375  \t\t  2  \t\t 8  \t\t\t  377\n   377  \t\t 31  \t\t 2  \t\t\t  418\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n   ...  \t\t ...  \t\t...  \t\t\t  ...\n```\n\n*NOTE: Even though the `--display-all` flag at the end looks like a typical command-line flag that can appended anywhere to work properly when executing the compiled program, in truth it strictly needs to be appended at the 2nd argument position to work as intended (refer to the source code in `./src/main.cpp`).*\n\nAfter verifying that everything works as intended and the simulation outputs match our expectations, we run `make clean` to remove the build files and the binary executable from the project root directory to keep everything nice and tidy. \n\n## Final Conclusion\n\nAs a matter of course, actual CPU schedulers working at the core of every major Operating System have slightly different behavior and much higher complexity compared to the schedulers simulated by this rudimentary program. \n\nHowever, that does not mean the core of them is any different. \n\nThis program helps us to understand the core methodology used by modern CPU schedulers working at the heart of Operating System kernels, and also helps us better manage any user-space programs we write as programmers and developers -- to better take advantage of the modern computing hardware in specific mission-critical applications. \n\n...Or to simply optimize our programs a little more in order to run better on low-computing-power machines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesupercd%2Fcpu_scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthesupercd%2Fcpu_scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesupercd%2Fcpu_scheduler/lists"}