Shortest Job First (SJF) in Operating System
Shortest Job First (SJF) is a scheduling algorithm in which the process having the smallest execution time it will be execute first and the next process will execute after previous smaller process. This scheduling method can be preemptive or non-preemptive. This method reduces the average waiting time for other processes awaiting execution.
Program in C / C++
#include<iostream>
#include<conio.h>
int main(){
int arr[5],sort[5],num,temp;
system("COLOR F9");
printf(" ENTER a Integer NUMBER ");
scanf("%i",&num);
for(int i=0;i<num;i++){
printf(" Your Job Number ");
scanf("%i",&arr[i]);
sort[i]=arr[i];
}
for(int i=0;i<num;i++){
for(int j=i+1;j<num;j++){
if(sort[j]<sort[i]){
temp=sort[i];
sort[i]=sort[j];
sort[j]=temp;
}
}
}
for(int i=0;i<num;i++){
printf(" Inputs %i Priority %i Job %i \n",arr[i],i+1,sort[i]);
}
getch();
}
Shortest Job First (SJF) |
No comments:
Post a Comment
Thanks For Visiting Here...!! I will Reply you as soon as possible.