0% found this document useful (0 votes)
96 views61 pages

Padosi Osfile

Uploaded by

arvinjulaha17
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)
96 views61 pages

Padosi Osfile

Uploaded by

arvinjulaha17
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/ 61

Practical File

of
Operating System
22CS005
Submitted

in partial fulfillment for the award of

the degreeof

BACHELEOR OF ENGINEERING
in

COMPUTER SCIENCE & ENGINEERING

CHITKARA UNIVERSITY
CHANDIGARH-PATIALA NATIONAL HIGHWAY
RAJPURA (PATIALA) PUNJAB-140401 (INDIA).
June, 2024

Submitted To: Submitted By:

Dr. Arjun Puri Name: Ayush Singh


Assistant Professor Roll No.: 2310990394
Chitkara University, Punjab Sem, Batch: 2nd, 2023
INDEX

S. No. Practical Name Teacher Sign

Installation: Configuration & Customizations of Linux

1 Introduction to GCC compiler: Basics of GCC,Compilation


of program, Execution of program, Time stamping,
Automating the execution using Make file.

Implement Process concepts using C Language by Printing


process Id, Execute Linux command as sub process,
2
Creating and executing process using fork and exec system
calls.

Implement FCFS, SJF, priority scheduling, and RR


3
scheduling algorithms in C language.

Implement the basic and user status commands like: su,


sudo, man, help, history, who, whoami, id, uname, uptime,
4
free, tty, cal, date, hostname,
reboot, clear.

5 Implement deadlock in C by using shared variable.

File system: Introduction to File system, File system


6
Architecture and File Types.

Implement the commands that is used for Creating and


Manipulating files: cat, cp, mv, rm, ls and its options, touch
7
and their options, which is,
where is, what is.
Implement Directory oriented commands: cd, pwd,
8
mkdir, rmdir.
Implement File system commands: Comparing Files
9
using diff, cmp,comm.
Mass Storage structure :Overview, Disk structure, Disk
10
Attachment, Disk Scheduling, Disk Management.

2
Program – 1
AIM: Installation: Configuration & Customizations of Linux.
Introduction to GCC compiler: Basics of GCC, Compilation of program,Execution
of program, Time stamping, Automating the execution using Make file.

Installation of GCC on Linux

By default, it comes with the most Linux distributions. We can verify it by executing
the below command:
1. gcc -version
The above command will display the installed version of the GCC tool. If itis not
installed, follow the below steps to install it:

Step 1: Update the package list.

To update the package list, execute the following command:

1. sudo apt update

It will ask for the system administrative password, enter the password. Itwill
start updating the system package. Consider the below snap of output:

Step 2: Install the build-essential package.

It contains various packages such as gcc, g++, and make utility. Execute the
below command to install it:

1. sudo apt install build-essential

The above command will install the required packages for the GCC utility.Now,
we can use the GCC utility in our machine. Consider the below snapof output:
Step 3: Verify the installation.

To verify the installation, execute the gcc -version command as follows:

1. gcc --version

It will display the installed version of GCC utility. To display the more specific
details about the version, use the '-v' option. Consider the below output:

Here, we have successfully installed the GCC utility. Let's understand to use it.
We will create and execute some c programs using GCC.

Run first C program by gcc.

Create a basic c program "Hello world!". Create a file 'hello.c" and put below
code in it:

1. #include <stdio.h>
2. int main() {
3. printf("Hello, world!\n");
4. return 0;
5. }
Now, compile the hello.c as follows:

4
1. gcc hello.c

If we directly run the hello.c, it will throw the error. Make it executable, the
default executable file for the Linux system is a.out. To execute the file, execute
the chmod command as follows:

2. chmod a+x a.out Now,

run the c program as:

3. ./a.out
Consider the below output:

GCC Commands with examples

Some useful examples of gcc commands are as following:

o Specify the object file name

By default, the gcc command creates the object file as 'a.out.' If you want to
change the default output file name, use the '-o' option.

Let's execute the basic gcc command:

1. gcc hello.c

The above command will generate the object file 'a.out.' To specify theobject
file name, execute the command as follows:
1. gcc hello.c -o hello
It will generate the output file 'hello.' Consider the below output:

5
o Enable all Warnings

To enable all warnings in the output, use the '-Wall' option with the gcccommand.
Let's create a variable in the main function of hello.c. Consider the below code:
hello.c:

1. #include <stdio.h>
2. int main() {
3. int a;
4. printf("Hello, world!\n");
5. return 0;
6. }
If we compile the above code using -Wall option. It will throw the
warnings. Execute the below command to compile the file:

1. gcc -wall hello.c

The above command will display the warnings. Consider the below output:

o Produce the stepwise output of the compilation process


We can only produce the stepwise output of the compilation process.

Produce the preprocessor output

We can produce only the preprocess output by using the '-E' option. Consider
the below command:

1. gcc -E hello.c > hello.i

From the above command, a file 'hello.i' that contains preprocessedoutput is


generated. Consider the below output:

6
Produce the assembly code

To produce the assembly code, execute the command with the '-S' option.
Consider the below command:

2 gcc -S hello.c > hello.s

The above command will generate the 'hello.s.' file that contains the
assembly code. Consider the below output:

Produce the compiled code


We can produce only the compiled code by using the '-C' option. Consider the
below command:
2. gcc -C hello.c
The above command will generate a file 'a.out,' having only the machinecode or
compiled code. Consider the below output:

Produce all the intermediate files of the compilation process

We can produce all the intermediate files of the compilation process byusing
the '-save-temp' option. Consider the below output:
3. gcc -save-temps hello.c
The above command will generate all the intermediate files as well as
executable files at once. Consider the below output:

o Print the output verbosely.

We can display verbose information of every step taken by gcc command.To do


so, execute the command with the '-v' option.
4. gcc -W -v hello.c ,Consider the below snap of output:

7
We have discussed some most useful examples of the gcc command. Since the
gcc command facilitates with a huge number of options, you can get stuck
anywhere while using it. Let's see how to get help by yourself from the
terminal.

If you get stuck anywhere while using the gcc command, you can take help
from your terminal. To access the manual from the command line, execute the
man command as follows:

man gcc

8
Program - 2
AIM: Implement Process concepts using C language by printing processId,execute Linux
command as sub process, creating and executing process using fork and exec system calls.

The title of our practical contains two different functions of the C language that occur while
running any program in our system. Unfortunately, there is zero possibility of occurring
more than one program at a time in C. Onlya single task can happen at a particular time,
which means it doesn’t allowconcurrent programs to run. It causes you to wait for the
completion of one process to execute the other one. To avoid this troubleshooting problem,
you may need to develop yourprogram in a good way, being a good developer. Linux fork () is
used to overcomethe waiting and to allowconcurrency in your system. It helps in duplicating a
new process and creates a new one by calling the duplicated process. The new process isthe
child process, and the previous one is called the parent process.
Whereas, exec () function is used to change the current existing programwith the new one.
This replacement is done by making amendments to the content of a program or a file. So,
the dissimilarity between fork and exec is that fork creates a new process from the existing
process, and exec is used to replace the existing program by creating a new one.
Prerequisites

To execute any c program on your Linux system, we need to install some prerequisites on it.
Go to the terminal by using the shortcut method Ctrl+Alt+T. Now write the following
commands to install the man pages.
sudo apt install manpages-dev

9
It will install all the corresponding pages.
Moving forward, to run a program on Linux, you need to install a codecompiler. That is used
to compile the code and execute it. For this purpose, we will install GCC repositories in our
system.

$ sudo apt install GCC


Coding with exec in c
As we have installed the man pages in Linux, we will use the following command to see the
description regarding exec. The primary sample syntax is asfollow:
Syntax
Exec (pathname/file, argv ); Here
we have used the “unistd.h” header as it contains all information of families of exec function.

$ man exec

10
Now in the above-cited image, you can observe the types of exec.These are the family of
exec functions. Each one is for a different function following the same base, “exec.”

Example: Now, moving further, we will describe the functionality of execwith the help of
an example. We will take one function of exec to demonstrate its working, which is
“execv.” Firstly, we will create two fileswith the extension of “.c.” After their creation, we
will write respective codes in them and execute them to see the result.
Consider a file name “sample4.c”. Please open it and use the followingcode. In this code, we
have used execv in a particular manner cited below.

Execv (“./sample4copy” , args); The


first part contains the new directory path, and the second partshows the arguments
array as a parameter we have passed.
Sample4.c

First of all, we have printed the current process’s id. Secondly, we havecreated a character
array having NULL in the end for the termination.
Thirdly we have called the sample4copy function.

Sample4copy.c
When we call the exec function(), the process image is changed. Below cited image
below shows the code of sample4copy.c.

Here we have used only print statements to get the id of the currentprocess.

11
The output of the respective codes can be obtained by using thefollowing commands.

$ GCC–o sample4 sample4.c


$ GCC –o sample4copy sample4copy.c
$ ./sample4

As we have described earlier, the “GCC” word is used to compile thecode, and after
compiling, the code is executed successfully.

According to the image, The PID of sample4.c file is shown first as it was declared before the
exec call. Then after the exec() function is called, both the print statements of file
sample4copy.c is executed where getpid() is used to obtain the process’s id.
Coding with a fork in c
The fork() function creates the child process from the parent process. It also
contains two headers, including the fork information in it.

Syntax:
Pid_t fork(void);
We can use the man page for help in the usage

$ man fork

12
Example: Now consider an example by creating a file “sample3.c”. We will enter the
code inside the file. According to the code, we have set thefork statusas forkrank.

Sample3.c

We have used the “if-else” statement to apply the condition. Simple print commands are
declared here to help in the understanding of the fork() concept. Forkrank is first
declared as 0 and then -1. With a fork(), there are now two processes that are working
concurrently. Output can be obtained by using the same code, as used above in exec
example.

$ GCC –o sample3.c
$./sample3

The output shows that the child process is executed earlier than the parent when the
parent process was waiting. The wait function implies that it causes the parent function
to wait unless one of all the child processes is terminate.

13
Fork and Exec system calls Collectively
Here we will take two files named “sample1.c” and “sample2.c”. First, open the
file sampl1.c and write the code that is appended below in theimage. We have
used the fork() system-call here; when the child process is created, p will be
assigned with 0. While using exec system-call, the sample1.c will be replaced
with sample2.c.

Sample1.c

Sample2.c

14
Similar to the examples discussed above, the sample2 file will
contain the printf statements in it. In sample1.c, the first print
command is executed first, then the fork function is called, when
p== 0, then child portion is executed and sample2.c file will be run.
The output will contain GCC to compile both files. Here parent
sample1.c id and sample2.c id isdifferent because they are parent
and child.

Conclusion
In this experiment, we have used both fork and exec separately and
collectively to understand the usage and concept easily.

15
Program–3
AIM: Implement FCFS, SJF, priority scheduling, and RR schedulingalgorithms in
C language.

Purpose of Scheduling algorithm


• Maximum CPU utilization
• Fare allocation of CPU
• Maximum throughput
• Minimum turnaround time
• Minimum waiting time
• Minimum response time

There are four types of process scheduling algorithms:

1. First Come First Serve (FCFS) Scheduling


2. Shortest Job First (SJF) Scheduling
3. Round Robin Scheduling
4. Priority Scheduling

First Come First Serve (FCFS) Scheduling


First come first serve (FCFS) scheduling algorithm simply schedules the jobs
according to their arrival time. The job which comes first in the readyqueue will get
the CPU first. The lesser the arrival time of the job, the sooner will the job get the
CPU. FCFS scheduling may cause the problemof starvation if the burst time of the
first process is the longest among all the jobs.
Completion Time: Time at which process completes its execution.

Turn Around Time (TAT): Time Difference between completion time andarrival
time.
Turn Around Time = Completion Time – Arrival Time

Waiting Time (WT): Time Difference between turn around time and bursttime.
Waiting Time = Turn Around Time – Burst Time

16
Program Code

#include<stdio.h> #include<conio.h> void main(){ clrscr();


int bt[10]={0},at[10]={0},tat[10]={0},wt[10]={0},ct[10]={0};
int n,sum=0;
float totalTAT=0, totalWT=0; printf("Enter number of processes: "); scanf("%d",&n);
printf("Enter Arrival time and Burst time for each process:\n");
for(int i=0;i<n;i++)
{
printf("Arrival time of process[%d]: ",i+1); scanf("%d",&at[i]);
printf("Burst time of process[%d]: ",i+1); scanf("%d",&bt[i]);
}
//calculate completion time of processes for(int j=0;j<n;j++)
{
sum+=bt[j]; ct[j]+=sum;
}
//calculate turnaround time and waiting times for(int k=0;k<n;k++)
{
tat[k]=ct[k]-at[k]; totalTAT+=tat[k];
}
for(k=0;k<n;k++)
{
wt[k]=tat[k]-bt[k]; totalWT+=wt[k];
}
printf("P#\t AT\t BT\t CT\t TAT\t WT\t\n\n"); for(i=0;i<n;i++)
{
printf("P%d\t %d\t %d\t %d\t %d\t
%d\n",i+1,at[i],bt[i],ct[i],tat[i],wt[i]);
}
printf("\nAverage Turnaround Time = %f\n",totalTAT/n); printf("Average WT = %f\n\n",totalWT/n);
getch();
}
17
Output
Enter number of processes: 5
Enter Arrival time and Burst time for each process:Arrival time of process[1]: 0
Burst time of process[1]: 4 Arrival time of process[2]: 1
Burst time of process[2]: 3 Arrival time of process[3]: 2 Burst
time of process[3]: 1 Arrival time of process[4]: 3 Burst time
of process[4]: 2 Arrival time of process[5]: 4 Burst time of
process[5]: 5
P# AT BT CT TAT WT

P1 0 4 4 4 0

P2 1 3 7 6 3

P3 2 1 8 6 5

P4 3 2 10 7 5

P5 4 5 15 11 6

Average Turnaround Time = 6.800000

Average WT = 3.800000

Shortest Job First (SJF) Scheduling


Shortest Job First (SJF) is a scheduling algorithm, that is used to schedule
processes in an operating system. It is a very important topic in Scheduling when
compared to round-robin and FCFS Scheduling.

There are two types of SJF


• Pre-emptive SJF
• Non-Preemptive SJF

These algorithms schedule processes in the order in which the shortest job is done
first. It has a minimum average waiting time.

There are 3 factors to consider while solving SJF, they are

1. Burst Time
2. Average waiting time
3. Average turnaround time

18
Non-Preemptive Shortest Job First

Here is an example

TurnAround
Process Id Burst Time Waiting Time
Time
4 3 0
1 6 3
3 7 9
2 8 16

Average waiting time = 7


Average turnaround time = 13
T.A.T = waiting time + burst time

Code for Shortest Job First Scheduling


#include<stdio.h>
int main()
{
int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;
float avg_wt,avg_tat;
printf("Enter number of process:");
scanf("%d",&n);
printf("nEnter Burst Time:n");
for(i=0;i<n;i++)
{
printf("p%d:",i+1);
scanf("%d",&bt[i]);
p[i]=i+1;
}
//sorting of burst times
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];

19
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)
{
wt[i]+=bt[j];
total+=wt[i];
}
avg_wt=(float)total/n;
total=0;
printf("n Process Burst Time Waiting Time Turnaround Time");
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
total+=tat[i];
printf("np%dtt %dtt %dttt%d",p[i],bt[i],wt[i],tat
}
avg_tat=(float)total/n;
printf("nnAverage Waiting Time=%f",avg_wt); printf("nAverage
Turnaround Time=%fn",avg_tat);
}

Output:

20
In the above program, we calculate the average waiting and average turn
around times of the jobs. We first ask the user to enter the numberof processes
and store it in n. We then accept the burst times from the user. It is stored in the
bt array.

After this, the burst times are sorted in the next section so the shortest one can
be executed first. Here selection sort is used to sort the array of burst time bt.

Waiting time of the first element is zero, the remaining waiting time is calculated
by using two for loop that runs from 1 to in that controls the outer loop and the
inner loop is controlled by another for loop that runs from j=0 to j<i. Inside the
loop, the waiting time is calculated by adding the burst time to the waiting time.
1for(i=1;i<n;i++)
2 {
3 wt[i]=0;
4 for(j=0;j<i;j++)
5 wt[i]+=bt[j];
6 total+=wt[i];
7}

Total is the addition of all the waiting time together. The average waitingtime is
calculated:

avg_wt=(float)total/n;

and it is printed.

Next, the turnaround time is calculated by adding the burst time and thewaiting
time

1for(i=0;i<n;i++)
2{
3 tat[i]=bt[i]+wt[i];total+=tat[i];
4 printf("np%dtt %dtt %dttt%d",p[i],bt[i],wt[i],tat[i]);
5}
6

Again, here the for loop is used. And the total variable here holds the totalturnaround
time. After this the average turnaround time is calculated. This is how Non-
Preemptive scheduling takes place

