0% found this document useful (0 votes)
2 views3 pages

Document (3) (3)

The document is a C program that implements various CPU scheduling algorithms including First-Come-First-Serve (FCFS), Shortest Job First (SJF), Round Robin, and Priority Scheduling. It allows the user to input the number of processes, their burst times, arrival times, and priorities, and then choose which scheduling algorithm to execute. The program continues to prompt the user for choices until they decide to exit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Document (3) (3)

The document is a C program that implements various CPU scheduling algorithms including First-Come-First-Serve (FCFS), Shortest Job First (SJF), Round Robin, and Priority Scheduling. It allows the user to input the number of processes, their burst times, arrival times, and priorities, and then choose which scheduling algorithm to execute. The program continues to prompt the user for choices until they decide to exit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <stdio.

h>

#include <stdbool.h>

#define MAX_PROCESS 10

// Process structure

struct Process {

int id;

int burst_time;

int arrival_time;

};

// Global variables

int quantum;

int num_processes;

struct Process processes[MAX_PROCESS];

// Function prototypes for scheduling algorithms

void fcfs();

void sjf();

void round_robin();

void priority_scheduling(int priorities[]);

int main() {

int priorities[MAX_PROCESS];

int choice;
printf("Enter the number of processes (max 10): ");

scanf("%d", &num_processes);

for (int i = 0; i < num_processes; i++) {

processes[i].id = i + 1;

printf("Enter burst time for process %d: ", i + 1);

scanf("%d", &processes[i].burst_time);

printf("Enter arrival time for process %d: ", i + 1);

scanf("%d", &processes[i].arrival_time);

printf("Enter priority for process %d: ", i + 1);

scanf("%d", &priorities[i]);

printf("Enter time quantum for Round Robin: ");

scanf("%d", &quantum);

do {

printf("\nMain Menu\n");

printf("1. First-Come-First-Serve (FCFS) Scheduling\n");

printf("2. Shortest Job First (SJF) Scheduling\n");

printf("3. Round Robin Scheduling\n");

printf("4. Priority Scheduling\n");

printf("5. Exit\n");

printf("Enter your choice: ");


scanf("%d", &choice);

switch (choice) {

case 1:

fcfs();

break;

case 2:

sjf();

break;

case 3:

round_robin();

break;

case 4:

priority_scheduling(priorities);

break;

default:

if (choice != 5)

printf("Invalid choice. Please try again.\n");

} while (choice != 5);

return 0;

You might also like