0% found this document useful (0 votes)
9 views

OS LAB MANUAL

The document contains three C programs demonstrating different concepts: the first program implements process system calls using fork, exec, and wait; the second program simulates CPU scheduling algorithms (FCFS, SJF, Round Robin, and Priority) to calculate turnaround and waiting times; and the third program simulates the producer-consumer problem using semaphores for synchronization between producer and consumer threads.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

OS LAB MANUAL

The document contains three C programs demonstrating different concepts: the first program implements process system calls using fork, exec, and wait; the second program simulates CPU scheduling algorithms (FCFS, SJF, Round Robin, and Priority) to calculate turnaround and waiting times; and the third program simulates the producer-consumer problem using semaphores for synchronization between producer and consumer threads.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Program 1:

Develop a c program to implement the Process system calls (fork (), exec(), wait(), create
process,terminate process)

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

int main() {
pid_t child_pid;
int status;

// Create a child process using fork()


child_pid = fork();

if (child_pid == -1) {
perror("Fork failed");
exit(EXIT_FAILURE);
}

if (child_pid == 0) {
// This code will be executed by the child process
printf("Child process: PID = %d\n", getpid());

// Execute a new program using exec()


char *args[] = {"/bin/ls", "-l", NULL};
if (execvp("/bin/ls", args) == -1) {
perror("Exec failed");
exit(EXIT_FAILURE);
}
} else {
// This code will be executed by the parent process

// Wait for the child process to finish using wait()


wait(&status);

if (WIFEXITED(status)) {
printf("Parent process: Child process terminated with exit status %d\n",
WEXITSTATUS(status));
} else {
printf("Parent process: Child process did not terminate normally\n");
}

printf("Parent process: PID = %d\n", getpid());


}

return 0;
}
OUTPUT:

Child process: PID = 4946


total 1160
drwxrwxr-x 28 student student 4096 Apr 25 2023 anaconda3
drwxrwxr-x 3 student student 4096 Apr 25 2023 Android
drwxrwxr-x 3 student student 4096 Apr 25 2023 AndroidStudioProjects
-rwxrwxr-x 1 student student 17048 Nov 9 16:10 a.out
drwxr-xr-x 3 student student 4096 Nov 9 16:10 Desktop
drwxr-xr-x 2 student student 4096 Nov 9 15:37 Documents
drwxr-xr-x 3 student student 4096 Nov 3 12:18 Downloads
drwxr-xr-x 2 student student 4096 Apr 6 2023 Music
-rwxrwxr-x 1 student student 17360 Nov 3 15:22 my_program
-rw-r--r-- 1 student student 816096 Sep 24 2018 nam_1.14_amd64.deb
drwxr-xr-x 3 student student 4096 Apr 17 2023 ns2-install
drwxr-xr-x 15 student student 4096 Apr 17 2023 ns-allinone-2.35
drwxrwxr-x 2 student student 4096 Apr 17 2023 nsg
-rw-r--r-- 1 student student 258968 Sep 25 2018 nsg2.1.jar
drwxr-xr-x 2 student student 4096 Nov 3 15:31 Pictures
-rw-rw-r-- 1 student student 1140 Nov 9 16:06 prg1.c
drwxr-xr-x 2 student student 4096 Apr 6 2023 Public
drwx------ 4 student student 4096 Apr 24 2023 snap
drwxr-xr-x 2 student student 4096 Apr 6 2023 Templates
drwxr-xr-x 2 student student 4096 Apr 6 2023 Videos
Parent process: Child process terminated with exit status 0
Parent process: PID = 4945
Program 2:

Simulate the following CPU scheduling algorithms to find turnaround time and waiting time
a) FCFS b) SJF c) Round Robin d) Priority.

#include <stdio.h>
#include <stdlib.h>

struct Process {
int processId;
int burstTime;
int priority;
int waitingTime;
int turnaroundTime;
};

void calculateTurnaroundTime(struct Process processes[], int n) {


processes[0].turnaroundTime = processes[0].burstTime;
processes[0].waitingTime = 0;

for (int i = 1; i < n; i++) {


processes[i].waitingTime = processes[i - 1].waitingTime + processes[i - 1].burstTime;
processes[i].turnaroundTime = processes[i].waitingTime + processes[i].burstTime;
}
}

void calculateWaitingTime(struct Process processes[], int n) {


processes[0].waitingTime = 0;

for (int i = 1; i < n; i++) {


processes[i].waitingTime = processes[i - 1].waitingTime + processes[i - 1].burstTime;
}
}

void fcfs(struct Process processes[], int n) {


calculateTurnaroundTime(processes, n);
calculateWaitingTime(processes, n);

printf("FCFS Scheduling\n");
printf("Process\tBurst Time\tWaiting Time\tTurnaround Time\n");
for (int i = 0; i < n; i++) {
printf("%d\t%d\t\t%d\t\t%d\n", processes[i].processId, processes[i].burstTime,
processes[i].waitingTime, processes[i].turnaroundTime);
}
}

void sjf(struct Process processes[], int n) {


// Sort processes based on burst time using bubble sort
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (processes[j].burstTime > processes[j + 1].burstTime) {
struct Process temp = processes[j];
processes[j] = processes[j + 1];
processes[j + 1] = temp;
}
}
}

calculateTurnaroundTime(processes, n);
calculateWaitingTime(processes, n);

printf("SJF Scheduling\n");
printf("Process\tBurst Time\tWaiting Time\tTurnaround Time\n");
for (int i = 0; i < n; i++) {
printf("%d\t%d\t\t%d\t\t%d\n", processes[i].processId, processes[i].burstTime,
processes[i].waitingTime, processes[i].turnaroundTime);
}
}

void roundRobin(struct Process processes[], int n, int timeQuantum) {


int remainingBurstTime[n];
for (int i = 0; i < n; i++) {
remainingBurstTime[i] = processes[i].burstTime;
}

int currentTime = 0;
int completed = 0;

printf("Round Robin Scheduling (Time Quantum: %d)\n", timeQuantum);


printf("Process\tBurst Time\tWaiting Time\tTurnaround Time\n");

while (completed < n) {


for (int i = 0; i < n; i++) {
if (remainingBurstTime[i] > 0) {
if (remainingBurstTime[i] <= timeQuantum) {
currentTime += remainingBurstTime[i];
processes[i].waitingTime += currentTime - processes[i].waitingTime;
processes[i].turnaroundTime = processes[i].waitingTime + processes[i].burstTime;
remainingBurstTime[i] = 0;
completed++;
} else {
currentTime += timeQuantum;
remainingBurstTime[i] -= timeQuantum;
processes[i].waitingTime += currentTime - processes[i].waitingTime;
}
}
}
}

for (int i = 0; i < n; i++) {


printf("%d\t%d\t\t%d\t\t%d\n", processes[i].processId, processes[i].burstTime,
processes[i].waitingTime, processes[i].turnaroundTime);
}
}
void priority(struct Process processes[], int n) {
// Sort processes based on priority using bubble sort
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (processes[j].priority > processes[j + 1].priority) {
struct Process temp = processes[j];
processes[j] = processes[j + 1];
processes[j + 1] = temp;
}
}
}