21
Code for Pre-emptive SJF Scheduling
#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, turnaround_time = 0, end; float average_waiting_time,
average_turnaround_time; printf("nEnter the Total Number of Processes:t");
scanf("%d", &limit);
printf("nEnter Details of %d Processesn", limit);
for(i = 0; i < limit; i++)
{
printf("nEnter Arrival Time:t"); scanf("%d",
&arrival_time[i]); printf("Enter Burst Time:t");
scanf("%d", &burst_time[i]);
temp[i] = burst_time[i];
}
burst_time[9] = 9999;
for(time = 0; count != limit; time++)
{
smallest = 9;
for(i = 0; i < limit; i++)
{
if(arrival_time[i] <= time && burst_time[i] <burst_time[i] > 0)
{
smallest = i;
}
}
burst_time[smallest]--;
if(burst_time[smallest] == 0)
{
count++;
end = time + 1;
wait_time = wait_time + end - arrival_time[small
turnaround_time = turnaround_time + end - arriva
}
}
average_waiting_time = wait_time / limit; average_turnaround_time =
turnaround_time / limit; printf("nnAverage Waiting Time:t%lfn",
average_waiting_time) printf("Average Turnaround Time:t%lfn",
average_turnaround_treturn 0;
}
22
Output:

The only difference in preemptive and non-preemptive is that when two burst
times are same the algorithm evaluates them on first come first serve basis. Hence
there is an arrival time variable.

What is Priority Scheduling Algorithm?

In the priority scheduling algorithm, each process has a priority associated with it and
as each process hits the queue, it is stored based on its priority so that processes with
higher priority is dealt with first. It should be noted that equal priority processesare
scheduled in FCFS order.

To prevent high priority processes from running indefinitely the scheduler may
decrease the priority of the currently running process at each clock tick (i.e., at each
clock interrupt). If this action causes its priority to drop below that of the next highest
process, a process switch occurs. Alternatively, each process may be assigned a
maximum time quantum that it is allowed to run. When this quantum is used up, the
next highest priority process is given a chance to run.

23
Example:

Here is an example of a Priority Scheduling algorithm.

Process Arrival Time Burst Time Priority


P1 0 5 2
P2 1 3 1

P3 2 6 4

P4 4 4 3
P5 6 2 5
In this example, there are 5 processes with their arrival time, burst time, and
priority. The execution order, waiting time, andturnaround time for each process
will be as given below.

Process Burst Time Waiting Time Turnaround Time


P2 3 0 3

P1 5 3 8
P4 4 8 12
P3 6 12 18
P5 2 18 20

• Average Waiting Time = (0 + 3 + 8 + 12 + 18) / 5 =8.2


• Average Turnaround Time = (3 + 8 + 12 + 18 + 20)/ 5 = 12.2
Limitations

The problem occurs when the operating system gives a particular task a very low
priority, so it sits in the queue for a larger amount of time, not being dealt with by the
CPU. If this process is something the user needs, there could be a very long wait, this
process is known as “Starvation” or “Infinite Blocking”.

Solution

Many operating systems use a technique called “aging”, in which a low priority process
slowly gains priority over time as it sits in the queue. Even if, the priority of
24
Code for Priority Scheduling
1 #include<stdio.h>
2int main()
3{
4 int
5bt[20],p[20],wt[20],tat[20],pr[20],i,j,n,total=0,pos,temp,avg_wt,avg_tat;
6 printf("Enter Total Number of Process:");
7 scanf("%d",&n);
8 printf("\nEnter Burst Time and Priority\n");
9 for(i=0;i<n;i++)
10 {
11 printf("\nP[%d]\n",i+1);
12 printf("Burst Time:");
13 scanf("%d",&bt[i]);
14 printf("Priority:");
15 scanf("%d",&pr[i]);
16 p[i]=i+1; //contains process number
17 }
18//sorting burst time, priority and process number in ascending order using
19selection sort
20 for(i=0;i<n;i++)
21 {
22 pos=i;
23 for(j=i+1;j<n;j++)
24 {
25 if(pr[j]<pr[pos])
26 pos=j;
27 }
28 temp=pr[i];
29 pr[i]=pr[pos];
30 pr[pos]=temp;
31 temp=bt[i];
32 bt[i]=bt[pos];
33 bt[pos]=temp;
34 temp=p[i];
35 p[i]=p[pos];
36 p[pos]=temp;
37 }
38 wt[0]=0; //waiting time for first process is zero
39 //calculate waiting time

40 for(i=1;i<n;i++)
41 {
42 wt[i]=0;
43 for(j=0;j<i;j++)
44 wt[i]+=bt[j];
25
45
total+
=wt[i]; 46
}
47 avg_wt=total/n; //averagewaiting time
48 total=0;
49 printf("\nProcess\t Burst Time \tWaiting Time\tTurnaround Time");
50 for(i=0;i<n;i++)
51 {
52 tat[i]=bt[i]+wt[i]; //calculate turnaround time
53 total+=tat[i];
54 printf("\nP[%d]\t\t %d\t\t %d\t\t\t%d",p[i],bt[i],wt[i],tat[i]);
55 }
56 avg_tat=total/n; //average turnaround time
57 printf("\n\nAverage Waiting
58 Time=%d",avg_wt); printf("\nAverage
Turnaround Time=%d\n",avg_tat);
return 0;
}

OUTPUT:

26
ROUND ROBIN SCHEDULING

Round Robin CPU Scheduling is the most important CPU Scheduling Algorithm which is ever
used in the history of CPU Scheduling Algorithms. Round Robin CPU Scheduling uses Time
Quantum (TQ). The Time Quantum is something which is removed from the Burst Time and

lets the chunk of process to be completed.

Time Sharing is the main emphasis of the algorithm. Each step of this algorithm is carried out
cyclically. The system defines a specific time slice, known as a time quantum.

First, the processes which are eligible to enter the ready queue enter the ready queue. After
entering the first process in Ready Queue is executed for a Time Quantum chunk of time. After
execution is complete, the process is removed from the ready queue. Even now the process
requires some time to complete its execution, then the process isadded to Ready Queue.

The Ready Queue does not hold processes which already present in the Ready Queue. The
Ready Queue is designed in such a manner that it does not hold non unique processes. By
holding same processes Redundancy of the processes increases.

After, the process execution is complete, the Ready Queue does not take the completed process
for holding.

27
Advantages

The advantages of Round Robin CPU Scheduling are:


1. A fair amount of CPU is allocated to each job.
2. Because it doesn't depend on the burst time, it can truly be
implemented in the system.

3. It is not affected by the convoy effect or the starvation problem as


occurred in First Come First Serve CPU SchedulingAlgorithm.

Disadvantages

The disadvantages of Round Robin CPU Scheduling are:

1. Low Operating System slicing times will result in decreased


CPU output.
2. Round Robin CPU Scheduling approach takes longer to swap
contexts.
3. Time quantum has a significant impact on its performance.
4. The procedures cannot have priorities established.
Examples:

S. No Process ID Arrival Time Burst Time


1 P1 0 7
2 P2 1 4
3 P3 2 15
4 P4 3 11
5 P5 4 20
6 P6 4 9

Assume Time Quantum TQ = 5

Ready Queue:

P1, P2, P3, P4, P5, P6, P1, P3, P4, P5, P6, P3, P4, P5

28
Gantt chart:

Average Completion Time

1. Average Completion Time = (31 +9 + 55 +56 +66 + 50) / 6


2. Average Completion Time = 267 / 6
3. Average Completion Time = 44.5

Average Waiting Time


1. Average Waiting Time = (5 + 26 + 5 + 42 + 42 + 37) / 6
2. Average Waiting Time = 157 / 6
3. Average Waiting Time = 26.16667

Average Turn Around Time

1. Average Turn Around Time = (31 + 8 + 53 + 53 + 62 + 46) / 6


2. Average Turn Around Time = 253 / 6
3. Average Turn Around Time = 42.1666

29
Program-4

AIM: Implement the basic and user status commands like: su, sudo, man, help, history,
who, whoami, id, uname, uptime, free, tty, cal, date, hostname, reboot, clear.
1. man command:
man command in Linux is used to display the user manual of any command that we
can run on the terminal.

Manual:

• man pwd: Provides detailed information about present working directory.

30
• man intro: Gives introduction to user commands.
2. hostname command:

Type hostname at the command line. This will print your computer name on the
next line.

31
1. who command:

who command is a tool print information about users who are currently logged in.
who command only see a real user who logged in.

• who -a/who -all: To display all details of currently logged in users.

• Who -p -H: To display information about all active processes that are
spawned by the NIT process.

• Who -r: To display the current run level of the system.

• who -m -H:Command to display the hostname and user associated with the
input/output like keyboard.

1. whoami command:
The 'whoami' command in Linux is a built-in utility that displays the username of
the current user. It is used with the syntax, whoami [option] . It's a quick and easy
way to confirm your identity within the system. In this example, we've used the
'whoami' command in the terminal.

32
2. uptime command:
The Linux uptime command shows the system's uptime, how long it has been
running, and when it was last booted. Depending on the options, the command
prints the number of users and system load averages.

• uptime –help: Display all commands that can be used with uptime.

• uptime -p: Show uptime in pretty format.

• uptime -s: Shows the time from which the system is up.

33
• uptime -v: It shows the output version information and exit.

3. cal command:
The cal command displays a calendar of the specified year or month. The Year
parameter names the year for which you want a calendar.

4. date command:
The "date" command in Linux is a simple but powerful tool used to display the

current date and time, as well as set the system date and time. This command is
extremely useful for troubleshooting and system administration tasks, and is a
vital tool in understanding any Linux user.

1. id command :
The id command is a basic Linux command used to confirm the identity of a
specified Linux user.

34
2. uname command:
The uname command writes to standard output the name of the operating system
that you are using.

• uname -s: Display the kernel name.

• uname -r: Used to check the Kernel release version.


3. help command:

help command just displays information about shell built-in commands.

35
4. sudo command:

The sudo command allows you to run programs with the security privileges of
another user.

5. history command:
The history command in Linux provides a chronological list of previously
executed commands, along with corresponding command numbers. This feature
allows users to recall, reuse, and modify commands without having to retype
them.

• history 5: Helps to di splay previously 5 commands.

36
6. tty command:
The tty command in Linux is a built-in utility that displays the file name of the
terminal connected to the standard input.

tty

37
• tty –help: It will display the help message and exit.

• tty –version: Prints the version information and exits.

38
Program – 5

AIM: Implement deadlock in C by using shared variable.

Deadlock in operating system is a situation which occurs when a process or thread


enters a waiting state because a resource requested is being held by another waiting
process, which in turn is waiting for another resource held by another waiting
process. In a deadlock state a process is unable to change its state (waiting)
indefinitely because the resources requested by it are being used by another waiting
process.

Setup

To simulate deadlock in the system we will create the above shown situation.

P1 and P2 will be represented by two thread one and two.The two resources R1 and R2
will be represented by the two lock variables first_mutex and second_mutex
First thread one will acquire lock first_mutex and then thread two will acquirelock
second_mutex. Hence, both the threads have acquired oneresource each.
Next, thread one will try to acquire lock second_mutex while the second thread, thread two
will try to acquire lock first_mutex. Since the resources are already occupied by the other
thread, both the threads will get into a deadlock.

39
Program to create Deadlock Using C in Linux using Mutex Locks andthreads
#include<stdio.h>
#include<pthread.h>
#include<unistd.h> void
*function1(); void
*function2();
pthread_mutex_t first_mutex; //mutex lockpthread_mutex_t
second_mutex;
int main() {
pthread_mutex_init(&first_mutex,NULL); //initialize the lock
pthread_mutex_init(&second_mutex,NULL);
pthread_t one, two;
pthread_create(&one, NULL, function1, NULL); // create thread
pthread_create(&two, NULL, function2, NULL); pthread_join(one,
NULL);
pthread_join(two, NULL);
printf("Thread joined\n");
}

void *function1( ) {

pthread_mutex_lock(&first_mutex); // to acquire the resource/mutexlock

printf("Thread ONE acquired first_mutex\n");

sleep(1); pthread_mutex_lock(&second_mutex);

printf("Thread ONE acquired second_mutex\n");

pthread_mutex_unlock(&second_mutex); // to release the resource

printf("Thread ONE released second_mutex\n");

pthread_mutex_unlock(&first_mutex);

printf("Thread ONE released first_mutex\n");


}

40
void *function2( ) { pthread_mutex_lock(&second_mutex);
printf("Thread TWO acquired second_mutex\n");sleep(1);
pthread_mutex_lock(&first_mutex); printf("ThreadTWO
acquired first_mutex\n");
pthread_mutex_unlock(&first_mutex); printf("Thread TWO
released first_mutex\n");
pthread_mutex_unlock(&second_mutex); printf("Thread
TWO released second_mutex\n");
}

Synchronization primitives Mutex locks • Used for exclusive access to a shared


resource (critical section) • Operations: Lock, unlock Sempahores • Generalization of
mutexes: Count number of available “resources” • Wait for an available resource
(decrement), notify availability (increment) • Example: wait for free buffer space,
signal more buffer space Condition variables •Represent an arbitrary event •
Operations: Wait for event, signal occurrence of event • Tied to a mutex for mutual
exclusion 5 Condition variables Goal: Wait for a specific event to happen • Event
depends on state shared with multiple threads Solution: condition variables • “Names”
an event • Internally, is a queueof threads waiting for the event Basic operations • Wait
for event • Signal occurrence of event to one waiting thread • Signal occurrence of
event to all waiting threads Signaling, not mutual exclusion • Condition variable is
intimately tied to a mutex

41
Program-6
AIM: Implement the command that is used for Creating and Manipulating files
cat,cp,mv,rm,ls and its options,touch and their options,whichis ,whereis, whatis .
1. Cat: This command outputs the contents of a text file. You can use it to read brief
files or to concatenate files together:
• To append file1 onto the end of file2,enter:
Syntax: cat file1>>file2
• To view the contents of a file named myfile, enter:
Syntax: cat myfile

2. Cp command: copies the source file specified by the SourceFile parameter to


the destination file specified by the TargetFile parameter.
Syntax: cp source_file destination

3. Output of the command whatis touch,whereis touch,which touch:

4. rm: Removes files and directories

42
• Syntax:rm[FILE]
• Example:Delete file1:
$rm t1.txt

5. Is: A Linux command has the following basic syntax: ls [ Options ][File]
• Is -a list all files including hidden file starting with '.'.
• Is -1 list with long format - show permissions.
• Is-r list in reverse order.
• Is -t sort by time & date.
• Is -n It is used to print group ID and owner ID instead of their names.
• Is -m A list of entries separated by commas should fill the width.
• Is -g This allows you to exclude the owner and group information

43
1. Touch: It is used to create a file without any content.
• Touch command to create multiple files:
Syntax: touch File1-name File2-name File3-name

2. Cat: The cat command reads each file parameter in sequence and writes it to
standard output.
Syntax: cat file-name

44
Program – 7

AIM: Implement Directory oriented commands:cd,pwd,mkdir,rmdir.

1. mkdir: The mkdir (make directory) command is used to create a new directory.
• To Create a single directory
Syntax: mkdir Directory Name

• To Create a multiple directory


Syntax: mkdir Dir1 Dir2 Dir3

2. Rmdir: The rmdir(remove directory) command is used to delete an empty directory.

• To Delete directory
Syntax: rmdir file

• To Delete multiple directory


Syntax: rmdir file1 file2

45
1. Pwd: The pwd(print working directory) command is used to print out the current
working directory we are in and they all are shell built in.

• Pwd-L Path name of the current directory


• Pwd -P refer to files of type symbolic link.

2. cd command: The cd command can be used to change the working directory


of the working drive or another lettered drive.

Syntax: cd [directory]

46
Program – 8
AIM: Implementing File system commands: Comparing files using diff,cmp,comm
the different ways involved for comparing two files.

1. cmp: This command is used to compare two files character by character.


• Syntax: cmp [options] file1 file2

• Example: Add write permission for user, group and others for filel.

$ cmp file1 file2

2. comm: This command is used to compare two sorted files.


• Syntax: comm [options] file! file2

• One set of options allows selection of 'columns" to suppress.

• Example: Only show column-3 that contains lines common between file! and
file2

• $ comm -12 filel file?

• -1: suppress lines unique to filel (column 1)


• -2: suppress lines unique to file2 (column 2)
• -3: suppress lines common to filel and file2 (column3)

47
3. diff: This command is used to compare two files line by line.
• Description: The output indicates how the lines in each file are different,
and the steps invoved to change d1.txt to d2.txt The 'patch' command
can be used to make the suggested changes. The output is formatted as
blocks of:

48
Program – 9
AIM: File system: Introduction to File system, File system Architecture
and FileTypes.

In a computer, a file system -- sometimes written filesystem -- is the way in


which files are named and where they are placed logically for storage and
retrieval. Without a file system, stored information wouldn't be isolated into
individual files and would be difficult to identify and retrieve. As data
capacities increase, the organization and accessibility of individual files are
becoming even more important in data storage.

Digital file systems and files are named for and modeled after paper- based
filing systems using the same logic-based method of storing and retrieving
documents.

File systems can differ between operating systems (OS), such as


Microsoft Windows, macOS and Linux-based systems. Some file
systems are designed for specific applications. Major types of file
systems includedistributed file systems, disk-based file systems and
special purpose file systems.

How file systems work


A file system stores and organizes data and can be thought of as a type of index
for all the data contained in a storage device. These devices can includehard
drives, optical drives and flash drives.

File systems specify conventions for naming files, including the


maximumnumber of characters in a name, which characters can be used and,
in some systems, how long the file name suffix can be. In many file systems,
file names are not case sensitive.

Along with the file itself, file systems contain information such as the size of the

file, as well as its attributes, location and hierarchy in the directory in the
metadata. Metadata can also identify free blocks of available storage on the
drive and how much space is available.

49
A file system also includes a format to specify the path to a file through the
structure of directories. A file is placed in a directory -- or a folder in
Windows OS
-- or subdirectory at the desired place in the tree structure. PC and mobile
OSes have file systems in which files are placed somewhere in a hierarchical
tree structure.

Before files and directories are created on the storage medium, partitions
shouldbe put into place. A partition is a region of the hard disk or other storage
that theOS manages separately. One file system is contained in the primary
partition, and some OSes allow for multiple partitions on one disk. In this
situation, if onefile system gets corrupted, the data in a different partition will
be safe.

File systems and role of metadata:

• Date created.

• Date modified.

• Last date of access.


• User ID of the file creator.
50
• Access permissions.
• File size.

Metadata is stored separately from the contents of the file, with many file
systems storing the file names in separate directory entries. Some metadata
maybe kept in the directory, whereas other metadata may be kept in a
structure called an inode.

In Unix-like operating systems, an inode can store metadata unrelated to the


content of the file itself. The inode indexes information by number, which
can be used to access the location of the file and then the file itself.

An example of a file system that capitalizes on metadata is OS X, the OS


usedby Apple. It allows for a number of optimization features, including file
namesthat can stretch to 255 characters.

File system access


File systems can also restrict read and write access to a particular group of
users. Passwords are the easiest way to do this. Along with controlling who
canmodify or read files, restricting access can ensure that data modification
is controlled and limited.

File permissions such as access or capability control lists can also be used to
moderate file system access. These types of mechanisms are useful to prevent
access by regular users, but not as effective against outside intruders.

Encrypting files can also prevent user access, but it is focused more on
protecting systems from outside attacks. An encryption key can be applied to
unencrypted text to encrypt it, or the key can be used to decrypt encrypted
text. Only users with the key can access the file. With encryption, the file
system does not need to know the
encryption key to manage the data effectively.

Types of file systems


There are a number of types of file systems, all with different logical
51
structuresand properties, such as speed and size. The type of file system can
differ by OSand the needs of that OS. The three most common PC
operating systems are Microsoft Windows, Mac OS X and Linux. Mobile
OSes include Apple iOS and Google Android.
Major file systems include the following:

File allocation table (FAT) is supported by the Microsoft Windows OS.


FAT is considered simple and reliable, and it is modeled after legacy file
systems. FAT was designed in 1977 for floppy disks, but was later adapted
for hard disks. While efficient and compatible with most current OSes, FAT
cannot match the performance and scalability of more modern file systems.

Global file system (GFS) is a file system for the Linux OS, and it is a
shared disk file system. GFS offers direct access to shared block storage
and can be used as a local file system.
GFS2 is an updated version with features not included in the original GFS,
such as an updated metadata system. Under the terms of the GNU General
Public License, both the GFS and GFS2 file systems are available as free
software.
Hierarchical file system (HFS) was developed for use with Mac operating
systems. HFS can also be referred to as Mac OS Standard, and it wassucceeded
by Mac OS Extended. Originally introduced in 1985 for floppy andhard disks,
HFS replaced the original Macintosh file system. It can also be used on CD-
ROMs.

The NT file system -- also known as the New Technology File System(NTFS
- is the default file system for Windows products from Windows NT
3.1 OS onward. Improvements from the previous FAT file system include
better metadata support, performance and use of disk space. NTFS is also
supported in the Linux OS through a free, open-source NTFS driver. Mac
OSes have read- only support for NTFS.
Universal Disk Format (UDF) is a vendor-neutral file system used on optical
media and DVDs. UDF replaces the ISO 9660 file system and is the official
file system for DVD video and audio as chosen by the DVD Forum.

File system vs. DBMS


Like a file system, a database management system (DBMS) efficiently stores
52
data that can be updated and retrieved. The two are not interchangeable,
however. While a file system stores unstructured, often unrelated files, a
DBMS is used to store and manage structured, related data.
A DBMS creates and defines the restraints for a database. A file system
allows access to single files at a time and addresses each file individually.
Because of this, functions such as redundancy are performed on an
individual level, not bythe file system itself. This makes a file system a much
less consistent form of data storage than a DBMS, which maintains one
repository of data that is defined once.

The centralized structure of a DBMS allows for easier file sharing than a file
system and prevents anomalies that can occur when separate changes are
made to files in a file system.

There are methods to protect files in a file system, but for heavy-duty security,
a DBMS is the way to go. Security in a file system is determined by the OS,
andit can be difficult to maintain over time as files are accessed and
authorization is granted to users.

A DBMS keeps security constraints high, relying on password protection,


encryption and limited authorization. More security does result in more
obstacles

when retrieving data, so in terms of general, simple-to-use file storageand


retrieval, a file system may be preferred.

File systems definition evolves


While previously referring to physical, paper files, the term file system was
usedto
refer to digital files as early as 1961. By 1964, it had entered general use to
refer to computerized file systems.

The term file system can also refer to the part of an OS or an add-on
program that supports a file system. Examples of such add-on file systems
include the Network File System (NFS) and the Andrew File System
(AFS).
In addition, the term has evolved to refer to the hardware used for nonvolatile storage, the software application
that controls the hardware and architecture of both hardware and software

53
Program –10
Aim: Mass Storage structure :Overview, Disk structure, Disk Attachment, Disk
Scheduling, Disk Management.

Solution:

Mass Storage Structure Overview:

The two types of memories are :

1) Primary Memory
A processor or computer initially or directly accesses primary memory while using a
computer. It enables a processor to access programs and services that are now in use
and temporarily stored in a particular area of memory. An operating system (OS),
user interface, and any user-installed and running software utilities are all loaded into
main memory as soon as a computer turns on.

2) Secondary Memory
Secondary memory is non-volatile, permanent computer memory that is not directly
accessible by a computer or processor. Data that can be quickly and easily retrieved,
transmitted, and utilized by apps and services can be stored by the user and then used
in this manner. Read-only memory (ROM), flash drives, hard disk drives (HDD),
magnetic tapes, and other forms of internal and external storage media are all
considered secondary memory.

The basic idea of Mass Storage is to create a Data Backup or Data Recovery System. The
Mass Storage Structure Devices are:

1. Magnetic Disks
2. Solid State Disks
3. Magnetic Tapes

Disk Structure
Disk structure in operating system refers to the physical and logical arrangement of data on
a hard disk drive. The physical structure of a hard disk drive consists of one or more
surfaces, each of which contains several tracks, each of which is divided into sectors. The
logical structure of a hard disk drive is divided into partitions, which are treated by the
operating system as separate disks.

Hard disk is organized into two different ways like as physical structure and logical
structure; below shown each one in detail, you can check them:
• Physical Structure of Hard Disk
The physical division of a hard disk refers to the way data is stored on the disk at a low
level. Here are the main parts of the physical structure of hard disk, including:

Platters: The disks that make up the hard disk drive. Each platter has an upper and lower
oxide-coated surface.

Read/Write Heads: The heads that float above the surface of the platters and read and
write data as the platters spin around. There is at least one head per surface.

Tracks: The concentric circles on the surface of the platters. Each track is divided into
sectors.

Sectors: The smallest physical storage units on the disk. Sectors are the unit of information
transfer and are mapped with a logical block on the disk.

Cylinders: The set of tracks that have the same track value on all platters. A cylinder is
made up of rings on the upper and lower surfaces of all of the platters.

Spindle: Help to connects all the platters and is connected to a motor. The motor of the
spindle rotates with a constant speed, causing the disk platter to spin at a constant speed.

Arm Assembly: It holds the read/write heads. The arm assembly is moved in or out to
position a head on a desired track.

• Logical Structure of Hard Disk


The logical division of a hard disk refers to the way data is organized and stored on the disk.
Here are the main components of the logical structure of hard disk, as following them:

Master Boot Record (MBR): The MBR contains a small program to load and start the
active (or bootable) partition from the hard disk drive. The MBR contains information about
all four primary partitions on the hard disk drive such as the starting sector, ending sector,
size of the partition, etc.

DOS Boot Record (DBR): The DBR is the first sector of a partition and contains the boot
loader code that is executed when the partition is booted.

File Allocation Table (FAT): The FAT is a table that keeps track of which clusters are free
and which are in use. It is used by the file system to locate files on the disk.

Root Directory: The root directory is the top-level directory on a disk. It contains all the
files and directories that are stored directly on the disk.

Clusters: A cluster is a group of sectors that are allocated to a file. Clusters are used by the
file system to read and write data.

Disk Attachment
The disk attachment is a special feature that allows you to attach a disk (such as a USB
flash drive) to your computer’s hard drive. Users can use this feature to store files in the
cloud or transfer files between computers on their network. This can be done in number of
ways like:
1) Host-Attached Storage
Host-attached storage (HAS) is a form of internal computer storage that can be
attached to a host computer, such as a PC or server. Host-attached devices are often
used for backup purposes and can include tape drives, optical drives, hard disk drives
(HDDs), solid state drives (SSDs), USB flash drives, and other similar media.

2) Network-Attached Storage (NAS)


A Network-Attached Storage (NAS) is a computer that is connected to a network and
shared by multiple users. NAS can also be called a file server, or storage appliance.
The term “storage” refers to any device that stores data; this includes hard drives and
flashes memory modules.

3) Storage Area Network (SAN)


Storage area networks (SAN) are a network of storage devices that can be used to
store and retrieve data from a shared central repository. A SAN is usually used for
large data storage and retrieval, which requires high availability, scalability,
reliability, and performance. The most common type of SAN uses fiber channel
adapters to connect the host with its disk arrays.

Disk Scheduling
Disk scheduling is done by operating systems to schedule I/O requests arriving for the disk.
Disk scheduling is also known as I/O Scheduling.

Programs in C language to implement Disk Scheduling algorithms (FCFS (First Come First
Serve), SSTF (Shortest Seek Time First), SCAN (Elevator Algorithm) and C-SCAN
(Circular SCAN)).

Program Code:

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define MAX_REQUESTS 100

// Function to implement FCFS Disk Scheduling Algorithm


void fcfs(int head, int requests[], int n) {
printf("\nFCFS Disk Scheduling:\n");
int total_seek_time = 0;

// Calculate total seek time


for (int i = 0; i < n; i++) {
total_seek_time += abs(head - requests[i]);
head = requests[i];
}

// Output total seek time


printf("Total Seek Time: %d\n", total_seek_time);
}

// Function to implement SSTF Disk Scheduling Algorithm


void sstf(int head, int requests[], int n) {
printf("\nSSTF Disk Scheduling:\n");
int total_seek_time = 0;
int visited[MAX_REQUESTS] = {0};

// Find nearest request in each step


for (int i = 0; i < n; i++) {
int min_distance = INT_MAX;
int min_index = -1;
for (int j = 0; j < n; j++) {
if (!visited[j]) {
int distance = abs(head - requests[j]);
if (distance < min_distance) {
min_distance = distance;
min_index = j;
}
}
}
total_seek_time += min_distance;
head = requests[min_index];
visited[min_index] = 1;
}

// Output total seek time


printf("Total Seek Time: %d\n", total_seek_time);
}

// Function to implement SCAN Disk Scheduling Algorithm (Elevator Algorithm)


void scan(int head, int requests[], int n, int max_cylinder) {
printf("\nSCAN (Elevator Algorithm) Disk Scheduling:\n");
int total_seek_time = 0;
int direction = 1; // 1: Moving towards higher cylinders, -1: Moving towards lower cylinders

// Sort requests
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (requests[j] > requests[j + 1]) {
int temp = requests[j];
requests[j] = requests[j + 1];
requests[j + 1] = temp;
}
}
}

