Final Os
Final Os
Semester- IV
Lab File
Operating System
(BCS451)
Submitted To : Submitted By :
Faculty Name : Name :
Designation :
Roll No. : Section :
Table of Contents
Vision and Mission Statements of the Institute
List of Experiments
Index
Department Vision Statement
To be a recognized Department of Computer Science & Engineering that produces versatile
computer engineers, capable of adapting to the changing needs of computer and related industry.
i. To provide broad based quality education with knowledge and attitude to succeed in Computer
Science & Engineering careers.
ii. To prepare students for emerging trends in computer and related industry.
iii. To develop competence in students by providing them skills and aptitude to foster culture of
continuous and lifelong learning.
iv. To develop practicing engineers who investigate research, design, and find workable solutions to
complex engineering problems with awareness & concern for society as well as environment.
ii. Graduates will possess capability of designing successful innovative solutions to real life problems
that are technically sound, economically viable and socially acceptable.
iii. Graduates will be competent team leaders, effective communicators and capable of working in
multidisciplinary teams following ethical values.
iv. The graduates will be capable of adapting to new technologies/tools and constantly upgrading
their knowledge and skills with an attitude for lifelong learning
Department Program Outcomes (POs)
The students of Computer Science and Engineering Department will be able:
1. Engineering knowledge: Apply the knowledge of mathematics, science, Computer Science &
Engineering fundamentals, and an engineering specialization to the solution of complex
engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and Computer Science & Engineering sciences.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modelling to complex Computer Science &
Engineering activities with an understanding of the limitations.
6. The Engineering and Society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant
to the professional engineering practice in the field of Computer Science and Engineering.
7. Environment and sustainability: Understand the impact of the professional Computer Science
& Engineering solutions in societal and environmental contexts, and demonstrate the knowledge
of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the Computer Science & Engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
11. Project management and finance: Demonstrate knowledge and understanding of the
Computer Science & Engineering and management principles and apply these to one’s own work,
as a member and leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
Department Program Specific Outcomes (PSOs)
The students will be able to:
2. Understand the processes that support the delivery and management of information systems
within a specific application environment.
Course Outcomes
*Level of Bloom’s Level to be
*Level of Bloom’s Taxonomy Level to be met
Taxonomy met
L1: Remember 1 L2: Understand 2
L3: Apply 3 L4: Analyze 4
L5: Evaluate 5 L6: Create 6
10
Experiment 1:
#include <stdio.h>
#include <stdlib.h>
int main() {
char command[256];
int choice;
while (1) {
printf("Unix Commands Practice:\n");
printf("1. List files (ls)\n");
printf("2. Print working directory (pwd)\n");
printf("3. Display current date and time (date)\n");
printf("4. Display the contents of a file (cat)\n");
printf("5. Create a directory (mkdir)\n");
printf("6. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
getchar(); // Clear newline character from buffer
switch (choice) {
case 1:
executeCommand("ls");
break;
case 2:
executeCommand("pwd");
break;
case 3:
executeCommand("date");
break;
case 4:
printf("Enter filename: ");
fgets(command, sizeof(command), stdin);
command[strcspn(command, "\n")] = 0; // Remove newline
character
char catCommand[256];
snprintf(catCommand, sizeof(catCommand), "cat %s", command);
executeCommand(catCommand);
break;
case 5:
printf("Enter directory name: ");
fgets(command, sizeof(command), stdin);
command[strcspn(command, "\n")] = 0; // Remove newline
character
char mkdirCommand[256];
snprintf(mkdirCommand, sizeof(mkdirCommand), "mkdir %s",
command);
executeCommand(mkdirCommand);
break;
case 6:
printf("Exiting...\n");
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
printf("\n");
}
return 0;
}
Input:
Output:
void findTurnAroundTime(int processes[], int n, int bt[], int wt[], int tat[]) {
for (int i = 0; i < n; i++)
tat[i] = bt[i] + wt[i];
}
findAverageTime(processes, n, burst_time);
return 0;
}
Input:
#include <stdio.h>
while (complete != n) {
for (int j = 0; j < n; j++) {
if ((rt[j] < minm) && (rt[j] > 0)) {
minm = rt[j];
shortest = j;
check = 1;
}
}
if (check == 0) {
t++;
continue;
}
rt[shortest]--;
minm = rt[shortest];
if (minm == 0)
minm = 10000000;
if (rt[shortest] == 0) {
complete++;
check = 0;
finish_time = t + 1;
wt[shortest] = finish_time - bt[shortest];
if (wt[shortest] < 0)
wt[shortest] = 0;
} t+
+;
}
}
void findTurnAroundTime(int processes[], int n, int bt[], int wt[], int tat[]) {
for (int i = 0; i < n; i++)
tat[i] = bt[i] + wt[i];
}
int main() {
int processes[] = { 1, 2, 3 };
int n = sizeof(processes) / sizeof(processes[0]);
int burst_time[] = { 6, 8, 7, 3 };
findAverageTime(processes, n, burst_time);
return 0;
}
Input:
Output:
a) Priority (Non-Preemptive)
#include <stdio.h>
typedef struct {
int processID;
int burstTime;
int priority;
int waitingTime;
int turnAroundTime;
} Process;
findWaitingTime(proc, n);
findTurnAroundTime(proc, n);
int main() {
Process proc[] = { {1, 10, 3}, {2, 1, 1}, {3, 2, 4}, {4, 1, 5}, {5, 5, 2} };
int n = sizeof(proc) / sizeof(proc[0]);
sortProcessesByPriority(proc, n);
findAverageTime(proc, n);
return 0;
}
Input:
Allocation Matrix: [[0, 1, 0], [2, 0, 0], [3, 0, 2], [2, 1, 1], [0, 0, 2]]
Request Matrix: [[0, 0, 0], [2, 0, 2], [0, 0, 0], [1, 0, 0], [0, 0, 2]]
Available Resources: [3, 3, 2]
Output:
Allocation Matrix:
010
200
302
211
002
Request Matrix:
000
202
000
100
002
Available Resources:
332
b) Multi-level Queue Scheduling
#include <stdio.h>
typedef struct {
int processID;
int burstTime;
int queueLevel;
int waitingTime;
int turnAroundTime;
} Process;
findWaitingTime(proc, n);
findTurnAroundTime(proc, n);
int main() {
Process proc[] = { {1, 10, 1}, {2, 5, 1}, {3, 8, 2}, {4, 6, 3} };
int n = sizeof(proc) / sizeof(proc[0]);
sortProcessesByQueueLevel(proc, n);
findAverageTime(proc, n);
return 0;
}
Input:
Processes: [0, 1, 2, 3, 4]
Available Resources: [3, 3, 2]
Maximum Resources: [[7, 5, 3], [3, 2, 2], [9, 0, 2], [2, 2, 2], [4, 3, 3]]
Allocated Resources: [[0, 1, 0], [2, 0, 0], [3, 0, 2], [2, 1, 1], [0, 0, 2]]
Output:
#include <stdio.h>
printf("Request Matrix:\n");
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
printf("%d ", request[i][j]);
}
printf("\n");
}
printf("Available Resources:\n");
for (int j = 0; j < M; j++) {
printf("%d ", available[j]);
}
printf("\n");
}
int main() {
int allocation[N][M] = { {0, 1, 0}, {2, 0, 0}, {3, 0, 2}, {2, 1, 1}, {0, 0, 2} };
int request[N][M] = { {0, 0, 0}, {2, 0, 2}, {0, 0, 0}, {1, 0, 0}, {0, 0, 2} };
int available[M] = {3, 3, 2};
Allocation Matrix: [[0, 1, 0], [2, 0, 0], [3, 0, 2], [2, 1, 1], [0, 0, 2]]
Request Matrix: [[0, 0, 0], [2, 0, 2], [0, 0, 0], [1, 0, 0], [0, 0, 2]]
Available Resources: [3, 3, 2]
Output:
Wait-For Graph:
00000
00110
00000
00000
00000
Experiment 5:
#include <stdio.h>
#include <stdbool.h>
int count = 0;
while (count < N) {
bool found =
false;
for (int p = 0; p < N; p++) {
if (!finish[p]) {
int j;
for (j = 0; j < M; j++)
if (need[p][j] > work[j])
break;
if (j == M) {
for (int k = 0; k < M; k++)
work[k] += allot[p][k];
safeSeq[count++] = p;
finish[p] = 1;
found = true;
}
}
}
if (!found) {
printf("System is not in safe state\n");
return false;
}
}
int main() {
int processes[] = {0, 1, 2, 3, 4};
int max[N][M] = { {7, 5, 3}, {3, 2, 2}, {9, 0, 2}, {2, 2, 2}, {4, 3, 3} };
int allot[N][M] = { {0, 1, 0}, {2, 0, 0}, {3, 0, 2}, {2, 1, 1}, {0, 0, 2} };
return 0;
}
Input
Output
#include <stdio.h>
int main() {
int allocation[N][M] = { {0, 1, 0}, {2, 0, 0}, {3, 0, 2}, {2, 1, 1}, {0, 0, 2} };
int request[N][M] = { {0, 0, 0}, {2, 0, 2}, {0, 0, 0}, {1, 0, 0}, {0, 0, 2} };
int available[M] = {3, 3, 2};
Output
Wait-For Graph:
00000
00000
00000
00000
00000