Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Presentation

cpu scheduling algorithms or technique

Rating
-
Sold
-
Pages
10
Uploaded on
22-05-2025
Written in
2024/2025

CPU scheduling in an operating system is the process of deciding which process to run on the CPU and for how long. It's a crucial part of operating system management, ensuring efficient and fair utilization of the CPU, especially when multiple processes need to be executed

Show more Read less
Institution
Course

Content preview

FCFS CPU scheduling algorithm in C

#include <stdio.h>



int main() {

int n, i;

int bt[20], wt[20], tat[20];

int total_wt = 0, total_tat = 0;



printf("Enter the number of processes: ");

scanf("%d", &n);



for (i = 0; i < n; i++) {

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

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

}



wt[0] = 0;

for (i = 1; i < n; i++) {

wt[i] = bt[i - 1] + wt[i - 1];

}



printf("\nProcess\tBurst Time\tWaiting Time\tTurnaround Time\n");

for (i = 0; i < n; i++) {

tat[i] = bt[i] + wt[i];

total_wt += wt[i];

total_tat += tat[i];

printf("P%d\t%d\t\t%d\t\t%d\n", i + 1, bt[i], wt[i], tat[i]);

}

, printf("\nAverage Waiting Time: %.2f", (float)total_wt / n);

printf("\nAverage Turnaround Time: %.2f\n", (float)total_tat / n);



return 0;

}

Enter the number of processes: 3

Enter burst time for Process 1: 5

Enter burst time for Process 2: 3

Enter burst time for Process 3: 8



Process Burst Time Waiting Time Turnaround Time

P1 5 0 5

P2 3 5 8

P3 8 8 16



Average Waiting Time: 4.33

Average Turnaround Time: 9.67



Priority Scheduling in C

#include <stdio.h>



int main() {

int n, i, j;

int bt[20], p[20], pt[20], wt[20], tat[20];

int total_wt = 0, total_tat = 0;



printf("Enter the number of processes: ");

scanf("%d", &n);

Written for

Institution
Course

Document information

Uploaded on
May 22, 2025
Number of pages
10
Written in
2024/2025
Type
PRESENTATION
Person
Unknown

Subjects

$7.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
jayashree2

Get to know the seller

Seller avatar
jayashree2 sri sairam institute of technology.
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions