Posts

Showing posts from December, 2023

First Come First Serve (FCFS) CPU Scheduling Algorithm in Operating Systems

Image
 First Come First Serve (FCFS) - CPU Scheduling Algorithm what is FCFS CPU Scheduling Algorithm ?                         First Come First Serve (FCFS) is a scheduling algorithm that automatically executes queued requests and processes in the order they arrive. Source Code #include <stdio.h> void main() { int i=0,pid[10],at[20],ct[20],bt[20],tat[20],wt[20],n=0,j=0; float avgw=0,avgtat = 0; printf("Enter the number of proccess : "); scanf("%d",&n); printf("Enter details of each process :\n");         for(i=0; i<n; i++) { printf("Enter the proccess id :"); scanf("%d",&pid[i]); printf("Enter arrival time : "); scanf("%d",&at[i]); printf("Enter Burst Time : "); scanf("%d",&bt[i]); printf("\n"); } //Sort the process based on arrival time using bubble sort int temp =0; for(i=0; i<n-1; i++) { for(j=0; j...

CPU Scheduling Algorithms

Image
CPU Scheduling Algorithms In Operating Systems What is CPU scheduling algorithm and why it should need in operating systems? Refers to switching between processes that are being executed. Basics of multi programmed operating systems This Switching ensures that CPU utilisation is maximised so that computer become so productive There are two main type of CPU scheduling 1. Preemptive CPU Scheduling 2. Non-Preemptive CPU Scheduling Type of CPU Scheduling 1. Preemptive CPU Scheduling Used when the process switches from the running state to the ready state or from waiting state to ready state In preemptive scheduling, the operating system can interrupt a currently running process and move it out of the CPU to allow another process to run. This interruption can occur based on priorities, time slices (quantum), or some other criteria.           Example:  Round Robin, Priority Scheduling 2. Non-Preemptive CPU Scheduling In non-preemptive scheduling, once a proc...