ads

FCFS Disk Scheduling Algorithm

 

FCFS Disk Scheduling Algorithm



  • FCFS (First-Come-First-Serve) is a disk scheduling algorithm that schedules I/O requests in the order they arrive. 


    When an I/O request is received, it is added to the end of the request queue. The request at the front of the queue is then serviced by the disk, and once it is completed, the next request in the queue is serviced. This continues until all the requests in the queue have been serviced.


    FCFS scheduling is simple and easy to implement, but it may not be the most efficient algorithm. It can result in long wait times for requests that are further back in the queue, as they have to wait for all the requests in front of them to be serviced first.


    Additionally, FCFS scheduling may not take into account the physical location of the requested data on the disk. This can lead to inefficient disk usage, as the disk head may have to travel long distances to access the requested data.


    Overall, FCFS scheduling is suitable for systems with low to moderate levels of disk activity and a small number of I/O requests. However, for systems with high levels of disk activity and a large number of I/O requests, more efficient algorithms such as SCAN or C-SCAN may be more suitable.


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int RQ[100],i,n,TotalHeadMoment=0,initial;
    printf("Enter the number of Requests\n");
    scanf("%d",&n);
    printf("Enter the Requests sequence\n");
    for(i=0;i<n;i++)
     scanf("%d",&RQ[i]);
    printf("Enter initial head position\n");
    scanf("%d",&initial);
   
    // logic for FCFS disk scheduling
   
    for(i=0;i<n;i++)
    {
        TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
        initial=RQ[i];
    }
   
    printf("Total head moment is %d",TotalHeadMoment);
    return 0;
   
}




Output of the program


PS E:\C\os> 
Enter the number of Requests
4
Enter the Requests sequence
5
8
6
7
Enter initial head position
5
Total head moment is 6




Advantage:-

  1. easy to understand and implement
  2. No starvation occur

Disadvantage:-

  1. Throughput is not very efficient
  2. Waiting and response time is more
Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!