main.py: Contains main section of the programtask.py: Illustrates class "Task". This class contains attributes such as:- name
- type (X, Y, Z)
- duration (CPU burst-time)
- cpu_time (how much time CPU has assigned time to this task)
- priority
- required resources: X: (A,B), Y: (B,C), Z: (A,C)
cpuCore.py: Illustrates class "CPUCore". This class contains attributes such as:- name
- idle_time (how much time this core has been busy)
- state (busy, idle, running)
- running_task (indicates he task that is processing by this CPU-core)
- process_task() process the input task preemptive/none-preemptive
schedulers.py: Contains different scheduling algorithms and also needed functions to run themglobals.py: Contains globals variables and functions used in different files
In this project I was supposed to implement some well-known OS scheduler algorithms. The implemented algorithms are as follows:
FCFS: First Come First ServiceSJF: Shortest Job FirstRR: Round RobinMLFQ: Multilevel feedback queueMLQ: Multilevel Queue (based on priorities)
- First of all you should run
main.pywith python 3.xx:
python3 main.py
- Choose the desired scheduler algorithm by typing its abbreviation:
FCFS,SJF,RR,MLFQ,MLQ3.Specify the number of resources that are available in this system. You should enter the number of resourcesA,B,Crespectively. - Enter the number of tasks that need to be processed
- Enter the information about tasks (line-by-line) in the following format:
<name> <type> <duration> - Enter the intended number of CPU-cores
- In case that selected scheduler algorithm needs more parameters to be specified such as time-quantum or number of queues, you'll be asked to enter them at this step, otherwise algorithm starts working!
- In this program, tasks are fed to system at the first step which means tasks will not be added to system while CPU is processing
- One of the main advantages of this program is
multithreading! It allows tasks to be processed by different CPU-cores simultaneously. So to be able to run this program you should have installedthreadingmodule - To be able to use advantages of multi-threading, I used different
Semaphores - This project was done as my final project of
Operating Systemscourse in semester 5