Here we are going discuss all things about the SJF scheduling algorithm i.e what is SJF , what are the advantage of SJF , what is disadvantage of SJF ,Code of SJF.
What is SJF(Shortest job First) scheduling:-
As it is clear by the name of this scheduling algorithm the job which have the less burst time will get the CPU first .it is the best method to minimize the waiting time .it is of two type
2. non preemptive
Characteristics:-
- Sjf scheduling can be either preemptive or non-preemptive.
- IN SJF CPU is assigned to the process that has the smallest next CPU Burst time.
- If the next CPU Burst of two process is the same then FCFS scheduling is used to break the tie.
- This process give the minimum average waiting time for a given processes.
Code:-
In this code first we are creating the structure for the process in which we are declaring the id , waiting time , Arrival time , Burst time and turn around time .then after an array of the structure type.
logic:-
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).
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.
2. 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 minimum burst time of the process which are arrived at cmp_time (completion time of the previous process) .
You can easily understand by Following code .
Output:-
Wipro :-
- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID
Infytq :-
Key Points;-
Hackerrank:-
- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution
C-tutorial:-
- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array
See more:-
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation
0 Comments