Posts

Showing posts with the label c programming language

Preemptive Shortest Job First (SJF) - scheduling algorithm in C

Exploring Preemptive SJF Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Preemptive Shortest Job First (SJF) - scheduling algorithm in C Check out my YouTube video explaining this code: Watch now #include <stdio.h> #include <stdlib.h> typedef struct process { int id, at, bt, ct , wt, tat, rt; } process; void display(process pro[], int n) { printf("P AT BT CT TAT WT \n"); for (int i = 0; i 0) { int min = -1; for(i = 0; i 0) { if(min == -1 || proc[i].rt

FCFS scheduling algorithm in C (Operating Systems)

FCFS scheduling algorithm in C.  Its working code with output If you want explanation, you can view my YouTube video.  Youtube Link #include <stdio.h> #include <stdlib.h> typedef struct process { int id, at, bt, wt, tat, ct; } process; void sort(process pro[], int n) { process temp; for (int i = 0; i pro[j + 1].at) { temp = pro[j]; pro[j] = pro[j+1]; pro[j+1] = temp; } } void display(process pro[], int n) { printf("\n"); for (int i = 0; i