Skip to content

๐Ÿ“ขA CPU scheduler determines an order for the execution of its scheduled processes. Operating System Scheduler decides which process will run according to a certain data structure that keeps track of the processes in the system and their status.

License

Notifications You must be signed in to change notification settings

EslamAsHhraf/Operating-System-Scheduler

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

55 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ–ฅ๏ธ Operating System Scheduler

logo


๐Ÿ“ Table of Contents


๐Ÿ“™ Overview


  • 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).
  • A bad scheduler will make a very bad operating system, so your scheduler should be as much optimized as possible in terms of memory and time usage.
  • The project has 2 phases.


  • Build using C lnaguage.

๐Ÿš€ Get Started

  1. Clone the repository.
    git clone https://github.com/AdhamAliAbdelAal/OS-Project
    
  2. You will need to download platform Linux.

  3. Install a C Compiler on Linux if you haven't.
    sudo dnf install gcc
    

๐Ÿ—บ๏ธ Path of the program

  1. Go to folder Phase 1 or Phase 2 , as you want.
  2. Put input in file "processes.txt" or run file "test_generator.c" and it will put random input

    • Phase 1

    • Phase 2


  3. Open terminal
  4. Build file process_generator.c.

  5. gcc process_generator.c -o ex
    
  6. Run ex.

  7. ./ex
    

  8. Choose a scheduling algorithm.

  9. Input Algorithm
    1 Non-preemptive Highest Priority First (HPF)
    2 Shortest Remaining time Next (SRTN)
    3 Round Robin (RR)


  10. There are 2 output file "scheduler.Log" and "scheduler.perf". "memory.log" is created in phase 2.

    • scheduler.Log


    • scheduler.perf

    • memory.log


๐Ÿ—๏ธ Data Structures Used


  1. Queue
  2. Priority Queue
  3. Process Data
    • Arrival time
    • Priority
    • Run time
    • ID
    • Memsize
  4. Memory Node
    • Size
    • Start
    • Pointer to the next memory node
  5. PCB for each process
    • ID
    • PID
    • Arrival time
    • Burst time
    • Finish time
    • Running time
    • Stop time
    • Priority
    • Start time
    • Start Address in memory
    • Memory Size

๐Ÿง  Algorithms Explanation


  1. HPF
    • The main loop checks if the processes are all finished or not.
    • In an inner loop, we get all the processes arrived at this particular second and enqueue them in the ready queue.
    • If there is no current process and the ready queue isnโ€™t empty, we directly pop from the ready queue as itโ€™s already sorted with the minimum priority, then start the process, fork it, and execl Process.c.
    • Last check: If the remaining time of the running process is zero, then it is finished and the running process is set to NULL. The finished processes counter is incremented as well and the loop continues.
  2. SRTN
    • Receiving the processes from the process generator.
    • Checking if the coming process's burst time is smaller than the remaining time of the running process.
    • If it's smaller than the running process will be added to the ready queue and saved in stop resuming queue and the smaller one will be the running process.
    • Then every time we a process starts then we check if this process was stopped before โ€œexisting in stop resuming queue" or not to know if it started or resumed to resume the stopped process.
  3. RR
    • Check if there are arriving processes, receive them in ready queue.
    • Check if there is a processes finished or the time slot ended, change the state of the process from running to finished or ready respectively.
    • Check if there are processes in ready queue and no process is running so pick up one of them and run it.

๐Ÿ“œ Assumptions


  1. In the memory waiting queue, it is implemented as a priority queue based on the algorithm so if itโ€™s a SRTN, the priority is the remaining time while for RR, it is based on the memory size where the smaller one gets put into the ready queue first. As for the HPF, there is no need since the running process is the only one put into the ready queue.

  2. We made an array of arrivals in the process generator as a shared memory with the scheduler in order to make sure that any process arriving at a specific time is read by the scheduler and not skipped.

  3. We synchronize between the stopped process and the arrived one if they come in the same second so that the stopped process is put into the queue before the arrived process.

๐Ÿ—ƒ๏ธ File Structure



๐Ÿ‘‘ Contributors


Abdelrahman Noaman


Abdelrahman Hamdy


Adham Ali


Eslam Ashraf

๐Ÿ”’ License

This software is licensed under MIT License, See License for more information ยฉAdhamAliAbdelAal.

About

๐Ÿ“ขA CPU scheduler determines an order for the execution of its scheduled processes. Operating System Scheduler decides which process will run according to a certain data structure that keeps track of the processes in the system and their status.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.9%
  • Makefile 1.1%