EXPERIMENT 1
Aim-: Study of hardware and software requirements of different operating
systems(UNIX, LINUX, WINDOWS XP, WINDOWS7/8.
OPERATING SYSTEM
An operating system acts as an interface between the software and different parts of the computer or
the computer hardware. The operating system is designed in such a way that it can manage the overall
resources and operations of the computer. It is a fully integrated set of specialized programs that handle
all the operations of the computer.
TYPES OF OPERATING SYSTEM
● Windows
● Linux
● Unix
COMPARATIVE ANANYSIS OF VARIOUS OS
Parameters Windows Linux Unix
Cost Less Costly Free More Costly
Ease of use Easy to use Littly difficult for first Easy to use
time user
Security More prone to attack More vulnerable than Less prone to attacks
Unix but less than
Windows
Gaming More games are Less games are present Less games are present
present.
Development and Developed and Linux is open sourced Most of Unix system are
Distribution distributed by Microsoft and distributed by developed by AT&T with
various vendors other commercial
vendors and non profit
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
organization.
ADVANTAGES AND DISADVANTAGES OF VARIOUS OPERATING SYSTEM
1. WINDOWS
Advantages
● User friendly interface and easy to use
● Compatible to all hardware
● Support plug and play feature
● Provide software Development support
● Have both Desktop and touch screen support
Disadvantages
● Security Concerns
● Paid software
● Infection assults
● Rebooting a framework
● High Performance System Required
2. LINUX
Advantages
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
● Open Source
● No antivirus software needed
● Low system specifications
● No reboot needed for installing/uninstalling
● Less disk space needed
Disadvantages
● Software compatibility
● Gaming
● Limited software Availability
● Hardware Compatibility
● Learning curve
3. UNIX
Advantages
● Very stable
● Less code to execute
● Ideal for web hosting
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
● Safe and secure
● Multitasking
Disadvantages
● Not user friendly
● Cryptic commands
● Gaming
● Less softwares are available
● Software Compatibility
HARDWARE AND SOFTWARE MINIMUM REQUIREMENTS
1 WINDOWS 10
● Processor: 1 Gigahertz (GHz) or faster processor.
● RAM: 1 gigabyte (GB) for 32-bit OS or 2GB for 64-bit OS.
● Hard disk Space: 16 Gb for 32-bit OS or 20GB for 64-bit OS.
2 Windows XP
● Pentium 233 MHz processor or faster.
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
● At least 64 MB of RAM (128 MB is recommended).
● At least 1.5 GB of available space.
3 LINUX
● 32-bit Intel-compatible processor running at 2GHz or greater.
● 512 MB RAM
● Disk space- 2.5 Gb for pipeline Pilot server plus components
● A DVD –ROM drive
4 UNIX
● RAM:1 GB
● Processor: IBM 604e processor with a clock speed of 375 MHz or faster
● Disk space: 1GB free disk space
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
EXPERIMENT 2
Aim-: Execute various UNIX system calls for
i. Process management
ii. File management
iii. Input/output Systems calls
COMMONLY USED UNIX SYSTEM CALLS FOR PROCESS MANAGEMENT:
● fork(): Creates a new process by duplicating the existing process.
● wait(): Suspends the execution of the current process until one of its child processes terminates.
● waitpid(): Suspends the execution of the current process until a specific child process
terminates.
● waitid(): Suspends the execution of the current process until a specific child process or group of
child processes terminates.
● exit(): Terminates the current process and returns the exit status to the parent process.
● kill(): Sends a signal to a specified process.
● getpid(): Returns the process ID (PID) of the current process.
● getppid(): Returns the PID of the parent process of the current process.
● getpgrp(): Returns the process group ID of the current process.
● setpgid(): Sets the process group ID of a process.
● setsid(): Creates a new session and sets the process group ID.
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
● nice(): Modifies the priority of a process.
● setpriority(): Sets the priority of a process.
● getpriority(): Gets the priority of a process.
● sched_yield(): Yields the processor to other processes.
● getrusage(): Gets resource usage statistics for the current or child processes.
● times(): Gets the current process and system times.
● getrlimit(): Gets the resource limits for the current process.
● setrlimit(): Sets the resource limits for the current process.
COMMONLY USED UNIX SYSTEM CALLS FOR FILE MANAGEMENT:
● open(): Opens a file or creates a new file if it doesn't exist.
● close(): Closes a file descriptor.
● read(): Reads data from a file.
● write(): Writes data to a file.
● lseek(): Changes the file offset (position) within a file.
● unlink(): Deletes a file.
● rename(): Renames a file.
● chmod(): Changes the permissions of a file.
● chown(): Changes the owner and group of a file.
● mkdir(): Creates a new directory.
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
● rmdir(): Deletes an empty directory.
● opendir(): Opens a directory for reading.
● readdir(): Reads the next directory entry.
● closedir(): Closes a directory.
● link(): Creates a hard link to a file.
● symlink(): Creates a symbolic (soft) link to a file.
● readlink(): Reads the value of a symbolic link.
● chdir(): Changes the current working directory.
● getcwd(): Gets the current working directory.
COMMONLY USED UNIX SYSTEM CALLS FOR INPUT/OUTPUT SYSTEM
CALL:
● open(): Opens a file or creates a new file if it doesn't exist.
● close(): Closes a file descriptor.
● read(): Reads data from a file descriptor.
● write(): Writes data to a file descriptor.
● ioctl(): Performs device-specific input/output operations (e.g., configuring a serial port).
● select(): Monitors multiple file descriptors for read/write/exception events.
● poll(): Polls multiple file descriptors for events.
● recv() and send(): Receives and sends data over a network socket.
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
● socket(): Creates a new network socket.
● bind(): Associates a socket with a local address.
● listen(): Puts a socket into a passive listening mode.
● accept(): Accepts an incoming network connection on a listening socket.
● connect(): Initiates a connection to a remote network address.
● shutdown(): Shuts down all or part of a network connection.
● pipe(): Creates an interprocess communication (IPC) pipe.
● dup() and dup2(): Duplicates a file descriptor.
● fsync(): Flushes changes to a file to disk.
● ftruncate(): Truncates a file to a specified size.
● pread() and pwrite(): Reads and writes data at a specific offset within a file.
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
EXPERIMENT 3.1
Aim-: Implement FCFS CPU Scheduling:
PROGRAM
#include <stdio.h>
int main()
{ int i,n;
printf("p no.= process number\t at=arrival time\t bt=Burst time\t ct=Completion time\t tat=Turn
around time\t wt=waiting time\n");
printf("enter total number of process = ");
scanf("%d",&n);
int p[15];
int at[15];
int bt[15];
printf("enter the arrival time in sorted order\n");
for(i=1;i<(n+1);i++)
printf("enter arrival time of p%d = ",i);
scanf("%d",&at[i]);
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
}
for(i=1;i<(n+1);i++)
printf("enter Burst time of p%d = ",i);
scanf("%d",&bt[i]);
int ct[15];
ct[0]=0;
for(i=1;i<(n+1);i++)
ct[i]=ct[i-1]+bt[i];
int tat[15];
for(i=1;i<(n+1);i++)
tat[i]=ct[i]-at[i];
int wt[15];
for(i=1;i<(n+1);i++)
wt[i]=tat[i]-bt[i];
float avgtat,avgwt;
avgtat=0.0;
avgwt=0.0;
for(i=1;i<(n+1);i++)
avgtat=avgtat+tat[i];
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
}
for(i=1;i<(n+1);i++)
avgwt=avgwt+wt[i];
avgtat=avgtat/n;
avgwt=avgwt/n;
printf("p no.\tat\tbt\tct\ttat\twt\n");
for(i=1;i<(n+1);i++)
printf("p%d\t%d\t%d\t%d\t%d\t%d\n",i,at[i],bt[i],ct[i],tat[i],wt[i]);
printf("average Turn around time:%f\n",avgtat);
printf("average Waiting time:%f",avgwt);
return 0;
OUTPUT
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
EXPERIMENT 3.2(a)
Aim-: Implement SJF CPU Scheduling:
SJF SCHEDULING
PROGRAM
#include<stdio.h>
int main() {
int time, burst_time[10], at[10], sum_burst_time = 0, smallest, n, i;
int sumt = 0, sumw = 0;
printf("enter the no of processes : ");
scanf("%d", & n);
for (i = 0; i < n; i++) {
printf("the arrival time for process P%d : ", i + 1);
scanf("%d", & at[i]);
printf("the burst time for process P%d : ", i + 1);
scanf("%d", & burst_time[i]);
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
sum_burst_time += burst_time[i];
burst_time[9] = 9999;
for (time = 0; time < sum_burst_time;) {
smallest = 9;
for (i = 0; i < n; i++) {
if (at[i] <= time && burst_time[i] > 0 && burst_time[i] < burst_time[smallest])
smallest = i;
printf("P[%d]\t|\t%d\t|\t%d\n", smallest + 1, time + burst_time[smallest] - at[smallest], time -
at[smallest]);
sumt += time + burst_time[smallest] - at[smallest];
sumw += time - at[smallest];
time += burst_time[smallest];
burst_time[smallest] = 0;
printf("\n\n average waiting time = %f", sumw * 1.0 / n);
printf("\n\n average turnaround time = %f", sumt * 1.0 / n);
return 0;
OUTPUT
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
EXPERIMENT 3.2(b)
Aim-: Implement SJF CPU Scheduling:
SRTF SCHEDULING
PROGRAM
#include <stdio.h>
int main()
int a[10],b[10],x[10],i,j,smallest,count=0,time,n;
double avg=0,tt=0,end;
printf("enter the number of Processes:\n");
scanf("%d",&n);
printf("enter arrival time\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter burst time\n");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
for(i=0;i<n;i++)
x[i]=b[i];
b[9]=9999;
for(time=0;count!=n;time++)
smallest=9;
for(i=0;i<n;i++)
if(a[i]<=time && b[i]<b[smallest] && b[i]>0 )
smallest=i;
b[smallest]--;
if(b[smallest]==0)
count++;
end=time+1;
avg=avg+end-a[smallest]-x[smallest];
tt= tt+end-a[smallest];
printf("\n\nAverage waiting time = %lf\n",avg/n);
printf("Average Turnaround time = %lf",tt/n);
return 0;
OUTPUT
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
EXPERIMENT 3.3(a)
Aim-: Implement PRIORITY CPU Scheduling:
PRIORITY SCHEDULING(non preemptive)
PROGRAM
#include <stdio.h>
void swap(int *a,int *b)
int temp=*a;
*a=*b;
*b=temp;
int main()
int n;
printf("Enter Number of Processes: ");
scanf("%d",&n);
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
int burst[n],priority[n],index[n];
for(int i=0;i<n;i++)
printf("Enter Burst Time and Priority Value for Process %d: ",i+1);
scanf("%d %d",&burst[i],&priority[i]);
index[i]=i+1;
for(int i=0;i<n;i++)
int temp=priority[i],m=i;
for(int j=i;j<n;j++)
if(priority[j] > temp)
temp=priority[j];
m=j;
swap(&priority[i], &priority[m]);
swap(&burst[i], &burst[m]);
swap(&index[i],&index[m]);
int t=0;
printf("Order of process Execution is\n");
for(int i=0;i<n;i++)
printf("P%d is executed from %d to %d\n",index[i],t,t+burst[i]);
t+=burst[i];
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
}
printf("\n");
printf("Process Id\tBurst Time\tWait Time\n");
int wait_time=0;
int total_wait_time = 0;
for(int i=0;i<n;i++)
printf("P%d\t\t%d\t\t%d\n",index[i],burst[i],wait_time);
total_wait_time += wait_time;
wait_time += burst[i];
float avg_wait_time = (float) total_wait_time / n;
printf("Average waiting time is %f\n", avg_wait_time);
int total_Turn_Around = 0;
for(int i=0; i < n; i++){
total_Turn_Around += burst[i];
float avg_Turn_Around = (float) total_Turn_Around / n;
printf("Average
TurnAround Time is
%f",avg_Turn_Around);
return 0;
OUTPUT
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
EXPERIMENT 3.3(b)
Aim-: Implement PRIORITY CPU Scheduling:
PRIORITY SCHEDULING(Preemptive)
PROGRAM
#include<stdio.h>
struct process
int WT,AT,BT,TAT,PT;
};
struct process a[10];
int main()
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
int n,temp[10],t,count=0,short_p;
float total_WT=0,total_TAT=0,Avg_WT,Avg_TAT;
printf("Enter the number of the process\n");
scanf("%d",&n);
printf("Enter the arrival time , burst time and priority of the process\n");
printf("AT BT PT\n");
for(int i=0;i<n;i++)
scanf("%d%d%d",&a[i].AT,&a[i].BT,&a[i].PT);
// copying the burst time in
// a temp array fot futher use
temp[i]=a[i].BT;
// we initialize the burst time
// of a process with maximum
a[9].PT=10000;
for(t=0;count!=n;t++)
short_p=9;
for(int i=0;i<n;i++)
if(a[short_p].PT>a[i].PT && a[i].AT<=t && a[i].BT>0)
short_p=i;
a[short_p].BT=a[short_p].BT-1;
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
// if any process is completed
if(a[short_p].BT==0)
// one process is completed
// so count increases by 1
count++;
a[short_p].WT=t+1-a[short_p].AT-temp[short_p];
a[short_p].TAT=t+1-a[short_p].AT;
// total calculation
total_WT=total_WT+a[short_p].WT;
total_TAT=total_TAT+a[short_p].TAT;
Avg_WT=total_WT/n;
Avg_TAT=total_TAT/n;
// printing of the answer
printf("ID WT TAT\n");
for(int i=0;i<n;i++)
printf("%d %d\t%d\n",i+1,a[i].WT,a[i].TAT);
printf("Avg waiting time of the process is %f\n",Avg_WT);
printf("Avg turn around time of the process is %f\n",Avg_TAT);
return 0;
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
}
OUTPUT
EXPERIMENT 3.4
Aim-: Implement ROUND ROBIN CPU Scheduling:
PROGRAM
#include<stdio.h>
int main()
{ printf("ENTER THE PROCESS IN ASCENDING ORDER WITH RESPECT TO ARRIVAL TIME");
int i, limit, total = 0, x, counter = 0, time_quantum;
int wait_time = 0, turnaround_time = 0, arrival_time[10], burst_time[10], temp[10];
float average_wait_time, average_turnaround_time;
printf("\nEnter Total Number of Processes:\t");
scanf("%d", &limit);
x = limit;
for(i = 0; i < limit; i++)
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
printf("\nEnter Details of Process[%d]\n", i + 1);
printf("Arrival Time:\t");
scanf("%d", &arrival_time[i]);
printf("Burst Time:\t");
scanf("%d", &burst_time[i]);
temp[i] = burst_time[i];
printf("\nEnter Time Quantum:\t");
scanf("%d", &time_quantum);
printf("\nProcess ID\t\tBurst Time\t Turn around Time\t Waiting Time\n");
for(total = 0, i = 0; x != 0;)
if(temp[i] <= time_quantum && temp[i] > 0)
total = total + temp[i];
temp[i] = 0;
counter = 1;
else if(temp[i] > 0)
temp[i] = temp[i] - time_quantum;
total = total + time_quantum;
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
}
if(temp[i] == 0 && counter == 1)
x--;
printf("\nProcess[%d]\t\t%d\t\t %d\t\t\t %d", i + 1, burst_time[i], total - arrival_time[i], total -
arrival_time[i] - burst_time[i]);
wait_time = wait_time + total - arrival_time[i] - burst_time[i];
turnaround_time = turnaround_time + total - arrival_time[i];
counter = 0;
if(i == limit - 1)
i = 0;
else if(arrival_time[i + 1] <= total)
i++;
else
i = 0;
average_wait_time = wait_time * 1.0 / limit;
average_turnaround_time = turnaround_time * 1.0 / limit;
printf("\n\nAverage Waiting Time:\t%f", average_wait_time);
printf("\nAvg Turn around Time:\t%f\n", average_turnaround_time);
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131
return 0;
OUTPUT
Operating System Lab(KCS-451) PRASHANT YADAV 2100910100131