// Find the index where head is present


int index;
for (index = 0; index < n; index++) {
if (head < requests[index])
break;
}

// Move head to the end of the queue in the direction it was moving
if (direction == 1)
total_seek_time += max_cylinder - head;
else
total_seek_time += head;

// Reverse direction
direction = -direction;

// Scan in the opposite direction


for (int i = index; i < n && i >= 0; i += direction) {
total_seek_time += abs(head - requests[i]);
head = requests[i];
}

// Output total seek time


printf("Total Seek Time: %d\n", total_seek_time);
}

// Function to implement C-SCAN Disk Scheduling Algorithm (Circular SCAN)


void cscan(int head, int requests[], int n, int max_cylinder) {
printf("\nC-SCAN (Circular SCAN) Disk Scheduling:\n");

int total_seek_time = 0;
int direction = 1; // 1: Moving towards higher cylinders, -1: Moving towards lower cylinders

// Sort requests
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (requests[j] > requests[j + 1]) {
int temp = requests[j];
requests[j] = requests[j + 1];
requests[j + 1] = temp;
}
}
}

// Find the index where head is present


int index;
for (index = 0; index < n; index++) {
if (head < requests[index])
break;
}

// Move head to the end of the queue in the direction it was moving
if (direction == 1)
total_seek_time += max_cylinder - head;
else
total_seek_time += head;