calculateTurnaroundTime(processes, n);
calculateWaitingTime(processes, n);

printf("Priority Scheduling\n");
printf("Process\tBurst Time\tWaiting Time\tTurnaround Time\n");
for (int i = 0; i < n; i++) {
printf("%d\t%d\t\t%d\t\t%d\n", processes[i].processId, processes[i].burstTime,
processes[i].waitingTime, processes[i].turnaroundTime);
}
}

int main() {
int n, timeQuantum, choice;

do {
printf("\nMenu:\n");
printf("1. FCFS Scheduling\n");
printf("2. SJF Scheduling\n");
printf("3. Round Robin Scheduling\n");
printf("4. Priority Scheduling\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

if (choice == 5) {
break;
}

printf("Enter the number of processes: ");


scanf("%d", &n);

struct Process processes[n];

for (int i = 0; i < n; i++) {


processes[i].processId = i + 1;
printf("Enter burst time for process %d: ", i + 1);
scanf("%d", &processes[i].burstTime);
printf("Enter priority for process %d: ", i + 1);
scanf("%d", &processes[i].priority);
}
switch (choice) {
case 1:
fcfs(processes, n);
break;
case 2:
sjf(processes, n);
break;
case 3:
printf("Enter the time quantum for Round Robin: ");
scanf("%d", &timeQuantum);
roundRobin(processes, n, timeQuantum);
break;
case 4:
priority(processes, n);
break;
default:
printf("Invalid choice. Please try again.\n");
}

} while (choice != 5);

return 0;
}

OUTPUT:
Menu:
1. FCFS Scheduling
2. SJF Scheduling
3. Round Robin Scheduling
4. Priority Scheduling
5. Exit
Enter your choice: 1
Enter the number of processes: 3
Enter burst time for process 1: 5
Enter priority for process 1: 3
Enter burst time for process 2: 4
Enter priority for process 2: 2
Enter burst time for process 3: 5
Enter priority for process 3: 3
FCFS Scheduling
Process Burst Time Waiting Time Turnaround Time
1 5 0 5
2 4 5 9
3 5 9 14

Menu:
1. FCFS Scheduling
2. SJF Scheduling
3. Round Robin Scheduling
4. Priority Scheduling
5. Exit
Enter your choice: 2
Enter the number of processes: 3
Enter burst time for process 1: 5
Enter priority for process 1: 3
Enter burst time for process 2: 4
Enter priority for process 2: 2
Enter burst time for process 3: 5
Enter priority for process 3: 3
SJF Scheduling
Process Burst Time Waiting Time Turnaround Time
2 4 0 4
1 5 4 9
3 5 9 14

Menu:
1. FCFS Scheduling
2. SJF Scheduling
3. Round Robin Scheduling
4. Priority Scheduling
5. Exit
Enter your choice: 3
Enter the number of processes: 3
Enter burst time for process 1: 5
Enter priority for process 1: 3
Enter burst time for process 2: 4
Enter priority for process 2: 2
Enter burst time for process 3: 5
Enter priority for process 3: 3
Enter the time quantum for Round Robin: 1
Round Robin Scheduling (Time Quantum: 1)
Process Burst Time Waiting Time Turnaround Time
1 5 13 18
2 4 11 15
3 5 14 19

Menu:
1. FCFS Scheduling
2. SJF Scheduling
3. Round Robin Scheduling
4. Priority Scheduling
5. Exit
Enter your choice: 4
Enter the number of processes: 3
Enter burst time for process 1: 5
Enter priority for process 1: 3
Enter burst time for process 2: 4
Enter priority for process 2: 2
Enter burst time for process 3: 5
Enter priority for process 3: 3
Priority Scheduling
Process Burst Time Waiting Time Turnaround Time
2 4 0 4
1 5 4 9
3 5 9 14

Menu:
1. FCFS Scheduling
2. SJF Scheduling
3. Round Robin Scheduling
4. Priority Scheduling
5. Exit
Enter your choice: 5
Program 3:

Develop a C program to simulate producer-consumer problem using semaphores.

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>

#define BUFFER_SIZE 5
#define NUM_PRODUCERS 3
#define NUM_CONSUMERS 2
#define MAX_ITERATIONS 10

int buffer[BUFFER_SIZE];
int in = 0, out = 0;
int producerCount = 0, consumerCount = 0;

sem_t mutex, full, empty;

void *producer(void *arg) {


int item;
int producerId = *((int *)arg);

while (producerCount < MAX_ITERATIONS) {


item = rand() % 100;
sem_wait(&empty);
sem_wait(&mutex);
buffer[in] = item;
printf("Producer %d produced: %d\n", producerId, item);
in = (in + 1) % BUFFER_SIZE;
sem_post(&mutex);
sem_post(&full);
producerCount++;
sleep(rand() % 3);
}

pthread_exit(NULL);
}

void *consumer(void *arg) {


int item;
int consumerId = *((int *)arg);

while (consumerCount < MAX_ITERATIONS) {


sem_wait(&full);
sem_wait(&mutex);
item = buffer[out];
printf("Consumer %d consumed: %d\n", consumerId, item);
out = (out + 1) % BUFFER_SIZE;
sem_post(&mutex);
sem_post(&empty);
consumerCount++;
sleep(rand() % 3);
}

pthread_exit(NULL);
}

int main() {
pthread_t producerThreads[NUM_PRODUCERS];
pthread_t consumerThreads[NUM_CONSUMERS];

// Initialize semaphores
sem_init(&mutex, 0, 1);
sem_init(&full, 0, 0);
sem_init(&empty, 0, BUFFER_SIZE);

int producerIds[NUM_PRODUCERS];
int consumerIds[NUM_CONSUMERS];

// Create producer threads


for (int i = 0; i < NUM_PRODUCERS; i++) {
producerIds[i] = i + 1;
pthread_create(&producerThreads[i], NULL, producer, (void *)&producerIds[i]);
}

// Create consumer threads


for (int i = 0; i < NUM_CONSUMERS; i++) {
consumerIds[i] = i + 1;
pthread_create(&consumerThreads[i], NULL, consumer, (void *)&consumerIds[i]);
}

// Join producer threads


for (int i = 0; i < NUM_PRODUCERS; i++) {
pthread_join(producerThreads[i], NULL);
}

// Join consumer threads


for (int i = 0; i < NUM_CONSUMERS; i++) {
pthread_join(consumerThreads[i], NULL);
}

// Destroy semaphores
sem_destroy(&mutex);
sem_destroy(&full);
sem_destroy(&empty);

return 0;
}
OUTPUT:

Producer 1 produced: 83
Consumer 2 consumed: 83
Producer 2 produced: 86
Consumer 1 consumed: 86
Producer 3 produced: 77
Producer 3 produced: 49
Producer 1 produced: 62
Producer 2 produced: 90
Consumer 1 consumed: 77
Producer 3 produced: 26
Producer 3 produced: 26
Consumer 2 consumed: 49
Producer 1 produced: 11
Consumer 2 consumed: 62
Producer 2 produced: 67
Consumer 1 consumed: 90
Producer 3 produced: 29
Consumer 2 consumed: 26
Consumer 1 consumed: 26
Consumer 2 consumed: 11
Consumer 1 consumed: 67
Program 4:

Develop a C program which demonstrates interprocess communication between a reader


process and a writer process. Use mkfifo, open, read, write and close APIs in your program.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>

#define FIFO_NAME "myfifo"

int main() {
int fd;
char message[] = "Hello, Reader!"; // Message to be sent by the writer process
char buffer[100];

// Create the FIFO (named pipe)


mkfifo(FIFO_NAME, 0666);

// Writer Process
if (fork() == 0) {
// Open the FIFO for writing
fd = open(FIFO_NAME, O_WRONLY);

// Write the message to the FIFO


write(fd, message, strlen(message) + 1);
printf("Writer: Sent message - %s\n", message);

// Close the FIFO


close(fd);

exit(0);
}
// Reader Process
else {
// Open the FIFO for reading
fd = open(FIFO_NAME, O_RDONLY);

// Read the message from the FIFO


read(fd, buffer, sizeof(buffer));
printf("Reader: Received message - %s\n", buffer);

// Close the FIFO


close(fd);

// Remove the FIFO


unlink(FIFO_NAME);
}
return 0;
}

OUTPUT:

Reader: Received message - Hello, Reader!


Writer: Sent message - Hello, Reader!
Program 5:

Develop a C program to simulate Bankers Algorithm for DeadLock Avoidance.

#include <stdio.h>
#include <stdbool.h>

#define MAX_PROCESS 10
#define MAX_RESOURCE 10

int available[MAX_RESOURCE];
int max[MAX_PROCESS][MAX_RESOURCE];
int allocation[MAX_PROCESS][MAX_RESOURCE];
int need[MAX_PROCESS][MAX_RESOURCE];
bool finish[MAX_PROCESS];

void input(int processes, int resources) {


printf("Enter available resources: ");
for (int i = 0; i < resources; i++) {
scanf("%d", &available[i]);
}

printf("Enter maximum resources for each process:\n");


for (int i = 0; i < processes; i++) {
printf("Process %d: ", i);
for (int j = 0; j < resources; j++) {
scanf("%d", &max[i][j]);
}
}

printf("Enter allocated resources for each process:\n");


for (int i = 0; i < processes; i++) {
printf("Process %d: ", i);
for (int j = 0; j < resources; j++) {
scanf("%d", &allocation[i][j]);
need[i][j] = max[i][j] - allocation[i][j];
}
finish[i] = false;
}
}

bool isSafe(int processes, int resources) {


int work[MAX_RESOURCE];
for (int i = 0; i < resources; i++) {
work[i] = available[i];
}

bool finishAll = false;


while (!finishAll) {
finishAll = true;
for (int i = 0; i < processes; i++) {
if (finish[i] == false) {
bool canAllocate = true;
for (int j = 0; j < resources; j++) {
if (need[i][j] > work[j]) {
canAllocate = false;
break;
}
}
if (canAllocate) {
finish[i] = true;
for (int j = 0; j < resources; j++) {
work[j] += allocation[i][j];
}
finishAll = false;
}
}
}
}

for (int i = 0; i < processes; i++) {


if (finish[i] == false) {
return false; // System is in an unsafe state
}
}
return true; // System is in a safe state
}

int main() {
int processes, resources;

printf("Enter number of processes: ");


scanf("%d", &processes);

printf("Enter number of resources: ");


scanf("%d", &resources);

input(processes, resources);

if (isSafe(processes, resources)) {
printf("System is in safe state.\n");
} else {
printf("System is in unsafe state.\n");
}

return 0;
}

OUTPUT:

Enter number of processes: 5


Enter number of resources: 3
Enter available resources: 3
3
2
Enter maximum resources for each process:
Process 0: 7
5
3
Process 1: 3
2
2
Process 2: 9
0
2
Process 3: 2
2
2
Process 4: 4
3
3
Enter allocated resources for each process:
Process 0: 0
1
0
Process 1: 2
0
0
Process 2: 3
0
2
Process 3: 2
1
1
Process 4: 0
0
2
System is in safe state.

Enter number of processes: 5


Enter number of resources: 3
Enter available resources: 1
0
0
Enter maximum resources for each process:
Process 0: 1
2
2
Process 1: 6
1
3
Process 2: 1
4
2
Process 3: 0
5
1
Process 4: 2
3
2
Enter allocated resources for each process:
Process 0: 1
0
0
Process 1: 5
1
1
Process 2: 0
2
0
Process 3: 0
0
1
Process 4: 1
1
0
System is in unsafe state.
Program 6:

Develop a C program to simulate the following contiguous memory allocation Techniques:


a) Worst fit b) Best fit c) First fit.

