Posts

Showing posts with the label c

Exploring Preemptive Priority Algorithm in C

Exploring Preemptive Priority Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Preemptive Priority - 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 , p; } process; void sortID(process pro[], int n) { process temp; for (int i = 0; i pro[j + 1].id) { temp = pro[j]; pro[j] = pro[j + 1]; pro[j + 1] = temp; } } void sortP(process pro[], int n) { process temp; for (int i = 0; i pro[j + 1].p) { temp = pro[j]; pro[j] = pro[j + 1]; pro[j + 1] = temp; } } void display(process pro[], int n) { printf("\n\nTABLE:\n"); for (int...

Non Preemptive SJF scheduling algorithm in C

Non Preemptive SJF scheduling algorithm in C.  This is a working code with output. If you want the explanation for this code, you can view: this video YouTube Link #include <stdio.h> typedef struct process { int id , at , bt ,rt, ct , tat , wt; } process; void display(process proc[] , int n) { int i; printf("\n\nP AT BT CT TAT WT\n"); for(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