OS Experiment - 3
OS Experiment - 3
OS Experiment - 3
OS Experiment - 2
OS Experiment - 4
OS Experiment - 5
OS Experiment - 7
#include <stdio.h>
int main() {
// Initialize variables
int n, m, i, j;
scanf("%d", &n);
scanf("%d", &m);
scanf("%d", &alloc[i][j]);
scanf("%d", &max[i][j]);
}
// Input the available matrix
scanf("%d", &avail[i]);
finish[i] = 0;
safeSeq[i] = -1;
work[i] = avail[i];
int count = 0;
int found = 0;
for (i = 0; i < n; i++) {
if (finish[i] == 0) {
int flag = 1;
flag = 0;
break;
if (flag) {
found = 1;
break;
if (!found) {
return 0;
finish[i] = 1;
safeSeq[count] = i;
count++;
printf("\n");
return 0;
}
OS Experiment - 8
int main() {
int part_size[20], process[20], flag[20];
int n, p, i, j, temp;
printf("\nProcess\tPartition\tPartition Size\n");
for (i = 0; i < p; i++) {
for (j = 0; j < n; j++) {
if (part_size[j] >= process[i] &z& flag[j] == 0) {
flag[j] = 1;
printf("P%d\t%d\t\t%d\n", i, j, part_size[j]);
break;
FOR WORST FIT
#include <stdio.h>
int main() {
int part[20], process[20], flag[20];
int n, p, i, j, temp;
printf("Enter number of partitions: ");
scanf("%d", &n);
FIFO:
LIFO:
LRU:
OPTIMAL:
OS Experiment - 10
FCFS:
SSTF:
SCAN:
C-SCAN:
LOOK:
C-LOOK:
OS Experiment - 6