#include <stdio.h>
#include <stdlib.h>

typedef struct {
int id;
int size;
int allocated;
} Block;

void worstFit(Block blocks[], int numBlocks, int requestSize) {


int i, worstFitIdx = -1;
for (i = 0; i < numBlocks; i++) {
if (blocks[i].allocated == 0 && blocks[i].size >= requestSize) {
if (worstFitIdx == -1 || blocks[i].size > blocks[worstFitIdx].size) {
worstFitIdx = i;
}
}
}

if (worstFitIdx != -1) {
blocks[worstFitIdx].allocated = 1;
printf("Memory allocated using Worst Fit at Block %d\n", worstFitIdx);
} else {
printf("No suitable block found for Worst Fit allocation\n");
}
}

void bestFit(Block blocks[], int numBlocks, int requestSize) {


int i, bestFitIdx = -1;
for (i = 0; i < numBlocks; i++) {
if (blocks[i].allocated == 0 && blocks[i].size >= requestSize) {
if (bestFitIdx == -1 || blocks[i].size < blocks[bestFitIdx].size) {
bestFitIdx = i;
}
}
}

if (bestFitIdx != -1) {
blocks[bestFitIdx].allocated = 1;
printf("Memory allocated using Best Fit at Block %d\n", bestFitIdx);
} else {
printf("No suitable block found for Best Fit allocation\n");
}
}

