Posts

Showing posts from June, 2025

8. To write a program in C to calculate waiting time, turn around time and average waiting time when non preemptive SJF is used

 #include <stdio.h> #include <conio.h> void main() {     clrscr();     int bt[20], p[20], wt[20], tat[20], i, j, n;     int total = 0, pos, temp;     float awt, atat;          printf("enter the no. of processes: ");     scanf("%d", &n);          for (i = 0; i < n; i++) {         printf("enter the burst time for process: ");         scanf("%d", &bt[i]);         p[i] = i + 1;     }          // SJF sorting     for (i = 0; i < n; i++) {         pos = i;         for (j = i + 1; j < n; j++) {             if (bt[j] < bt[pos])                 pos = j;         }         temp = bt[i];        ...

7. C Program: Preemptive SJF Scheduling (WT, TAT, AWT)

 #include <stdio.h> int main() {     int arrival_time[10], burst_time[10], temp[10];     int i, smallest, count = 0, time, limit;     double wait_time = 0, turn_around_time = 0, end;     float average_waiting_time, average_turn_around_time;     printf("\nEnter total number of processes: ");     scanf("%d", &limit);          printf("\nEnter details of %d processes\n", limit);     for(i = 0; i < limit; i++) {         printf("\nEnter Arrival Time: ");         scanf("%d", &arrival_time[i]);         printf("Enter Burst Time: ");         scanf("%d", &burst_time[i]);         temp[i] = burst_time[i];     }     burst_time[9] = 9999;     for(time = 0; count != limit; time++) {         smallest = 9;         for(...

6. Write a program to calculates Waiting Time (WT), Turnaround Time (TAT), Average WT, and Average TAT using the FCFS (First Come First Serve) scheduling algorithm.

 #include <stdio.h> int main() {     float burst_time[30], waiting_time[30], turn_around_time[30];     float average_waiting_time = 0.0, average_turnaround_time = 0.0;     int count, j, total_process;     printf("Enter the number of processes to execute: ");     scanf("%d", &total_process);     printf("Enter the burst time of each process:\n");     for (count = 0; count < total_process; count++) {         printf("Process [%d]: ", count + 1);         scanf("%f", &burst_time[count]);     }     waiting_time[0] = 0; // First process has 0 waiting time     // Calculate waiting time for each process     for (count = 1; count < total_process; count++) {         waiting_time[count] = 0;         for (j = 0; j < count; j++) {             waiting_time[co...