"Z Code Writer" is an Online Blog for Programmer & Beginner. Here, You will Find tech, Build your Programming Skills and other Programming Language Like C, C++, HTML, Java Script Java Code, Web Designing and University Of Sialkot (USKT) CGPA / GPA Calculator etc.

Friday 10 July 2020

First Come First Serve (FCFS) in Operating System

First Come First Serve (FCFS) in Operating System
             
        First Come First Served (FCFS) is a process scheduling algorithm in operating system (OS) that automatically execute processes and queued data by their sequence. In this Algorithm which process comes first to the queue is execute first, the next process will execute when the previous process complete their execution. FCFS is also known as (FIFO) First in First Out and First Come First Choice (FCFC).

Program in C / C++

#include<stdio.h>
int nxt=0,arry[5],c=0,d;
void menu();
void Insert();
void Delete();
void Display();
int main(){
int ch=1;
menu();
while(ch!=0){
printf(" Enter Your Choice ");
scanf("%i",&ch);
switch(ch){
case 0:
printf(" Exit ........ \n");
break;
case 1:
Insert();
break;
case 2:
Delete();
break;
case 3:
Display();
break;
default: 
printf(" Invalid Choice \n");
}
}
}

void menu(){
printf("--------- Menu --------\n");
printf(" Press 1 for Insert\n");
printf(" Press 2 for Delete\n");
printf(" Press 3 for Display\n");
printf(" Press 0 for Exit\n\n");
}

void Insert(){
if(c<5){
c++;
printf(" Enter data ");
scanf("%i",&d);
arry[nxt]=d;
nxt++;
}
else{
printf(" Que is Full \n");
}
}

void Delete(){
if(c>0){
c--;
for(int i=0;i<nxt;i++){
arry[i]=arry[i+1];
}
nxt--;
printf("\n Deletion Have Done  \n\n");
}
else{
printf(" Empty ...! \n");
}
}

void Display(){
if(c>0){
for(int i=0;i<nxt;i++){
printf(" Priority %d",i+1);
printf(" Job %d \n",arry[i]);
}
}
else{
printf(" Empty ...! \n");
}
}

First-Come-First-Serve-(FCFS)
First Come First Serve (FCFS)


No comments:

Post a Comment

Thanks For Visiting Here...!! I will Reply you as soon as possible.