Skip to content

ahmedasad236/OS_Scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 

Repository files navigation

OS Scheduler

  • Introduction

    • Scheduling the processes by the operating system is one of the most important jobs of the OS. We will apply some scheduling algorithm in this project, like SRTN algorithm, RoundRobin algorithm, HPF algorithm.

    • Note: This code is valid only on linux machines


  • Algorithms

    • SRTN algorithm:

      This algorithm depends on choosing the shortest remaining time process to be executed, it depends on the priority queue datastructure. and it is the preemptive version of SJF (shortest job first) algorithm.

    • Non preemptive HPF algorithm:

      This algorithm's criteria depends on choosing the highest priority process, each process has a number represents its priority, the lowest number represnts the highest priority process

    • Round Robin algorithm:

      This algorithm's criteria is to give each process a time slot for running and then, return it back to the ready queue and run the next process, and so on.


  • Project structure

        ├── Code
        │   ├── DS
        │   │   ├── linkedlist.h
        │   │   ├── priorityQueue.h
        │   │   ├── queue.h
        |   ├── algorithms
        |   |   ├── HPF.h
        |   |   ├── RounRobin.h
        |   |   ├── SRTN.h
        |   |   ├── common.h
        |   ├── globals
        |   |   ├── PCB.h
        |   |   ├── global_variables.h
        |   |   ├── headers.h
        |   ├── helping
        |   |   ├── kill_running_processes.sh
        |   |   ├── run_scheduler.sh
        |   ├── process
        |   |   ├── clk.c
        |   |   ├── process.c
        |   |   ├── scheduler.c
        |   |   ├── process_generator.c
        |   |   ├── memory.h
        |   |   ├── memory.c
        |   |   ├── processes.txt
        |   |   ├── process_info.txt
        |                      
        ├── README.md

  • How to run the scheduler

    • to generate a test case run the following

      •    cd code/process
      •    gcc test_generator.c -o test.out && ./test.out
    • open two terminals and run the following commands in the first terminal

      •   cd code/process/
      •   gcc process_generator.c -o process_generator.out && ./process_generator.out  
    • then run the following to the second one

      •   cd code/process/
      •   gcc scheduler.c -o scheduler.out -lm && ./scheduler.out 

  • Scheduler Flow

    • Firstly, the input text file processes.txt is read and save the processes data in the process_generator

    • Each clock cycle generated by the program clk.c, we check if there is a process should be forked or not!

    • After generating the process, it is listed in the queue of the chosen algorithm

    • When the process is ready to start, we check first the memory size and depending on that we decide to run the process or wait untill any bulk of memory is freed.

    • when the process finish, we save all its information, arrival time, finish time, waiting time, burst time, Turnaround time, etc.


  • Output files

    • scheduler.log contains the following information for each process

      • arrival time

      • state

      • process id

      • total time

      • Turnaround time(TA)

      • Waited turnaround time(WTA)

    • scheduler.pref contains the following information

      • CPU utilization

      • AVG WTA

      • Avg Waiting

      • Std WTA

    • memory.log contains the following information

      • process id

      • allocated time

      • freed time

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages