OS
OS
Code :
#include <stdio.h>
#define N 10
Int main()
Scanf(“%d”, &n);
Printf(“Enter the process id, arrival time, and burst time of all processes:\n”);
Scanf(“%d”, &process[i]);
Scanf(“%d”, &arrival[i]);
Scanf(“%d”, &burst[i]);
Arrival[j + 1] = temp;
Temp = burst[j];
Burst[j + 1] = temp;
Temp = process[j];
Process[j + 1] = temp;
Int currentTime = 0;
currentTime = arrival[i];
currentTime += burst[i];
total_wait += wait[i];
total_turnaround += turnaround[i];
Return 0;
Code :
#include <stdio.h>
#define N 10
Int main()
Scanf(“%d”, &n);
Scanf(“%d”, &process[i]);
Scanf(“%d”, &arrival[i]);
Scanf(“%d”, &burst[i]);
minBurst = burst[i];
index = I;
If (index != -1)
currentTime += burst[index];
completed[index] = 1;
totalCompleted++;
Else
currentTime++;
Twt += wait[i];
Tat += turnaround[i];
Return 0;
Code :
#include <stdio.h>
Struct Process
Int pid;
Int arrival_time;
Int burst_time;
Int remaining_time;
Int completion_time;
Int waiting_time;
Int turnaround_time;
};
Int finish_time;
Int is_completed[n];
Is_completed[i] = 0;
Processes[i].remaining_time = processes[i].burst_time;
While (completed != n)
Shortest = -1;
Min_remaining_time = processes[i].remaining_time;
Shortest = I;
If (shortest != -1)
Processes[shortest].remaining_time--;
Time++;
If (processes[shortest].remaining_time == 0)
Is_completed[shortest] = 1;
Completed++;
Finish_time = time;
Processes[shortest].completion_time = finish_time;
If (processes[shortest].waiting_time < 0)
Processes[shortest].waiting_time = 0;
Processes[shortest].turnaround_time = finish_time –
processes[shortest].arrival_time;
}
}
Else
Time++;
findWaitingAndTurnaroundTime(processes, n);
Total_waiting_time += processes[i].waiting_time;
Total_turnaround_time += processes[i].turnaround_time;
Int main()
Int n;
Printf(“Enter arrival time and burst time for process %d: “, I + 1);
Processes[i].pid = I + 1;
findAverageTime(processes, n);
return 0;
Code :
#include <stdio.h>
#define N 10
Typedef struct
Int pid;
Int arrival;
Int burst;
Int priority;
Int wait;
Int turnaround;
Int completed;
} Process;
Index = I;
}
If (index != -1)
currentTime = proc[index].arrival;
currentTime += proc[index].burst;
proc[index].completed = 1;
totalCompleted++;
Else
currentTime++;
totalWait += proc[i].wait;
totalTurnaround += proc[i].turnaround;
Int main()
Process process[N];
Int n;
Scanf(“%d”, &n);
Process[i].pid = I + 1;
Scanf(“%d”, &process[i].arrival);
Scanf(“%d”, &process[i].burst);
Process[i].completed = 0;
calculateTimes(process, n);
printResult(process, n);
return 0;
Code :
#include <stdio.h>
#include <limits.h>
Typedef struct
Int id;
Int burst_time;
Int remaining_time;
Int priority;
Int arrival_time;
Int completion_time;
Int waiting_time;
Int turnaround_time;
} Process;
Int min_priority_index;
Int min_priority;
While (completed != n)
Min_priority_index = -1;
Min_priority = INT_MAX;
Min_priority = processes[i].priority;
Min_priority_index = I;
If (min_priority_index != -1)
{
Processes[min_priority_index].remaining_time--;
Time++;
If (processes[min_priority_index].remaining_time == 0)
Completed++;
Processes[min_priority_index].completion_time = time;
Processes[min_priority_index].turnaround_time =
processes[min_priority_index].completion_time –
processes[min_priority_index].arrival_time;
Processes[min_priority_index].waiting_time =
processes[min_priority_index].turnaround_time –
processes[min_priority_index].burst_time;
Else
Time++;
Total_waiting_time += processes[i].waiting_time;
Total_turnaround_time += processes[i].turnaround_time;
Printf(“%d\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\n”,
Processes[i].id,
Processes[i].burst_time,
Processes[i].priority,
Processes[i].arrival_time,
Processes[i].completion_time,
Processes[i].turnaround_time,
Processes[i].waiting_time
);
Int main()
Process processes[MAX_PROCESSES];
Int n;
Scanf(“%d”, &n);
{
Processes[i].id = I + 1;
Scanf(“%d”, &processes[i].burst_time);
Processes[i].remaining_time = processes[i].burst_time;
Scanf(“%d”, &processes[i].priority);
Scanf(“%d”, &processes[i].arrival_time);
Priority_preemptive_scheduling(processes, n);
Print_results(processes, n);
Return 0;
Code :
#include <stdio.h>
Typedef struct
Int id;
Int burst_time;
Int remaining_time;
Int arrival_time;
Int completion_time;
Int waiting_time;
Int turnaround_time;
} Process;
Processes[i].remaining_time = processes[i].burst_time;
Queue[rear++] = I;
If (processes[index].remaining_time > 0)
{
If (processes[index].remaining_time > time_quantum)
Time += time_quantum;
Processes[index].remaining_time -= time_quantum;
Else
Time += processes[index].remaining_time;
Processes[index].remaining_time = 0;
Processes[index].completion_time = time;
Processes[index].turnaround_time = processes[index].completion_time –
processes[index].arrival_time;
Processes[index].waiting_time = processes[index].turnaround_time –
processes[index].burst_time;
Completed++;
Queue[rear++ % n] = index;
Printf(“%d\t%d\t\t%d\t\t%d\t\t%d\t\t%d\n”,
Processes[i].id,
Processes[i].burst_time,
Processes[i].arrival_time,
Processes[i].completion_time,
Processes[i].turnaround_time,
Processes[i].waiting_time);
Int main()
Process processes[MAX_PROCESSES];
Int n, time_quantum;
Scanf(“%d”, &n);
Processes[i].id = I + 1;
Scanf(“%d”, &processes[i].burst_time);
Scanf(“%d”, &processes[i].arrival_time);
Scanf(“%d”, &time_quantum);
Round_robin_scheduling(processes, n, time_quantum);
Print_results(processes, n);
Return 0;