void firstFit(Block blocks[], int numBlocks, int requestSize) {


int i;
for (i = 0; i < numBlocks; i++) {
if (blocks[i].allocated == 0 && blocks[i].size >= requestSize) {
blocks[i].allocated = 1;
printf("Memory allocated using First Fit at Block %d\n", i);
return;
}
}
printf("No suitable block found for First Fit allocation\n");
}

int main() {
int numBlocks, i, choice, requestSize;
printf("Enter the number of memory blocks: ");
scanf("%d", &numBlocks);

Block blocks[numBlocks];

for (i = 0; i < numBlocks; i++) {


blocks[i].id = i;
blocks[i].allocated = 0;
printf("Enter the size of Block %d: ", i);
scanf("%d", &blocks[i].size);
}

while (1) {
printf("\nMenu:\n");
printf("1. Worst Fit Allocation\n");
printf("2. Best Fit Allocation\n");
printf("3. First Fit Allocation\n");
printf("4. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
printf("Enter the size of the memory request: ");
scanf("%d", &requestSize);
worstFit(blocks, numBlocks, requestSize);
break;
case 2:
printf("Enter the size of the memory request: ");
scanf("%d", &requestSize);
bestFit(blocks, numBlocks, requestSize);
break;
case 3:
printf("Enter the size of the memory request: ");
scanf("%d", &requestSize);
firstFit(blocks, numBlocks, requestSize);
break;
case 4:
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
}

return 0;
}

OUTPUT:
Enter the number of memory blocks: 3
Enter the size of Block 0: 100
Enter the size of Block 1: 200
Enter the size of Block 2: 150

Menu:
1. Worst Fit Allocation
2. Best Fit Allocation
3. First Fit Allocation
4. Exit
Enter your choice: 1
Enter the size of the memory request: 120
Memory allocated using Worst Fit at Block 1

Menu:
1. Worst Fit Allocation
2. Best Fit Allocation
3. First Fit Allocation
4. Exit
Enter your choice: 2
Enter the size of the memory request: 110
Memory allocated using Best Fit at Block 2

Menu:
1. Worst Fit Allocation
2. Best Fit Allocation
3. First Fit Allocation
4. Exit
Enter your choice: 3
Enter the size of the memory request: 130
No suitable block found for First Fit allocation

Menu:
1. Worst Fit Allocation
2. Best Fit Allocation
3. First Fit Allocation
4. Exit
Enter your choice: 4
Program 7:

Develop a C program to simulate page replacement algorithms:


a) FIFO b) LRU

#include <stdio.h>
#include <stdlib.h>

#define MAX_FRAMES 3 // Number of frames

int fifo(int pages[], int n, int capacity);


int lru(int pages[], int n, int capacity);

int main() {
int choice, n;
int pages[100]; // Assume a maximum of 100 pages for simplicity
int capacity = MAX_FRAMES;

printf("Enter the number of pages: ");


scanf("%d", &n);

printf("Enter the sequence of pages (separated by space): ");


for (int i = 0; i < n; i++) {
scanf("%d", &pages[i]);
}

while (1) {
printf("\nPage Replacement Algorithms Menu:\n");
printf("1. FIFO (First-In-First-Out)\n");
printf("2. LRU (Least Recently Used)\n");
printf("3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
printf("Page Faults using FIFO: %d\n", fifo(pages, n, capacity));
break;
case 2:
printf("Page Faults using LRU: %d\n", lru(pages, n, capacity));
break;
case 3:
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
}

return 0;
}

int fifo(int pages[], int n, int capacity) {


int frame[capacity];
int pageFaults = 0;
int rear = -1;

for (int i = 0; i < n; i++) {


int pageFound = 0;
for (int j = 0; j < capacity; j++) {
if (frame[j] == pages[i]) {
pageFound = 1;
break;
}
}

if (!pageFound) {
if (rear < capacity - 1) {
rear++;
} else {
rear = 0;
}
frame[rear] = pages[i];
pageFaults++;
}
}

return pageFaults;
}

int lru(int pages[], int n, int capacity) {


int frame[capacity];
int pageFaults = 0;
int counter[capacity];
for (int i = 0; i < capacity; i++) {
frame[i] = -1;
counter[i] = 0;
}

for (int i = 0; i < n; i++) {


int pageFound = 0;
for (int j = 0; j < capacity; j++) {
if (frame[j] == pages[i]) {
pageFound = 1;
counter[j] = i;
break;
}
}

if (!pageFound) {
int lruPage = 0;
for (int j = 1; j < capacity; j++) {
if (counter[j] < counter[lruPage]) {
lruPage = j;
}
}
frame[lruPage] = pages[i];
counter[lruPage] = i;
pageFaults++;
}
}

return pageFaults;
}

OUTPUT:

Enter the number of pages: 12


Enter the sequence of pages (separated by space): 1 2 3 4 1 2 5 1 2 3 4 5

Page Replacement Algorithms Menu:


1. FIFO (First-In-First-Out)
2. LRU (Least Recently Used)
3. Exit
Enter your choice: 1
Page Faults using FIFO: 9

Page Replacement Algorithms Menu:


1. FIFO (First-In-First-Out)
2. LRU (Least Recently Used)
3. Exit
Enter your choice: 2
Page Faults using LRU: 10

Page Replacement Algorithms Menu:


1. FIFO (First-In-First-Out)
2. LRU (Least Recently Used)
3. Exit
Enter your choice: 3
Program 8:
Simulate following File Organization Techniques
a) Single level directory
b) Two level directory

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct SingleLevelDirectory {
char filename[100][100];
int fileCount;
};

struct TwoLevelDirectory {
char directoryName[100][100];
struct SingleLevelDirectory files[100];
int directoryCount;
};