// Move head to the beginning of the queue


total_seek_time += max_cylinder;

// Output total seek time


printf("Total Seek Time: %d\n", total_seek_time);
}

int main() {
int head, n, max_cylinder;

// Input head position


printf("Enter the initial head position: ");
scanf("%d", &head);

// Input maximum cylinder number


printf("Enter the maximum cylinder number: ");
scanf("%d", &max_cylinder);

// Input number of requests


printf("Enter the number of disk requests: ");
scanf("%d", &n);

// Input disk requests


int requests[MAX_REQUESTS];
printf("Enter the disk requests: ");
for (int i = 0; i < n; i++)
scanf("%d", &requests[i]);

// Perform FCFS Disk Scheduling


fcfs(head, requests, n);

// Perform SSTF Disk Scheduling


sstf(head, requests, n);

// Perform SCAN Disk Scheduling


scan(head, requests, n, max_cylinder);

// Perform C-SCAN Disk Scheduling


cscan(head, requests, n, max_cylinder);

return 0;
}

Output :

Disk Management

The operating system is responsible for various operations of disk management. Modern
operating systems are constantly growing their range of services and add-ons, and all
operating systems implement four essential operating system administration functions.
These functions are as follows:

1) Process Management
2) Memory Management
3) File and Disk Management
4) I/O System Management

Disk management of the operating system includes:


1) Disk Format
2) Booting from disk
3) Bad block recovery

Advantages of disk management include:


1) Improved organization and management of data.
2) Efficient use of available storage space.
3) Improved data integrity and security.
4) Improved performance through techniques such as defragmentation.

Disadvantages of disk management include:


1) Increased system overhead due to disk management tasks.
2) Increased complexity in managing multiple partitions and file systems.
3) Increased risk of data loss due to errors during disk management tasks.
4) Overall, disk management is an essential aspect of operating system management and
can greatly improve system performance and data integrity when implemented
properly.

You might also like