Uma Doc Os
Uma Doc Os
Uma Doc Os
EXPERIMENT -1
Developmen Developed and Linux is Open Mac OS was Unix system OHA (Open Apple Inc.
t distributed by Sourced and designed has Handset developed
and Microsoft. distributed by only to be various Alliance) and
Distribution various deployed by flavors, most distributed
vendors. Apple of iOS
Computers. which are
developed by
AT&T with
other
commercial
vendors
and non-profit
orgs
File System NTFS, FAT & ext2, ext3, HFS+, HFS, jfs, gpfs, hfs, Ext4 HFS+, FTP
Supported exFAT with ex4,ReiserFS,FAT MFS (Mac hfs+, ufs,
ISO , OS 8.0 and xfs, zfs format
9660; UDF, ISO 9660,UDF, before) AFP,
rd NFS, with ISO
3
and others 9660, FAT,
Party driver UDF
that
supports file
system
ext2, and ext3,
ReiserFS, and
HFS
User Very User Depends on Very User Unix is Very User Very User
Friendly Friendly Distribution. Friendly user-friendly. Friendly Friendly
for Lay More It's just
Users friendlier to users choosy about
Kernel Type Hybrid Monolithic with Monolithic Monolithic Linux kernel XNU kernel;
modules with with of Darwin
modules modules
Compatibili Can coexist on Linux has few Only few Unix does not Better than Compatibility
ty local programs and programs have as iOS is fair
networks with games will run on many
Windows, BSD, like Windows. Mac programs and
Macs, and other But is games as
Unix-like more compatible Windows
systems. and
More scalable than
compatible. Unix
Examples Early versions Fedora, Debian, ● ac OS X 10.0. 4 IBM AIX, Android 11 iOS 10
Red Hat, Ubuntu, Darwin, Solaris, Android 10
(Windows NT Cheetah. iOS 11
3.1/3.5/3.51/4.0/2 Android, etc HP-UX, macOS
● Mac OS X 10.1. 5
X, etc. iOS 12
000) Puma.
● Windows XP.
iOS 13
● Mac OS X 10.2. 8
Jaguar.
iOS 14
Windows Vista.
iOS 15
● Windows 7. ● Mac OS X 10.3. 9
Panther. iOS 16
Windows 8 and iOS 17
8.1. Mac OS X 10.4. 11
Tiger.
● Windows 10.
● Mac OS X 10.5. 8
● Windows 11.
Leopard.
● Mac OS X 10.6. 8
Snow Leopard.
OS X 10.7. 5 Lion.
EXPERIMENT -2
1. access():
The access() function in Unix is a system call that is used to check whether the calling
process can access a particular file or directory with the specified permissions. It takes
two arguments: a pointer to a character string that contains the name of the file or
directory to be checked, and an integer representing the mode of access that is being
checked.
Eg . access(filename,R_OK);
2. chdir():
In Unix-like operating systems, the chdir() system call is used to change the current
working directory of a process. The chdir() function is defined in the <unistd.h> header
file and takes a single argument, which is a string specifying the path to the new working
directory. the new path can be specified as an absolute path or a relative path.
Eg. chdir(“/user/bin”)
3. chmod():
In Unix-like operating systems, the chmod() , is a command used to change the
permission (ie. read, write, execute) on a file or directory . The name chmod stands for “
changes in mode”.
The chmod() uses three-digit code to specify the new permission for a file or directory.
Each digit represents the permission for a different user or group.
Eg chmod(755,myfile)
4. chown():
In a UNIX-like operating system, chown() is a command used to change the owner and or
group of a file or directory. The name Chown stands for “change owner”.
The chown() command takes two arguments: the new owner and or group and the name
of the file or directory to be modified. The new owner and or group can be specified
using a username or numeric ID (UID), a group name, or a numeric group ID (GID).
5. kill():
In a UNIX-like operating system , kill() is a command used to send a signal to a process,
requesting that it terminate or perform some other actions.
Eg. kill(91734)
6. link():
In Unix-like operating systems, the link() function is used to create a hard link between
two files. A hard link is a way to associate a new name link with an existing file on the
filesystem , without creating a new copy of the file’s contents.
7. stime():
In Unix-like operating systems , the stime() function is used to set the system time . the
functions takes a pointer to a time_t value that specifies the new system time.
8. open():
In Unix-like operating systems , the open() function is used to open a file and obtain a file
descriptor , which is a small integer that represents the file in the kernel’s internal tables .
9. times():
In Unix-like operating systems , the times() function is used to get process and system
times . The functions return the elapsed real time since some points in the past , as well as
the amount of CPU time used by the calling process and its children.
10. link():
In Unix-like operating systems, the link() function is used to create a hard link between
two files. A hard link is a way to associate a new name link with an existing file on the
filesystem , without creating a new copy of the file’s contents.
EXPERIMENT -3(a)
Code:
#include<stdio.h>
void findWaitingTime(int processes[], int n, int bt[], int wt[])
{
wt[0] = 0;
for (int i = 1; i < n ; i++ )
wt[i] = bt[i-1] + wt[i-1] ;
}
void findTurnAroundTime( int processes[],int n, int bt[], int wt[])
OUTPUT:
Processes BurstTime WaitingTime TurnAroundTime
1 10 0 10
2 5 10 15
3 8 15 23
Average waiting time = 8.333333
Average turn around time = 16.000000
EXPERIMENT -3(b)
#include <stdio.h>
int main()
{
int A[100][4];
int i, j, n, total = 0, index, temp;
float avg_wt, avg_tat;
printf("Enter number of process: ");
scanf("%d", &n);
printf("Enter Burst Time:\n");
OUTPUT:
EXPERIMENT -3(c)
Step 3: For each process in the ready Q, assign the process ID and accept the CPU burst time
Step 5: Set the waiting of the first process as ‘0’ and its burst time as its turnaround time.
Step 7: Calculate
A. Average waiting time = Total waiting Time / Number of processes
B. Average Turnaround time = Total Turnaround Time / Number of processes
Code:
#include <conio.h>
#include <stdio.h>
void main() {
int i, j, n, tat[10], wt[10], bt[10], pid[10], pr[10], t, twt = 0, ttat = 0;
float awt, atat;
clrscr();
printf("\n-----------PRIORITYSCHEDULING--------------\n");
printf("Enter the No of Process: ");
scanf("%d", &n);
for (i = 0; i < n; i++) {
pid[i] = i;
printf("Enter the Burst time of Pid %d : ", i);
scanf("%d", &bt[i]);
printf("Enter the Priority of Pid %d : ", i);
scanf("%d", &pr[i]);
}
// Sorting start
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++) {
if (pr[i] > pr[j]) {
t = pr[i];
pr[i] = pr[j];
pr[j] = t;
t = bt[i];
bt[i] = bt[j];
bt[j] = t;
t = pid[i];
pid[i] = pid[j];
pid[j] = t;
}
}
// Sorting finished
tat[0] = bt[0];
wt[0] = 0;
for (i = 1; i < n; i++) {
wt[i] = wt[i - 1] + bt[i - 1];
tat[i] = wt[i] + bt[i];
}
printf(“n-- ------------------------------------------------------------------”);
printf("Pid\t Priority\tBurst time\tWaitingTime\tTurnArroundTime\n");
printf(“n-- ------------------------------------------------------------------”);
for (i = 0; i < n; i++) {
printf("\n%d\t\t%d\t%d\t\t%d\t\t%d", pid[i], pr[i], bt[i], wt[i], tat[i]);
}
for (i = 0; i < n; i++) {
ttat = ttat + tat[i];
twt = twt + wt|i];
}
awt = (float)twt / n;
atat = (float)ttat / n;
printf("\n\nAvg.Waiting Time: %nAvg.Turn Around Time: %fAn", , awt, atat);
getch();
}
OUTPUT:
-----—--------PRIORITY SCHEDULING------—-------
EXPERIMENT -3(d)
Step 2: Accept the number of processes in the ready Queue and time quantum (or) time slice.
Step 3: For each process in the ready Q, assign the process id and accept the CPU burst time.
Step 4: Calculate the no. of time slices for each process where
Step 5: If the burst time is less than the time slice then the no. of time slices =1.
(a) Waiting time for process(n) = waiting time of process(n-1)+ burst time of process(n-1) +
the time difference in getting the CPU from process(n-1)
(b) Turn around time for process(n) = waiting time of process(n) + burst time of
process(n)+ the time difference in getting CPU fromprocess(n).
Step 7: Calculate
Step 8: Stop
Code:
#include <conio.h>
#include <stdio.h>
intz[10], b[10], n, m[50], r, q, e = 0, avg = 0, i, j;
Float f;
main() {
cIrscr();
printf("\n\tJOB SCHEDULING ALGORITHM[RR]");
printf(
"'nlt*******************************************************/n"); printf(
"\nEnter how many jobs:");
scanf("%d", &n);
printf(" \nEnter burst time for corresponding job... \n");
for (i = 1; i <= n; i++) {
printf("\nProcess %d: ", i);
scanf("@d", &b[il);
z[i]=b[il;
printf("\ nENTER THE TIME SLICE VALUE:");
scanf("/d", &q);
rr);
average);
getch);
return 0;
}
rr()
{
int max = 0;
max = b[1];
for (j = 1; j <= n; j++)
if(max<=b[jl)
max=b[j];
if ((max % q) == 0)
r = (max / q);
else
r = (max / q) + 1;
for (i = 1; i <= r; i++) {
printf("\nround %d", i);
for(j = 1; <= n;
j++ ) if (b[j] > 0) {
bll=b[jl-q;
if(b[jl=0)
{
bljl = 10 printf("\nprocess %d is completed", j);
}
else
printf("\process %d remaining time is %d", j,b[jl);
}
}
return 0;
delay(1000);
average)
{
for (i = 1; i <= n; i++) e = 0;
for (j = 1; j <= r; j++) {
if (z[i] != 0)
if(z[il>=q)
{
} else m[ite] = q;
z[i] -= q;
m[ite]=z[il;z[il=0;
} else
e = e + n;
m[i + e] = 0;
}
for (i = 2; i <= n; i++)
for (j = 1; j <= i - 1; j++) avg = avg + mil;
for (i = n + 1; i <= r * n; i++) {
if (m[i] != 0)
1
for(j=i-(n-1);j<=i-1;j++)
avg=m[l+avg;
}
f=avg/n;
printf("\nTOTAL WATING:%d"
, avg);
OUTPUT:
Enter the number of Processors 4
Enter the Timeslice 5
Enter the process ID 15
Enter the Burst Time for the process10
Enter the process ID 26
Enter the Burst Time for the process 15
Enter the process ID 37
Enter the Burst Time for the process20
Enter the process ID 48
Enter the Burst Time for the process 25
EXPERIMENT -4
Objective: Write a program to implement Banker's algorithm.
THEORY :
The banker's algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating
the allocation for the predetermined maximum possible amounts of all resources, then makes an "s-state" check to
test for possible activities, before deciding whether allocation should be allowed to continue. Banker's algorithm is
named so because it is used in the banking system to check whether a loan can be sanctioned to a person. Suppose
there are n number of account holders in a bank and the total sum of their money is S. If a person applies for a loan
then the bank subtracts the loan amount from the total cash that bank has and if the remaining amount is greater than
S then only the loan is sanctioned. It is done because if all the account holders come to withdraw their money then
the bank can easily do it.
Code:
#include <stdio.h>
int n, m; // number of processes and resources int available[m]; // available
// resources
int allocation[n][m]; // allocated resources to processes int max|n][m]; //
// maximum resources required by processes
int finish[n]; // finish array
void banker() {
int i, j;
// Initialize finish array
for (i = 0; i < n; i++) {
finish[i] = 0;
}
// Banker's algorithm
while (1) {
// Find a process p that is not finished and can be allocated resources
int p = -1;
for (i = 0; i < n; i++) {
if (!finish[il) {
int canAllocate = 1;
for (j = 0; j < m; j++) 1
if (max[ilD] - allocation[i]D] > available i]) 1
canAllocate = 0;
break;
}
}
if (canAllocate) {
р = i;
break;
}
}
}
// If no such process exists, the system is in a safe state
if (p == -1) {
break;
}
// Allocate resources to process p
for (j= 0; j < m; j++) 1
available[il -= allocation [p]Öl;
}
finish[p] = 1;
}
}
int main() {
// Initialize number of processes and resources
n = 4;
m = 3;
// Initialize available resources
available[0] = 3;
available[1] = 3;
available[2] = 2;
// Initialize allocation of resources to processes
allocation[0][0] = 0;
allocation[0][1] = 1;
allocation[0][2] = 0;
allocation[11 [0] = 2; allocation[1][1] = 0; allocation[1][2] = 0;
allocation[2][0] = 3; allocation | 2][1] = 0;
allocation[2][2] = 2;
allocation (31[0] = 2;
allocation [3][1] = 1;
allocation[3][2] = 0;
// Initialize maximum resources required by processes
max[0][0] = 7;
max[0][1] = 5;
max[0][2] = 3;
max[1][0] = 3;
max[1][1] = 2;
max[1][2] = 2;
max[2][0] = 2;
max[2][1] = 2;
max[2][2] = 2;
max[3][0] = 4;
max[3][1] = 3;
max[3][2] = 3;
// Banker's algorithm
banker();
Output:
Process 1: finish =1
Process 2: finish =1
Process 3: finish =1
Process 4: finish =0