void singleLevelDirectory() {
struct SingleLevelDirectory singleLevelDir;
singleLevelDir.fileCount = 0;

char filename[100];
printf("Enter the filename: ");
scanf("%s", filename);

strcpy(singleLevelDir.filename[singleLevelDir.fileCount], filename);
singleLevelDir.fileCount++;

printf("File '%s' added to single level directory.\n", filename);


}

void twoLevelDirectory() {
struct TwoLevelDirectory twoLevelDir;
twoLevelDir.directoryCount = 0;

char directoryName[100];
printf("Enter the directory name: ");
scanf("%s", directoryName);

strcpy(twoLevelDir.directoryName[twoLevelDir.directoryCount], directoryName);
twoLevelDir.files[twoLevelDir.directoryCount].fileCount = 0;

char filename[100];
printf("Enter the filename: ");
scanf("%s", filename);
strcpy(twoLevelDir.files[twoLevelDir.directoryCount].filename[twoLevelDir.files[twoLevelDir.dire
ctoryCount].fileCount], filename);
twoLevelDir.files[twoLevelDir.directoryCount].fileCount++;

twoLevelDir.directoryCount++;

printf("File '%s' added to '%s' directory.\n", filename, directoryName);


}

int main() {
int choice;

while (1) {
printf("\nFile Organization Techniques Menu:\n");
printf("1. Single Level Directory\n");
printf("2. Two Level Directory\n");
printf("3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
singleLevelDirectory();
break;
case 2:
twoLevelDirectory();
break;
case 3:
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
}

return 0;
}

OUTPUT:
File Organization Techniques Menu:
1. Single Level Directory
2. Two Level Directory
3. Exit
Enter your choice: 1
Enter the filename: document.txt
File 'document.txt' added to single level directory.

File Organization Techniques Menu:


1. Single Level Directory
2. Two Level Directory
3. Exit
Enter your choice: 2
Enter the directory name: folder1
Enter the filename: file1.txt
File 'file1.txt' added to 'folder1' directory.

File Organization Techniques Menu:


1. Single Level Directory
2. Two Level Directory
3. Exit
Enter your choice: 3
Program 9:

#include <stdio.h>
#include <stdlib.h>

struct Block {
int blockNumber;
int fileSize;
struct Block *next;
};

typedef struct Block Block;

Block *head = NULL; // Linked list representing the File Allocation Table (FAT)

void allocateFile(int fileSize) {


Block *newBlock = malloc(sizeof(Block));
if (newBlock == NULL) {
printf("Memory allocation failed.\n");
exit(1);
}

newBlock->blockNumber = rand() % 1000; // Generate a random block number for simplicity


newBlock->fileSize = fileSize;
newBlock->next = NULL;

if (head == NULL) {
head = newBlock;
} else {
Block *temp = head;
while (temp->next != NULL) {
temp = temp->next;
}
temp->next = newBlock;
}

printf("File allocated. Block Number: %d\n", newBlock->blockNumber);


}

void deallocateFile(int blockNumber) {


if (head == NULL) {
printf("No files are allocated.\n");
return;
}

Block *temp = head;


Block *prev = NULL;
while (temp != NULL) {
if (temp->blockNumber == blockNumber) {
if (prev == NULL) {
head = temp->next;
} else {
prev->next = temp->next;
}
free(temp);
printf("File deallocated. Block Number: %d\n", blockNumber);
return;
}
prev = temp;
temp = temp->next;
}

printf("File with Block Number %d not found.\n", blockNumber);


}

void displayFAT() {
Block *temp = head;
printf("File Allocation Table (FAT):\n");
while (temp != NULL) {
printf("Block Number: %d, File Size: %d\n", temp->blockNumber, temp->fileSize);
temp = temp->next;
}
}

int main() {
int choice, fileSize, blockNumber;

while (1) {
printf("\nLinked File Allocation Strategies Menu:\n");
printf("1. Allocate File\n");
printf("2. Deallocate File\n");
printf("3. Display File Allocation Table (FAT)\n");
printf("4. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
printf("Enter the file size: ");
scanf("%d", &fileSize);
allocateFile(fileSize);
break;
case 2:
printf("Enter the block number to deallocate: ");
scanf("%d", &blockNumber);
deallocateFile(blockNumber);
break;
case 3:
displayFAT();
break;
case 4:
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
}

return 0;
}

OUTPUT:

Linked File Allocation Strategies Menu:


1. Allocate File
2. Deallocate File
3. Display File Allocation Table (FAT)
4. Exit
Enter your choice: 1
Enter the file size: 100
File allocated. Block Number: 383

Linked File Allocation Strategies Menu:


1. Allocate File
2. Deallocate File
3. Display File Allocation Table (FAT)
4. Exit
Enter your choice: 1
Enter the file size: 200
File allocated. Block Number: 886

Linked File Allocation Strategies Menu:


1. Allocate File
2. Deallocate File
3. Display File Allocation Table (FAT)
4. Exit
Enter your choice: 3
File Allocation Table (FAT):
Block Number: 383, File Size: 100
Block Number: 886, File Size: 200

Linked File Allocation Strategies Menu:


1. Allocate File
2. Deallocate File
3. Display File Allocation Table (FAT)
4. Exit
Enter your choice: 2
Enter the block number to deallocate: 383
File deallocated. Block Number: 383

Linked File Allocation Strategies Menu:


1. Allocate File
2. Deallocate File
3. Display File Allocation Table (FAT)
4. Exit
Enter your choice: 3
File Allocation Table (FAT):
Block Number: 886, File Size: 200

Linked File Allocation Strategies Menu:


1. Allocate File
2. Deallocate File
3. Display File Allocation Table (FAT)
4. Exit
Enter your choice: 4
Program 10:

Develop a C program to simulate SCAN disk scheduling algorithm.

#include <stdio.h>
#include <stdlib.h>

#define TOTAL_CYLINDERS 200


#define STARTING_CYLINDER 50

void SCAN(int requestQueue[], int size, int head) {


int totalMovement = 0;
int direction; // 1 for right, 0 for left

printf("Enter the initial head movement direction (1 for right, 0 for left): ");
scanf("%d", &direction);

if (direction == 1) {
// Move right until the end of the disk
for (int i = head; i <= TOTAL_CYLINDERS; i++) {
printf("Head moved to cylinder %d\n", i);
totalMovement++;
for (int j = 0; j < size; j++) {
if (requestQueue[j] == i) {
printf("Request for cylinder %d serviced.\n", i);
requestQueue[j] = -1; // Mark request as serviced
}
}
}

// Move left to cylinder 0


for (int i = TOTAL_CYLINDERS - 1; i >= 0; i--) {
if (requestQueue[i] != -1) {
printf("Head moved to cylinder %d\n", i);
totalMovement++;
printf("Request for cylinder %d serviced.\n", i);
}
}
} else if (direction == 0) {
// Move left until the start of the disk
for (int i = head; i >= 0; i--) {
printf("Head moved to cylinder %d\n", i);
totalMovement++;
for (int j = 0; j < size; j++) {
if (requestQueue[j] == i) {
printf("Request for cylinder %d serviced.\n", i);
requestQueue[j] = -1; // Mark request as serviced
}
}
}

// Move right to the end of the disk


for (int i = 1; i <= TOTAL_CYLINDERS; i++) {
if (requestQueue[i] != -1) {
printf("Head moved to cylinder %d\n", i);
totalMovement++;
printf("Request for cylinder %d serviced.\n", i);
}
}
}

printf("Total head movement: %d\n", totalMovement);


}

int main() {
int requestQueue[100];
int size;

printf("Enter the number of requests: ");


scanf("%d", &size);

printf("Enter the request queue (cylinders separated by space): ");


for (int i = 0; i < size; i++) {
scanf("%d", &requestQueue[i]);
}

SCAN(requestQueue, size, STARTING_CYLINDER);

return 0;
}

OUTPUT:
Enter the number of requests: 5
Enter the request queue (cylinders separated by space): 60 70 90 10 110
Enter the initial head movement direction (1 for right, 0 for left): 1
Head moved to cylinder 50
Head moved to cylinder 51
Head moved to cylinder 52
Head moved to cylinder 53
Head moved to cylinder 54
Head moved to cylinder 55
Head moved to cylinder 56
Head moved to cylinder 57
Head moved to cylinder 58
Head moved to cylinder 59
Head moved to cylinder 60
Request for cylinder 60 serviced.
Head moved to cylinder 61
Head moved to cylinder 62
Head moved to cylinder 63
Head moved to cylinder 64
Head moved to cylinder 65
Head moved to cylinder 66
Head moved to cylinder 67
Head moved to cylinder 68
Head moved to cylinder 69
Head moved to cylinder 70
Request for cylinder 70 serviced.
Head moved to cylinder 71
Head moved to cylinder 72
Head moved to cylinder 73
Head moved to cylinder 74
Head moved to cylinder 75
Head moved to cylinder 76
Head moved to cylinder 77
Head moved to cylinder 78
Head moved to cylinder 79
Head moved to cylinder 80
Head moved to cylinder 81
Head moved to cylinder 82
Head moved to cylinder 83
Head moved to cylinder 84
Head moved to cylinder 85
Head moved to cylinder 86
Head moved to cylinder 87
Head moved to cylinder 88
Head moved to cylinder 89
Head moved to cylinder 90
Request for cylinder 90 serviced.
Head moved to cylinder 91
Head moved to cylinder 92
Head moved to cylinder 93
Head moved to cylinder 94
Head moved to cylinder 95
Head moved to cylinder 96
Head moved to cylinder 97
Head moved to cylinder 98
Head moved to cylinder 99
Head moved to cylinder 100
Head moved to cylinder 101
Head moved to cylinder 102
Head moved to cylinder 103
Head moved to cylinder 104
Head moved to cylinder 105
Head moved to cylinder 106
Head moved to cylinder 107
Head moved to cylinder 108
Head moved to cylinder 109
Head moved to cylinder 110
Request for cylinder 110 serviced.
Head moved to cylinder 111
Head moved to cylinder 112
Head moved to cylinder 113
Head moved to cylinder 114
Head moved to cylinder 115
Head moved to cylinder 116
Head moved to cylinder 117
Head moved to cylinder 118
Head moved to cylinder 119
Head moved to cylinder 120
Head moved to cylinder 121
Head moved to cylinder 122
Head moved to cylinder 123
Head moved to cylinder 124
Head moved to cylinder 125
Head moved to cylinder 126
Head moved to cylinder 127
Head moved to cylinder 128
Head moved to cylinder 129
Head moved to cylinder 130
Head moved to cylinder 131
Head moved to cylinder 132
Head moved to cylinder 133
Head moved to cylinder 134
Head moved to cylinder 135
Head moved to cylinder 136
Head moved to cylinder 137
Head moved to cylinder 138
Head moved to cylinder 139
Head moved to cylinder 140
Head moved to cylinder 141
Head moved to cylinder 142
Head moved to cylinder 143
Head moved to cylinder 144
Head moved to cylinder 145
Head moved to cylinder 146
Head moved to cylinder 147
Head moved to cylinder 148
Head moved to cylinder 149
Head moved to cylinder 150
Head moved to cylinder 151
Head moved to cylinder 152
Head moved to cylinder 153
Head moved to cylinder 154
Head moved to cylinder 155
Head moved to cylinder 156
Head moved to cylinder 157
Head moved to cylinder 158
Head moved to cylinder 159
Head moved to cylinder 160
Head moved to cylinder 161
Head moved to cylinder 162
Head moved to cylinder 163
Head moved to cylinder 164
Head moved to cylinder 165
Head moved to cylinder 166
Head moved to cylinder 167
Head moved to cylinder 168
Head moved to cylinder 169
Head moved to cylinder 170
Head moved to cylinder 171
Head moved to cylinder 172
Head moved to cylinder 173
Head moved to cylinder 174
Head moved to cylinder 175
Head moved to cylinder 176
Head moved to cylinder 177
Head moved to cylinder 178
Head moved to cylinder 179
Head moved to cylinder 180
Head moved to cylinder 181
Head moved to cylinder 182
Head moved to cylinder 183
Head moved to cylinder 184
Head moved to cylinder 185
Head moved to cylinder 186
Head moved to cylinder 187
Head moved to cylinder 188
Head moved to cylinder 189
Head moved to cylinder 190
Head moved to cylinder 191
Head moved to cylinder 192
Head moved to cylinder 193
Head moved to cylinder 194
Head moved to cylinder 195
Head moved to cylinder 196
Head moved to cylinder 197
Head moved to cylinder 198
Head moved to cylinder 199
Head moved to cylinder 200
Head moved to cylinder 199
Request for cylinder 199 serviced.
Head moved to cylinder 198
Request for cylinder 198 serviced.
Head moved to cylinder 197
Request for cylinder 197 serviced.
Head moved to cylinder 196
Request for cylinder 196 serviced.
Head moved to cylinder 195
Request for cylinder 195 serviced.
Head moved to cylinder 194
Request for cylinder 194 serviced.
Head moved to cylinder 193
Request for cylinder 193 serviced.
Head moved to cylinder 192
Request for cylinder 192 serviced.
Head moved to cylinder 191
Request for cylinder 191 serviced.
Head moved to cylinder 190
Request for cylinder 190 serviced.
Head moved to cylinder 189
Request for cylinder 189 serviced.
Head moved to cylinder 188
Request for cylinder 188 serviced.
Head moved to cylinder 187
Request for cylinder 187 serviced.
Head moved to cylinder 186
Request for cylinder 186 serviced.
Head moved to cylinder 185
Request for cylinder 185 serviced.
Head moved to cylinder 184
Request for cylinder 184 serviced.
Head moved to cylinder 183
Request for cylinder 183 serviced.
Head moved to cylinder 182
Request for cylinder 182 serviced.
Head moved to cylinder 181
Request for cylinder 181 serviced.
Head moved to cylinder 180
Request for cylinder 180 serviced.
Head moved to cylinder 179
Request for cylinder 179 serviced.
Head moved to cylinder 178
Request for cylinder 178 serviced.
Head moved to cylinder 177
Request for cylinder 177 serviced.
Head moved to cylinder 176
Request for cylinder 176 serviced.
Head moved to cylinder 175
Request for cylinder 175 serviced.
Head moved to cylinder 174
Request for cylinder 174 serviced.
Head moved to cylinder 173
Request for cylinder 173 serviced.
Head moved to cylinder 172
Request for cylinder 172 serviced.
Head moved to cylinder 171
Request for cylinder 171 serviced.
Head moved to cylinder 170
Request for cylinder 170 serviced.
Head moved to cylinder 169
Request for cylinder 169 serviced.
Head moved to cylinder 168
Request for cylinder 168 serviced.
Head moved to cylinder 167
Request for cylinder 167 serviced.
Head moved to cylinder 166
Request for cylinder 166 serviced.
Head moved to cylinder 165
Request for cylinder 165 serviced.
Head moved to cylinder 164
Request for cylinder 164 serviced.
Head moved to cylinder 163
Request for cylinder 163 serviced.
Head moved to cylinder 162
Request for cylinder 162 serviced.
Head moved to cylinder 161
Request for cylinder 161 serviced.
Head moved to cylinder 160
Request for cylinder 160 serviced.
Head moved to cylinder 159
Request for cylinder 159 serviced.
Head moved to cylinder 158
Request for cylinder 158 serviced.
Head moved to cylinder 157
Request for cylinder 157 serviced.
Head moved to cylinder 156
Request for cylinder 156 serviced.
Head moved to cylinder 155
Request for cylinder 155 serviced.
Head moved to cylinder 154
Request for cylinder 154 serviced.
Head moved to cylinder 153
Request for cylinder 153 serviced.
Head moved to cylinder 152
Request for cylinder 152 serviced.
Head moved to cylinder 151
Request for cylinder 151 serviced.
Head moved to cylinder 150
Request for cylinder 150 serviced.
Head moved to cylinder 149
Request for cylinder 149 serviced.
Head moved to cylinder 148
Request for cylinder 148 serviced.
Head moved to cylinder 147
Request for cylinder 147 serviced.
Head moved to cylinder 146
Request for cylinder 146 serviced.
Head moved to cylinder 145
Request for cylinder 145 serviced.
Head moved to cylinder 144
Request for cylinder 144 serviced.
Head moved to cylinder 143
Request for cylinder 143 serviced.
Head moved to cylinder 142
Request for cylinder 142 serviced.
Head moved to cylinder 141
Request for cylinder 141 serviced.
Head moved to cylinder 140
Request for cylinder 140 serviced.
Head moved to cylinder 139
Request for cylinder 139 serviced.
Head moved to cylinder 138
Request for cylinder 138 serviced.
Head moved to cylinder 137
Request for cylinder 137 serviced.
Head moved to cylinder 136
Request for cylinder 136 serviced.
Head moved to cylinder 135
Request for cylinder 135 serviced.
Head moved to cylinder 134
Request for cylinder 134 serviced.
Head moved to cylinder 133
Request for cylinder 133 serviced.
Head moved to cylinder 132
Request for cylinder 132 serviced.
Head moved to cylinder 131
Request for cylinder 131 serviced.
Head moved to cylinder 130
Request for cylinder 130 serviced.
Head moved to cylinder 129
Request for cylinder 129 serviced.
Head moved to cylinder 128
Request for cylinder 128 serviced.
Head moved to cylinder 127
Request for cylinder 127 serviced.
Head moved to cylinder 126
Request for cylinder 126 serviced.
Head moved to cylinder 125
Request for cylinder 125 serviced.
Head moved to cylinder 124
Request for cylinder 124 serviced.
Head moved to cylinder 123
Request for cylinder 123 serviced.
Head moved to cylinder 122
Request for cylinder 122 serviced.
Head moved to cylinder 121
Request for cylinder 121 serviced.
Head moved to cylinder 120
Request for cylinder 120 serviced.
Head moved to cylinder 119
Request for cylinder 119 serviced.
Head moved to cylinder 118
Request for cylinder 118 serviced.
Head moved to cylinder 117
Request for cylinder 117 serviced.
Head moved to cylinder 116
Request for cylinder 116 serviced.
Head moved to cylinder 115
Request for cylinder 115 serviced.
Head moved to cylinder 114
Request for cylinder 114 serviced.
Head moved to cylinder 113
Request for cylinder 113 serviced.
Head moved to cylinder 112
Request for cylinder 112 serviced.
Head moved to cylinder 111
Request for cylinder 111 serviced.
Head moved to cylinder 110
Request for cylinder 110 serviced.
Head moved to cylinder 109
Request for cylinder 109 serviced.
Head moved to cylinder 108
Request for cylinder 108 serviced.
Head moved to cylinder 107
Request for cylinder 107 serviced.
Head moved to cylinder 106
Request for cylinder 106 serviced.
Head moved to cylinder 105
Request for cylinder 105 serviced.
Head moved to cylinder 104
Request for cylinder 104 serviced.
Head moved to cylinder 103
Request for cylinder 103 serviced.
Head moved to cylinder 102
Request for cylinder 102 serviced.
Head moved to cylinder 101
Request for cylinder 101 serviced.
Head moved to cylinder 100
Request for cylinder 100 serviced.
Head moved to cylinder 99
Request for cylinder 99 serviced.
Head moved to cylinder 98
Request for cylinder 98 serviced.
Head moved to cylinder 97
Request for cylinder 97 serviced.
Head moved to cylinder 96
Request for cylinder 96 serviced.
Head moved to cylinder 95
Request for cylinder 95 serviced.
Head moved to cylinder 94
Request for cylinder 94 serviced.
Head moved to cylinder 93
Request for cylinder 93 serviced.
Head moved to cylinder 92
Request for cylinder 92 serviced.
Head moved to cylinder 91
Request for cylinder 91 serviced.
Head moved to cylinder 90
Request for cylinder 90 serviced.
Head moved to cylinder 89
Request for cylinder 89 serviced.
Head moved to cylinder 88
Request for cylinder 88 serviced.
Head moved to cylinder 87
Request for cylinder 87 serviced.
Head moved to cylinder 86
Request for cylinder 86 serviced.
Head moved to cylinder 85
Request for cylinder 85 serviced.
Head moved to cylinder 84
Request for cylinder 84 serviced.
Head moved to cylinder 83
Request for cylinder 83 serviced.
Head moved to cylinder 82
Request for cylinder 82 serviced.
Head moved to cylinder 81
Request for cylinder 81 serviced.
Head moved to cylinder 80
Request for cylinder 80 serviced.
Head moved to cylinder 79
Request for cylinder 79 serviced.
Head moved to cylinder 78
Request for cylinder 78 serviced.
Head moved to cylinder 77
Request for cylinder 77 serviced.
Head moved to cylinder 76
Request for cylinder 76 serviced.
Head moved to cylinder 75
Request for cylinder 75 serviced.
Head moved to cylinder 74
Request for cylinder 74 serviced.
Head moved to cylinder 73
Request for cylinder 73 serviced.
Head moved to cylinder 72
Request for cylinder 72 serviced.
Head moved to cylinder 71
Request for cylinder 71 serviced.
Head moved to cylinder 57
Head moved to cylinder 58

Head moved to cylinder 70


Request for cylinder 70 serviced.
Head moved to cylinder 69
Request for cylinder 69 serviced.
Head moved to cylinder 68
Request for cylinder 68 serviced.
Head moved to cylinder 67
Request for cylinder 67 serviced.
Head moved to cylinder 66
Request for cylinder 66 serviced.
Head moved to cylinder 65
Request for cylinder 65 serviced.
Head moved to cylinder 64
Request for cylinder 64 serviced.
Head moved to cylinder 63
Request for cylinder 63 serviced.
Head moved to cylinder 62
Request for cylinder 62 serviced.
Head moved to cylinder 61
Request for cylinder 61 serviced.
Head moved to cylinder 60
Request for cylinder 60 serviced.
Head moved to cylinder 59
Request for cylinder 59 serviced.
Head moved to cylinder 58
Request for cylinder 58 serviced.
Head moved to cylinder 57
Request for cylinder 57 serviced.
Head moved to cylinder 56
Request for cylinder 56 serviced.
Head moved to cylinder 55
Request for cylinder 55 serviced.
Head moved to cylinder 54
Request for cylinder 54 serviced.
Head moved to cylinder 53
Request for cylinder 53 serviced.
Head moved to cylinder 52
Request for cylinder 52 serviced.
Head moved to cylinder 51
Request for cylinder 51 serviced.
Head moved to cylinder 50
Request for cylinder 50 serviced.
Head moved to cylinder 49
Request for cylinder 49 serviced.
Head moved to cylinder 48
Request for cylinder 48 serviced.
Head moved to cylinder 47
Request for cylinder 47 serviced.
Head moved to cylinder 46
Request for cylinder 46 serviced.
Head moved to cylinder 45
Request for cylinder 45 serviced.
Head moved to cylinder 44
Request for cylinder 44 serviced.
Head moved to cylinder 43
Request for cylinder 43 serviced.
Head moved to cylinder 42
Request for cylinder 42 serviced.
Head moved to cylinder 41
Request for cylinder 41 serviced.
Head moved to cylinder 40
Request for cylinder 40 serviced.
Head moved to cylinder 39
Request for cylinder 39 serviced.
Head moved to cylinder 38
Request for cylinder 38 serviced.
Head moved to cylinder 37
Request for cylinder 37 serviced.
Head moved to cylinder 36
Request for cylinder 36 serviced.
Head moved to cylinder 35
Request for cylinder 35 serviced.
Head moved to cylinder 34
Request for cylinder 34 serviced.
Head moved to cylinder 33
Request for cylinder 33 serviced.
Head moved to cylinder 32
Request for cylinder 32 serviced.
Head moved to cylinder 31
Request for cylinder 31 serviced.
Head moved to cylinder 30
Request for cylinder 30 serviced.
Head moved to cylinder 29
Request for cylinder 29 serviced.
Head moved to cylinder 28
Request for cylinder 28 serviced.
Head moved to cylinder 27
Request for cylinder 27 serviced.
Head moved to cylinder 26
Request for cylinder 26 serviced.
Head moved to cylinder 25
Request for cylinder 25 serviced.
Head moved to cylinder 24
Request for cylinder 24 serviced.
Head moved to cylinder 23
Request for cylinder 23 serviced.
Head moved to cylinder 22
Request for cylinder 22 serviced.
Head moved to cylinder 21
Request for cylinder 21 serviced.
Head moved to cylinder 20
Request for cylinder 20 serviced.
Head moved to cylinder 19
Request for cylinder 19 serviced.
Head moved to cylinder 18
Request for cylinder 18 serviced.
Head moved to cylinder 17
Request for cylinder 17 serviced.
Head moved to cylinder 16
Request for cylinder 16 serviced.
Head moved to cylinder 15
Request for cylinder 15 serviced.
Head moved to cylinder 14
Request for cylinder 14 serviced.
Head moved to cylinder 13
Request for cylinder 13 serviced.
Head moved to cylinder 12
Request for cylinder 12 serviced.
Head moved to cylinder 11
Request for cylinder 11 serviced.
Head moved to cylinder 10
Request for cylinder 10 serviced.
Head moved to cylinder 9
Request for cylinder 9 serviced.
Head moved to cylinder 8
Request for cylinder 8 serviced.
Head moved to cylinder 7
Request for cylinder 7 serviced.
Head moved to cylinder 6
Request for cylinder 6 serviced.
Head moved to cylinder 5
Request for cylinder 5 serviced.
Head moved to cylinder 3
Request for cylinder 3 serviced.
Total head movement: 347

You might also like