C program on the priority scheduling algorithm (Non preemptive) in operating system (os)
In this post I am going to explain you all things related to the priority scheduling . What is priority scheduling , what is the characteristics of the priority scheduling , what is the drawbacks of the this algorithm . all that points.
What is the priority scheduling:-
As it is clear with the name that this scheduling is based on the priority of the processes. The process which have the higher priority will get the CPU first. whereas jobs with equal priorities are carried out on a round-robin or FCFS basis.
This scheduling is of two types:-
1. Non preemptive
2. Preemptive
characteristics:-
- It schedules the process based on the priority of the processes.
- Lower the number higher the priority.
- If the two or more processes have the same priority then we schedules on the basis of FCFS.
- Major problem with priority scheduling is problem of starvation.
- Solution of the problem of the starvation is aging ,where aging is a technique of gradually increasing the priority of the processes that wait in the system from long time.
Drawbacks:-
- Major problem with priority scheduling is problem of starvation.
- Solution of the problem of the starvation is aging ,where aging is a technique of gradually increasing the priority of the processes that wait in the system from long time.
Code:-
1.After taking the input first we sort the input on the basis of Arrival time (i.e the process which have less Arrival time will come first).
2.Here one more things we will do . we will check that the arrival time of all the processes are different or not. (Example:- if all the processes comes at the same time then we don’t need to sort the array on the basis of arrival time ) . for checking this we will use check_ar.
3.After doing this if processes are arrived at the different time then we can easily calculate the waiting and turn around time for the first process. and for other process first we will find the highest priority (less priority number) of the process which are arrived at cmp_time (completion time of the previous process) .
You can easily understand by Following code .
Output:-
Recommended post:-
Hackerearth Problems:-
- Very Cool numbers | Hacker earth solution
- Birthday party | Hacker earth solution
- Most frequent | hacker earth problem solution
- program to find symetric difference of two sets
- cost of balloons | Hacker earth problem solution
- Chacha o chacha | hacker earth problem solution
- jadu and dna | hacker earth solution
- Bricks game | hacker earth problem
- Anti-Palindrome strings | hacker earth solution
- connected components in the graph | hacker earth data structure
- odd one out || hacker earth problem solution
- Minimum addition | Hackerearth Practice problem
- The magical mountain | Hackerearth Practice problem
- The first overtake | Hackerearth Practice problem
Data structure:-
- Program to find cycle in the graph
- Implementation of singly link list
- Implementation of queue by using link list
- Algorithm of quick sort
- stack by using link list
- program to find preorder post order and inorder of the binary search tree
- Minimum weight of spanning tree
- Preorder, inorder and post order traversal of the tree
Key points:-
- How to set limit in the floating value in python
- What is boolean data type
- How to print any character without using format specifier
Must check this:-