Fcfs
Fcfs
Algorithm
1.Enter all the processes and their burst time.
2. Find waiting time, WT of all the processes.
3. For the 1st process, WT = 0.
4. For all the next processes i, WT[i] = BT[i-1] + WT[i-1].
5. Calculate Turnaround time = WT + BT for all the processes.
6. Calculate average waiting time = total waiting time/no. of
processes.
7. Calculate average turnaround time = total turnaround time/no.
of processes.
Program
#include <stdio.h>
#include <stdbool.h>
#define MAX_FRAMES 3
// Maximum number of frames in memory
// Function to check if a page is already present in memory
bool isInMemory(int page, int *frames, int num_frames)
{
for (int i = 0; i < num_frames; ++i)
{
if (frames[i] == page)
{
return true;
}
}
return false;
}
displayFrames(frames, num_frames);
}
else
{
printf("Page %d is already in memory\n", pages[i]);
}
}
int main()
{
int pages[] = {1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5}; // Reference string
int num_pages = sizeof(pages) / sizeof(pages[0]);
int frames[MAX_FRAMES];
return 0;
}
Output: