A CPU scheduler determines an order for the execution of its scheduled processes; it decides which process will run according to a certain data structure that keeps track of the processes in the system and their status.
A process, upon creation, has one of the three states: Running, Ready, Blocked (doing I/O, using other resources than CPU or waiting on unavailable resource).
OS for 1 CPU and fixed memory size 1024 byte
- LinkedList for storing processes and memory free list.
- Dynamic array (vector) for storing weighted turnaround time.
The process generator readsinput,initiate and create the scheduler and clock processes.
The scheduler communicates with the process generator through 2 semaphores and message queues.
Whenever the process generator finishes it sends a message to the scheduler and busy waits till it’s killed.
The scheduler forksthe process and, for phase 2, allocates its memoryFor phase 2, We store the memory free list in an array with size 11 memory segments from 2^0 to 2^10, every index in the free list is a linked list ofsorted allocated memory segmentsTheprocessupdatesitsremaining time and stores it in a shared memoryso thescheduler can access it .Every one clock Scheduler takes the lead and pause the running process with semaphores .Every one clock Scheduler receives the data from Process generator, updates the running process PCB, decides to stop the running process and start other one or not according to the selected algorithm (RR, SRTN, HPF) Thescheduler will remove the process from the queue and, for phase 2, deallocate the memory used by this processwhenthe remaining time of the process is zero.
- Assumptions :
- No process can arrive at 0 (this causes inconsistency as the program requires time to initialize)
- In phase 2 RR, If a process cannot be allocated (insufficient memory) it proceeds to the next process and if it is at the end it wraps around.
- In phase 2, If 2 or more processes have the same everything except memory size it does NOT get sorted by the memory size. We just get the same order of the process generator.
- The compiled programs is .out (not .o). it matters as we are calling them by name in the code.
You can use this snippet for compiling the program.
PS: the -lm argument while compiling scheduler is necessary.
gcc process_generator.c -o process_generator.out gcc clk.c -o clk.out gcc scheduler.c -lm -o scheduler.out gcc process.c -o process.out
- Clone the repository
$ git clone https://github.com/D4rk1n/OS_Proj
- Navigate to repository directory
$ cd OS_Proj
run ./process_generator.out-h
to see explanation of the arguments
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b AmazingFeature-Feat
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin AmazingFeature-Feat
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Abdelrahman Tarek |
Hassan Mohamed |
Abdelrahman Arafat |
Aly Abozied |