OS Lab Manual II IT
OS Lab Manual II IT
No:01
INSTALLATION OF WINDOWS
Date: OPERATING SYSTEM
AIM:
Installation processes:
Connect a blank USB flash drive or insert a blank writable DVD. You can install Windows 10
by creating a bootable USB flash drive or DVD that contains the Windows 10 installation files. You'll
need a USB flash drive that's at least 8GB, or any blank DVD to get started.
If you bought Windows 10 through Microsoft using your Microsoft account, your product
key is already linked to your account. If you bought Windows 10 from another retailer, you'll
have a 25-character product key that you'll need to have handy to activate Windows
• If you don't have a product key or you're installing Windows 10 on a new hard drive, make
sure you've linked your Windows 10 digital license to your Microsoft account before you
start the installation.
• Head to Settings > Update & Security > Activation from the current installation—if the
activation status says Windows is activated with a digital license,
• click Add an account and follow the on-screen instructions to link your Microsoft account.
• If you're upgrading from an earlier version and your PC qualifies for a free upgrade, you
won't need a product key.
Step:3
Step:4
Click Download tool now. This is a blue button in the middle of the page. This downloads the Media
Creation Tool, which you'll use to create your installation media (or start your upgrade).
Step:5
Double-click the downloaded file. Its name begins with "MediaCreationTool" and ends with ".exe."
You'll find it in your default download folder, which is usually called Downloads.
• Click Yes when prompted to allow the installer to run.
Step:6
Click Accept to accept the license. It's in the bottom-right corner of the window.
Step-7:
Select "Create installation media" and click OK. This option lets you create a Windows
installation disc or drive that will work on any compatible PC, not just the one you're using now.
• If you're updating your PC from an earlier version of Windows, select Upgrade this PC
now instead, and then follow the on-screen instructions to install Windows 10. You're done!
Step-8:
Select your preferences and click Next. If you're installing Windows on the current PC, you can
keep the default options. If you need to install on a different PC, make sure you choose the language
and edition for which you have a license, and select the architecture (64-bit or 32-bit) that matches the
PC you're going to install on.
• If you're not sure about the architecture, you can choose Both from the menu.
Step-09:
Choose an installation type and click Next. An ISO file is a type of file that can be burned to
a DVD, so choose that option if you plan to create a DVD. Otherwise, choose the USB flash drive
option.
Step-10:
Create your installation media. The steps are a little different depending on what you're doing:
• Flash drive: Select your flash drive from the list, click Next, and wait for the installation files
to install. When the process is complete, click Finish.
• DVD/ISO: Click Save to save the ISO file to your computer—it may take a while because
the file is large and has to be downloaded. Once downloaded, you'll see a progress screen
that monitors the download. When the download is complete, click Open DVD burner on
the "Burn the ISO file to a DVD" screen, select your DVD burner, and then click Burn to
create your DVD.
Step-11:
Booting from Windows 10 Installation Media
➢ Connect your Windows 10 installation media. If you created a flash drive, connect it to the
PC on which you want to install Windows 10. If you made a DVD, insert it into the drive
now.
Boot the PC into the BIOS. If your PC is not already set up to boot from your flash or optical drive,
rebooting from your installation media won't work. You'll need to make a quick change in
your BIOS to change the boot order. There are a few ways to get in:
• Windows 8.1 or 10: From Windows, open Settings, select Update & Recovery or Update
& Security, and go to Recovery > Restart now > Troubleshoot > Advanced
Options > UEFI Firmware Settings > Restart.
• Any PC: Reboot the PC and immediately start pressing (over and over again) the keyboard
key required by your PC to enter "Setup," or the BIOS. The key varies by computer, but
here are some of the most common keys:
• Acer and Asus: F2 or Del
• Dell: F2 or F12
• HP: ESC or F10
• Lenovo: F1, F2, or Fn + F2
• Lenovo ThinkPads: Enter + F1.
• MSI: DEL
• Microsoft Surface Tablets: Press and hold the volume-up button.
• Samsung and Toshiba: F2
• Sony: F1, F2, or F3
Step-12:
Go to the Boot tab. You'll use the arrow keys to select it.
The Boot tab may instead say Boot Options or Boot Order, depending on your computer's
manufacturer.
Step-13:
Select a device from which to boot. You have a couple of options here:
• For a USB flash drive, select the Removable Devices option.
• For a disc installation, select the CD-ROM Drive or Optical Drive option
Step-14:
Press the + key until your boot option is first. Once either Removable Devices or CD-
ROM Drive is at the top of the list, your computer will select your choice as its default boot
option.
On some computers, you'll instead press one of the function keys (e.g., F5 or the arrow keys
to navigate an option up to the top of the menu. The key will be listed on the right side of the
screen.
Step-15:
Save your settings. You should see a key prompt (e.g., F10 at the bottom of the screen that
correlates to "Save and Exit". Pressing it will save your settings and restart your computer.
Step-16:
Wait for your computer to restart. Once your computer finishes restarting, you'll see a
window here with your geographical data. You're now ready to begin setting up your
Windows 10 installation.
Step-17:
Click Next when prompted. You can also change the options on this page (e.g., the setup
language) before continuing if need be
Step-18:
Follow the on-screen instructions to install Windows 10. You'll be asked to perform a few
tasks, such as connecting to Wi-Fi and choosing some preferences. Once the installation is
complete, you'll have a fresh new installation of Windows 10.
• If you're upgrading from an earlier version of Windows, you'll be asked if you want to
upgrade the current operating system or do a custom install. If you choose Upgrade, you'll
preserve existing apps and files.
Conclusion:
Thus the windows operating system was installed and configured successfully.
Ex.No:02
AIM:
Acquire operating system skills through UNIX Commands.
UNIX SHELL:
A UNIX shell is a command-line interpreter that provides a user interface for the
UNIX operating system. Users direct the operation of the computer by entering
commands as text for a command line interpreter to execute or by creating text scripts of
one or more such commands
GENERAL COMMANDS:
who Login details of all users such as their IP, Terminal No, Username
who am i Used to display the login details of the user
tty Used to display the terminal name (or) terminaltype
uname Displays the Operating System
uname –r Shows version number of the OS (kernel)
uname –n Displays domain name of the server
echo "txt" Displays the given text on the screen
echo $HOME Displays the user's home directory
bc Basic calculator. Press Ctrl+d to quit
lp - file Allows the user to spool a job along with others in a print queue
history To display the commands used by the user since logon.
Exit Exit from a process. If shell is the only process then logs out
Clear Clear the screen
DIRECTORY COMMANDS:
CONCLUSION:
Thus the basics of UNIX commands are studied by executing the commands
Ex.No:03(a)
IMPLEMENTATION OF UNIX SYSTEM CALLS
Date:
(getpid, waitpid)
AIM:
To write programs using the following system calls of UNIX operating system fork,
getpid, waitpid..
ALGORITHM:
Step 3: Create a identical copy of parent process (child process) using fork ()
system call
Step 4: Process id is created for both child and parent process using getpid()
system call
Step 6: After the exiting of the child process parent process will getexit.
[com39@localhost ~]$ cd os
Parent 1769 waiting for child 1770 to start the executing fork is empty
CONCLUSION:
Thus the C program to simulate UNIX system calls fork, getpid, wait has been executed
successfully
Ex.No:03(b)
IMPLEMENTATION OF UNIX SYSTEM CALLS
Date: (opendir (), readdir(),closedir(), exit())
AIM:
To write programs using the following system calls of UNIX operating
system opendir(),readdir(), closedir() and exit().
ALGORITHM:
Step 1: Start the program.
Step 2: Create a directory entry in the directory structure and a directory variable.
Step 3: Get the name of the directory to be opened.
Step 4: Using the system call opendir(),open the given directory and store it inthe directory
variable.
Step 5: Read the contents of the directory using readdir()system call and print the list
of files in the directory.
Step 6: Close the directory after the read and write process.
Step 7: Stop the program.
PROGRAM:
#include<stdio.h>
#include<dirent.h>
#include<stdlib.h>
scanf("%s",buff); if((dirp=opendir(buff))==NULL)
printf("error");
exit(0);
while(dptr=readdir(dirp))
printf("%s\n",dptr->d_name);
closedir(dirp);
}
OUTPUT:
[com39@localhost ~]$ cd os
ex5b.c
ex1b.c
..
ex1a.c
ex4a.c
ex2.c
ex3a.c
ex1d.c
ex4b.c
.
ex3b.c
ex1c.c
ex5a.c
[com39@localhost os]$
CONCLUSION:
Thus the C program to simulate UNIX system calls opendir, readdir, closedir and exit has
beenexecuted successfully.
Ex.No:4a CPU SCHEDULING ALGORITHMS –
AIM
Step 3: Get the number of process and their burst time of each process.
Step 4: Calculate the waiting time and turnaround time of each of the processes
Step 5: Calculate average waiting and average turnaround time of all the process.
Step 6: Display waiting time, turnaround time, average waiting time and turnaround time of
the processes
clrscr();
printf("\nEnter the number of processes -- ");
scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("\nEnter Burst Time for Process %d -- ", i);
scanf("%d", &bt[i]);
}
wt[0] = wtavg = 0; tat[0] = tatavg = bt[0];
for(i=1;i<n;i++)
{ wt[i] = wt[i-1] +bt[i-1];
for(i=0;i<n;i++)
}
INPUT
CONCLUSION:
Thus the C program using FCFS scheduling has been executed successfully.
Ex.No:4b
AIM
Acquire operating system skills through CPU scheduling algorithms.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
main()
{
p[i]=i;
printf("Enter Burst Time for Process %d -- ", i);
scanf("%d", &bt[i]);
}
for(i=0;i<n;i++)
for(k=i+1;k<n;k++)
if(bt[i]>bt[k])
{
temp=bt[i];
}
bt[i]=bt[k]; bt[k]=temp; temp=p[i]; p[i]=p[k]; p[k]=temp;
wt[0] = wtavg = 0;
printf("\n\t P%d \t\t %d \t\t %d \t\t %d", p[i], bt[i], wt[i], tat[i]);
printf("\nAverage Waiting Time -- %f", wtavg/n);
printf("\nAverage Turnaround Time -- %f", tatavg/n);
getch();}
INPUT
Process 0 -- 6
Enter Burst Time for
Process 1 -- 8
Enter Burst Time for
Process 2 -- 7
Enter Burst Time for
Process 3 -- 3
OUTPUT
PROCESS
BURST TIMEWAITING TIME TURNAROUND TIME
P3 3 0 3
P0 6 3 9
P2 7 9 16
P1 8 16 24
CONCLUSION:
Thus the C program using SJF scheduling has been executed successfully.
Ex.No:4c
CPU SCHEDULING ALGORITHMS - ROUND ROBIN SCHEDULING
Date: ALGORITHM
AIM:
Acquire programming skills for application development in real-world problem
solving.
ALGORITHM:
Step 8: Calculate average waiting and average turnaround time of all the process.
Step 9: Display waiting time, turnaround time, average waiting time and turnaround time of
the processes.
#include<stdio.h>
main()
{
int pt[10][10],a[10][10],at[10],pname[10][10],i,j,n,k=0,q,sum=0;
float avg;
printf("\n\n Enter the number of processes : ");
scanf("%d",&n);
for(i=0;i<10;i++)
for(j=0;j<10;j++)
{
pt[i][j]=0;
a[i][j]=0;
}
}
for(i=0;i<n;i++)
{ j=0;
printf("\n\n Enter the process time for process %d : ",i+1); scanf("%d",&pt[i][j]);
{
a[2*j][i]=k; if((pt[i][j]<=q)&&(pt[i][j]!=0))
{
pt[i][j+1]=0;
}
else if(pt[i][j]!=0)
{
pt[i][j+1]=pt[i][j]-q;
printf(" %d P%d %d\n",k,i+1,(k+q)); k+=q;
a[2*j+1][i]=k;
}
else
a[2*j][i]=0;
a[2*j+1][i]=0;
}}}
for(i=0;i<n;i++)
{
sum+=a[0][i];
}
for(i=0;i<n;i++)
{
for(j=1;j<10;j++)
{ if((a[j][i]!=0)&&(a[j+1][i]!=0)&&((j+1)%2==0))
{
sum+=((a[j+1][i]-a[j][i]));
}}}
avg=(float)sum/n;
printf("\n\n Average waiting time = %f msec",avg); sum=avg=0;
for(j=0;j<n;j++)
{ i=1;
while(a[i][j]!=0)
{ i+=1;
}
sum+=a[i-1][j];
}
avg=(float)sum/n;
printf("\n\n Average turnaround time = %f msec\n\n",avg);
}
OUTPUT:
2 P2 4
4 P3 6
6 P1 8
8 P2 10
10 P3 12
12 P2 14
14 P3 16
16 P3 18
18 P3 19
Average waiting time = 7.333333 msec
Average turnaround time = 13.666667
msec [com39@localhost os]$
CONCLUSION:
Thus the C program using Round Robin scheduling has been executed successfully.
Ex.No:5
INTER PROCESS COMMUNICATION
Date:
AIM:
Learn about Shared Memory and Inter Process Communication
ALGORITHM:
Step 1: Start the program.
Step 2: Create a child process using fork().
Step 3: Now close the read end of the parent using close().
Step 4: Write the data in the pipe using write().
Step 5: Now close the read end of the child using close().
Step 6: Read the data in the pipe using read().
Step 7: Display the string.
Step 8: Stop the program.
PROGRAM:
#include<stdio.h>
int main()
{
int fd[2],child; char a[10];
printf("Enter the string to enter into the pipe:\t");
scanf("%s", a);
pipe(fd); child=fork();
if(!child)
{
close(fd[0]);
write(fd[1],a,5);
wait(0);
}
else
{
close(fd[1]);
read(fd[0],a,5);
printf("The string received from the pipe is %s",a);
}
return 0;
}
OUTPUT:
CONCLUSION:
Thus the C program for interprocess communication using pipes was executed and the
output was verified.
Ex.No:6
Date: SEMAPHORES
AIM:
To write a C program to implement semaphores.
ALGORITHM:
Step 1: Start the program
Step 4: When job 1 enters critical section, next job starts processing
Step 5: When job1 comes out of the critical section, the other job enters the critical section
int i,a=1,h=2,n;
for(i=0;i<n;i++)
if(a==1)
a++;
if(h>1)
if(i+2<=n)
printf("\n Process %d Enters Critical section", i+1); printf("\n Process %d Leaves Critical section",
i+1);
} h+1;
}
OUTPUT:
processing 1. !
processing 2. !
CONCLUSION:
Thus the program to implement semaphores in c was executed and the
output was verified.
Ex.No:7
BANKERS ALGORITHM FOR DEAD LOCK
Date:
AVOIDANCE
AIM:
ALGORITHM:
Step 8: If the new request comes then check that the system is insafety.
#include< stdio.h>
#include< conio.h>
void main()
int pno,rno,i,j,prc,count,t,total;
count=0 clrscr();
scanf("%d",&pno);
scanf("%d",&rno);
for(i=1;i< =pno;i++)
flag[i]=0;
]);
{
avail[j]=0; total=0; for(i=1;i<= pno;i++)
total+=allocated[i][j];
printf(" %d \t",work[j]);
do
for(i=1;i<= pno;i++)
for(j=1;j<= rno;j++)
need[i][j]=max[i][j]-allocated[i][j];
for(i=1;i<= pno;i++)
printf("\n");
for(j=1;j<= rno;j++)
printf("%4d",allocated[i][j]);
printf("|");
for(j=1;j<= rno;j++)
printf("%4d",max[i][j]);
}
printf("|");
for(j=1;j<= rno;j++)
printf("%4d",max[i][j]);
printf("|");
for(j=1;j<= rno;j++)
printf("%4d",need[i][j]);
prc=0;
for(i=1;i<= pno;i++)
if(flag[i]==0)
prc=i;
for(j=1;j<= rno;j++)
if(work[j]< need[i][j])
Prc=0; break;
if(prc!=0) break;
}
if(prc!=0)
for(j=1;j<= rno;j++)
printf(" %d",work[j]);
}while(count!=pno&&prc
!=0);
if(count==pno)
else
getch();
printf("%4d",need[i][j]);
prc=0;
for(i=1;i<= pno;i++)
{
if(flag[i]==0)
prc=i;
for(j=1;j<= rno;j++)
if(work[j]< need[i][j])
Prc=0; break;
if(prc!=0) break;
if(prc!=0)
printf(" %d",work[j]);
}while(count!=pno&&prc
}
OUTPUT:
Enter allocated resources for each process: for process 1:0 1 0 for process 2:3 0 2
need 0
0 1 0| 7 5 3| 7 4 3
3 0 2| 3 2 2| 0 2 0
3 0 2| 9 0 2| 6 0 0
2 1 1| 2 2 2| 0 1 1
0 0 2| 4 3 3| 4 3 1
Process 2 completed
0 1 0| 7 5 3| 7 4 3
0 0 0| 0 0 0| 0 0 0
3 0 2| 9 0 2| 6 0 0
2 1 1| 2 2 2| 0 1 1
0 0 2| 4 3 3| 4 3 1
Process 4 completed
Available matrix: 7 4 3 Allocated matrix Max need
0 1 0| 7 5 3| 7 4 3
0 0 0| 0 0 0| 0 0 0
3 0 2| 9 0 2| 6 0 0
0 0 0| 0 0 0| 0 0 0
0 0 2| 4 3 3| 4 3 1
Process 1 completed
0 0 0| 0 0 0| 0 0 0
0 0 0| 0 0 0| 0 0 0
3 0 2| 9 0 2| 6 0 0
0 0 0| 0 0 0| 0 0 0
0 0 2| 4 3 3| 4 3 1
Process 3 completed
0 0 0| 0 0 0| 0 0 0
0 0 0| 0 0 0| 0 0 0
0 0 0| 0 0 0| 0 0 0
0 0 0| 0 0 0| 0 0 0
0 0 2| 4 3 3| 4 3 1
Process 5 completed
CONCLUSION:
Thus the program to implement banker’s algorithm for Dead Lock Avoidance
was executedand the output was verified.
Ex.No:8
Date:
DEADLOCK DETECTION ALGORITHM
AIM:
ALGORITHM:
Step 2: Get the values of resources and processes. Step 3: Get the avail value.
Step 4: After allocation find the need value. Step 5: Check whether it’s possible to allocate.
Step 6: If it is possible then the system is in safe state. Step 7: Else system is not in safety state.
Step 8: If the new request comes then check that the system is insafety. Step 9: Or not if we allow the
request.
#include<stdio.h>
#include<conio.h>
int max[100][100];
int alloc[100][100];
int n,r;
void input();
void show();
void cal();
int main()
int i,j;
input();
show();
cal();
getch();
return 0;
void input()
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<r;j++)
scanf("%d",&max[i][j]);
for(k=0;k<r;k++)
//printf("\nP%d",i); if(finish[i]==1)
i=n;
}}}}}
} j=0;
flag=0; for(i=0;i<n;i++)
if(finish[i]==0)
if(flag==1)
printf("P%d\t",dead[i]);
}
}
else
PROGRAM-2
#include <bits/stdc++.h>
int arrmax[100][100];
int alloc[100][100];
int need[100][100];
int avail[100];
int n, r;
void input()
int i, j;
cin >> n;
cin >> r;
void show()
int i, j;
if (i == 0)
void cal()
int dead[100];
int safe[100];
int i, j;
finish[i] = 0;
while (flag)
flag = 0;
int c = 0;
c++;
if (c == r)
avail[k] += alloc[i][j];
finish[i] = 1;
flag = 1;
//cout<<"\nP%d",i;
if (finish[i] == 1)
i = n;
}
}
j = 0;
flag = 0;
if (finish[i] == 0)
dead[j] = i;
j++;
flag = 1;
if (flag == 1)
else
}
}
int main()
int i, j;
input();
show();
cal();
return 0;
}
OUTPUT:
368
433
344
333
203
124
120
P2 203 433
P3 124 344
P0 P1 P2
CONCLUSION:
Thus the program to implement banker’s algorithm for Dead Lock Detection
was executedand the output was verified.
Ex.No:9
AIM:
ALGORITHM:
#include<st dio.h>
#include<str ing.h>
#include<pt hread.h>
#include<st dlib.h>
int counter;
int main(void)
while(i < 2)
i++;
pthread_join(tid[0], NULL);
pthread_join(tid[1], NULL);
return 0;
}
OUTPUT:
Job 1 started
Job 1 finished
Job 2 started
Job 2 finished
CONCLUSION:
Thus the C program for threading and synchronization applications was
created andexecuted successfully.
Ex.No:10
Date:
IMPLEMENTATION OF PAGING TECHNIQUE
AIM:
To learn about paging techniques in memory management.
ALGORITHM
Step 1: Start the program.
Step 2: Input the pagesize and initialize memsize of page to 15.
CONCLUSION:
Thus the c program for implementing paging technique of memory management using first fit
was executed and the output was verified.
Ex.No:11a
AIM:
To learn about Memory management schemes.
ALGORITHM:
Step 1: Include the necessary header files required.
Step 2: Declare the variables needed.
Step 3: Read the number of blocks and the size of each blocks.
Step 4: Read the number of process and the size of each process.
Step 5: Check if the process size is less than or equal to block
size.
Step 6: If yes, assign the corresponding block to the current
process.
Step 7: Else print the current process is not allocated.
PROGRAM:
#include<stdio.h>
#include<conio.h>
#define max 25
void main()
{
int frag[max],b[max],f[max],i,j,nb,nf,temp,highest=0;
static int bf[max],ff[max];
clrscr();
printf("\n\tMemory Management Scheme - Worst Fit");
printf("\nEnter the number of blocks:");
scanf("%d",&nb);
printf("Enter the number of files:");
scanf("%d",&nf);
printf("\nEnter the size of the blocks:-\n");
for(i=1;i<=nb;i++)
{
printf("Block %d:",i);
scanf("%d",&b[i]);
}
printf("Enter the size of the files :-\n"); for(i=1;i<=nf;i++)
{
printf("File %d:",i);
scanf("%d",&f[i]);
}
for(i=1;i<=nf;i++)
{
for(j=1;j<=nb;j++)
{
if(bf[j]!=1) //if bf[j] is not allocated
{
temp=b[j]-f[i];
if(temp>=0) if(highest<temp)
{
ff[i]=j; highest=temp;
}
}
}
frag[i]=highest; bf[ff[i]]=1; highest=0;
}
printf("\nFile_no:\tFile_size :\tBlock_no:\tBlock_size:\tFragement");
for(i=1;i<=nf;i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,f[i],ff[i],b[ff[i]],frag[i]);
getch();
}
INPUT
Enter the number of blocks: 3 Enter the number of files: 2
Enter the size of the blocks:- Block 1: 5
Block 2: 2
Block 3: 7
Enter the size of the files:- File 1: 1
File 2: 4
OUTPUT
CONCLUSION:
Thus the program to implement memory management using first fit was executed and the
output was verified
Ex.No:11b
Date:
MEMORY MANAGEMENT SCHEME USING WORST FIT
AIM:
ALGORITHM:
Step 3: Read the number of blocks and the size of each blocks.
Step 4: Read the number of process and the size of each process.
Step 5: Check if the process size is less than or equal to block size.
#include<stdio.h>
void main()
clrscr();
printf("Block %d:",i);
scanf("%d",&b[i]);
for(i=1;i<=nf;i++)
printf("File %d:",i);
scanf("%d",&f[i]);
for(i=1;i<=nf;i++)
for(j=1;j<=nb;j++)
if(bf[j]!=1)
temp=b[j]-f[i]; if(temp>=0)
{
ff[i]=j; break;
frag[i]=temp;
bf[ff[i]]=1;}
printf("\nFile_no:\tFile_size:\tBlock_no:\tBlock_size:\tFragement");
for(i=1;i<=nf;i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,f[i],ff[i],b[ff[i]],frag[i]);
getch();
}
INPUT:
Block 2: 2
Block 3: 7
File 2: 4
OUTPUT
1 1 1 5 4
2 4 3 7 3
CONCLUSION:
Thus the program to implement memory management using worst fit was executed and the
output was verified.
Ex.No:11c
AIM:
To learn about Memory management schemes using best fit.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
#define max 25
void main()
{
int frag[max],b[max],f[max],i,j,nb,nf,temp,lowest=10000;
static int bf[max],ff[max];
clrscr();
for(i=1;i<=nf;i++)
for(j=1;j<=nb;j++)
if(bf[j]!=1)
temp=b[j]-f[i]; if(temp>=0)
if(lowest>temp)
ff[i]=j;
lowest=temp;
}
frag[i]=lowest; bf[ff[i]]=1; lowest=10000;
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,f[i],ff[i],b[ff[i]],frag[i]);
getch();
}
INPUT
Block 1: 5
Block 2: 2
Block 3: 7
File 1: 1
File 2: 4
OUTPUT
1 1 2 2 1
2 4 1 5 1
CONCLUSION:
Thus the program to implement memory management using best fit was executed and the
output was verified.
Ex.No:12a
AIM:
ALGORITHM
Step 2: Input the total length of reference strings, number of frames and individual reference strings
from the user.
Step 3: For each reference string value, check its availability in the page frames. Step 4: If found,
increment to next reference string.
Step 5: When the page is not in the frames, increment the number of page fault and remove the page
whose page frequency is least in the reference strings.
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
scanf("%d",&m);
for(i=0;i<m;i++)
scanf("%d",&rs[i]);
for(i=0;i<f;i++)
{ cntr[i]=0;
a[i]=-1; }
for(i=0;i<m;i++){
for(j=0;j<f;j++)
if(rs[i]==a[j])
{ cntr[j]++;
break;
if(j==f)
getch();
}
Output
Enter the reference string --1 2 3 4 5 2 5 2 5 1 Enter the available no. of frames – 3
1 -1 -1 PF No. 1
1 2 -1 PF No. 2
1 2 3 PF No. 3
4 2 3 PF No. 4
5 2 3 PF No. 5
5 2 3 PF No. 6
5 2 3 PF No. 7
PF No. 8
CONCLUSION:
Thus the program for Page replacement algorithms for LRU was executed and the output
was verified.
Ex.No:12b
Date:
IMPLEMENTATION OF PAGE REPLACEMENT ALGORITHMS (FIFO)
AIM:
To learn about Page Replacement Algorithms.
ALGORITHM
Step 1: Start the program.
Step 2: Input the total length of reference strings, number of frames and individualreference strings
from the user.
Step 3: For each reference string value, check its availability in the page frames.
Step 4: If found, increment to next reference string.
Step 5: When the page is not in the frames, increment the number of page fault andremove
the page that comes first in the FIFO algorithm.
Step 6: Display the number of faults.
Step 7: Stop the program.
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&rs[i]);
scanf("%d",&f);
for(i=0;i<f;i++) m[i]=-1;
for(k=0;k<f;k++)
if(m[k]==rs[i]) break;
if(k==f)
m[count++]=rs[i];
pf++;
for(j=0;j<f;j++)
printf("\t%d",m[j]);
if(k==f)
printf("\tPF No. %d",pf);
getch();
}
OUTPUT
7 -1 -1 PF No. 1
7 0 -1 PF No. 2
7 0 1 PF No. 3
2 0 1 PF No. 4
2 0 1
2 3 1 PF No. 5
2 3 0 PF No. 6
4 3 0 PF No. 7
4 2 0 PF No. 8
4 2 3 PF No. 9
0 2 3 PF No. 10
0 2 3
0 2 3
0 1 3 PF No. 11
0 1 2
0 1 2
7 1 2 PF No. 13
7 0 2 PF No. 14
7 0 1 PF No. 15
CONCLUSION:
Thus the program for Page replacement algorithms for FIFO was executed and the output
was verified.
Ex.No:12c
IMPLEMENTATION OF PAGE REPLACEMENT
Date: ALGORITHMS (LRU)
AIM:
ALGORITHM
Step 2: Input the total length of reference strings, number of frames and individual reference strings
from the user.
Step 3: For each reference string value, check its availability in the page frames.
Step 5: When the page is not in the frames, increment the number of page fault and remove the page
that is used very least in the reference strings.
scanf("%d",&rs[i]); flag[i]=0;
for(i=0;i<f;i++)
{
scanf("%d",&rs[i]); flag[i]=O;
scanf("%d",&f); for(i=O;i<f;i++)
}
OUTPUT
7 -1 -1 PF No. – 1
7 0 -1 PF No. – 2
7 0 1 PF No. – 3
2 0 1 PF No. – 4
2 0 1
2 0 3 PF No. – 5
2 0 3
4 0 3 PF No. – 6
4 0 2 PF No. – 7
4 3 2 PF No. – 8
0 3 2 PF No. – 9
0 3 2
0 3 2
1 3 2 PF No. – 10
1 3 2
1 0 2 PF No. – 11
1 0 2
1 0 7 PF No. – 12
1 0 7
1 0 7
CONCLUSION:
Thus the program for Page replacement algorithms for LRU was executed and the output
was verified.
Ex.No:13a
IMPLEMENTATION OF FILE ORGANIZATION
Date:
TECHNIQUES (SINGLE LEVEL FILE)
AIM:
To learn about File Organization Techniques.
ALGORITHM
switch(ch)
case 1:
break; case 2:
for(i=0;i<dir.fcnt;i++)
if(strcmp(f, dir.fname[i])==0)
if(i==dir.fcnt)
else
dir.fcnt--; break;
case 3:
if(strcmp(f, dir.fname[i])==0)
if(i==dir.fcnt)
case 4:
break; default:
exit(0);
}
OUTPUT
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
1 Enter the name of the file –A
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
1 Enter the name of the file –B
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
1 Enter the name of the file –C
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
4 The Files are -- A B C
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
3 Enter the name of the file – ABC
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
2 Enter the name of the file – B
File B is deleted
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
3 Enter the name of the file – C
File C is found
1.Create File 2. Delete File 3. Search File 4.Display Files 5. Exit Enter your choice –
5
CONCLUSION
AIM:
ALGORITHM:
Step 2: Create a structure for building a directory with dname and fname as inputs.
Step 3: Create a new directory. Create another new directory inside it or create a file.
Step 4: For the generated directory, create individual files with distinct names.
Step 5: Search for the file created in the directory using its name. if found returns file found.
Step 6: Display the total files present in the directory using display function.
Step 7: Delete a file by specifying its name using the delete function.
#include<stdio.h>
struct
dcnt=0; while(1)
scanf("%d",&ch);
switch(ch)
case 1:
dcnt++;
case 2:
scanf("%s",d);
for(i=0;i<dcnt;i++) if(strcmp(d,dir[i].dname)==0)
scanf("%s",dir[i].fname[dir[i].fcnt]);
dir[i].fcnt++;
if(i==dcnt)
case 3:
for(i=0;i<dcnt;i++)
if(strcmp(d,dir[i].dname)==0)
if(strcmp(f, dir[i].fname[k])==0)
break;
case 4:
for(i=0;i<dcnt;i++)
if(strcmp(d,dir[i].dname)==0)
{
printf("Enter the name of the file -- ");
scanf("%s",f); for(k=0;k<dir[i].fcnt;k++)
if(strcmp(f, dir[i].fname[k])==0)
break; case 5:
if(dcnt==0)
printf("\nDirectory\tFiles"); for(i=0;i<dcnt;i++)
break; default:
exit(0);
getch();
}
OUTPUT
4. Search File 5.Display 6.Exit Enter Your Choice—1 Enter name of the Directory—DIR1
Directory Created.
4. Search File 5.Display 6.Exit Enter Your Choice—1 Enter name of the Directory—DIR2
Directory Created.
4. Search File 5.Display 6.Exit Enter Your Choice—2 Enter name of the Directory—DIR1
4. Search File 5.Display 6.Exit Enter Your Choice—2 Enter name of the Directory—DIR1
4. Search File 5.Display 6.Exit Enter Your Choice—2 Enter name of the Directory—DIR2
DIR1 A1 A2
DIR2 B1
4. Search File 5.Display 6.Exit Enter Your Choice—3 Enter name of the Directory—DIR1
CONCLUSION:
Thus the program to implement file organization technique in Two Level Directory was
executed and the output was verified.
Ex.No:14a IMPLEMENTATION OF FILE ALLOCATION TECHNIQUES
AIM:
To learn about File Allocation Techniques.
ALGORITHM:
14 1
15 1
16 1
The file is not allocated Do you want to enter more file(Yes - 1/No - 0)0
CONCLUSION:
Thus the program to implement sequential file allocation was executed and the output was
verified.
Ex.No:14b IMPLEMENTATION OF FILE ALLOCATION TECHNIQUES
AIM:
ALGORITHM:
Step 3: Input enter the number of files, file name, starting block and number of blocks.
Step 4: Subsequent blocks are allocated as per the index details of the file in indexed approach.
Search for the file created. if found returns file found. Else returns not found.
#include<stdio.h>
#include<conio.h>
struct fileTable
char name[20];
}ft[30];
void main()
scanf("%s",ft[i].name);
if(i==n)
printf("%d, ",ft[i].blocks[j]);
getch();}
OUTPUT:
CONCLUSION
Thus the C program for indexed file allocation has been executed successfully.
Ex.No:14c IMPLEMENTATION OF FILE ALLOCATION TECHNIQUES
AIM:
ALGORITHM:
Step 3: Input enter the number of files, file name, starting block and number of blocks.
Step 4: Subsequent blocks are allocated as per pointer value to next block of the file in linked
approach. Search for the file created. if found returns file found. Else returns not found.
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
struct fileTable
}ft[30];
struct block
int bno;
};
void main()
scanf("%d",&n); for(i=0;i<n;i++) {
scanf("%s",ft[i].name);
scanf("%d",&ft[i].nob);
scanf("%d",&temp->bno);
temp->next=NULL; for(j=1;j<ft[i].nob;j++) {
scanf("%d",&temp->bno);
temp->next=NULL;
scanf("%s",s);
if(i==n)
temp=ft[i].sb; for(j=0;j<ft[i].nob;j++)
getch();
}
OUTPUT:
CONCLUSION
Thus the C program for linked file allocation has been executed successfully.
Ex.No:15a IMPLEMENTATION OF DISK SCHEDULING ALGORITHM
Date: (SSTF)
AIM:
ALGORITHM:
#include<stdio.h>
#include<stdlib.h>
int main()
int RQ[100],i,n,TotalHeadMoment=0,initial,count=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&RQ[i]);
scanf("%d",&initial);
while(count!=n)
int min=1000,d,index;
for(i=0;i<n;i++)
d=abs(RQ[i]-initial);
if(min>d)
min=d;
index=i;
}
}
TotalHeadMoment=TotalHeadMoment+min;
initial=RQ[index];
RQ[index]=1000;
count++;
return 0;
}
Output:
50
CONCLUSION:
Thus the program to implement file allocation strategies using c program was executed
and the output was verified.
Ex.No:15b IMPLEMENTATION OF DISK SCHEDULING ALGORITHM
AIM:
ALGORITHM:
#include<stdio.h>
#include<stdlib.h>
int main()
int RQ[100],i,j,n,TotalHeadMoment=0,initial,size,move;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&RQ[i]);
scanf("%d",&initial);
scanf("%d",&size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d",&move);
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
if(RQ[j]>RQ[j+1])
int temp;
temp=RQ[j];
RQ[j]=RQ[j+1];
RQ[j+1]=temp;
int index;
for(i=0;i<n;i++)
if(initial<RQ[i])
index=i;
break;
if(move==1)
for(i=index;i<n;i++)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
TotalHeadMoment=TotalHeadMoment+abs(size-RQ[i-1]-1);
initial = size-1;
for(i=index-1;i>=0;i--)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
else
for(i=index-1;i>=0;i--)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
TotalHeadMoment=TotalHeadMoment+abs(RQ[i+1]-0);
initial =0;
for(i=index;i<n;i++)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
return 0;
}
OUTPUT:
50
200
Enter the head movement direction for high 1 and for low 0
CONCLUSION:
Thus the program to implement file allocation strategies using c program was executed
and the output was verified.
Ex.No:15c IMPLEMENTATION OF DISK SCHEDULING ALGORITHM
AIM:
ALGORITHM:
#include<stdio.h>
#include<stdlib.h>
int main()
int RQ[100],i,j,n,TotalHeadMoment=0,initial,size,move;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&RQ[i]);
scanf("%d",&initial);
scanf("%d",&size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d",&move);
for(i=0;i<n;i++)
for( j=0;j<n-i-1;j++)
if(RQ[j]>RQ[j+1])
int temp;
temp=RQ[j];
RQ[j]=RQ[j+1];
RQ[j+1]=temp;
int index;
for(i=0;i<n;i++)
if(initial<RQ[i])
index=i;
break;
if(move==1)
for(i=index;i<n;i++)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
TotalHeadMoment=TotalHeadMoment+abs(size-RQ[i-1]-1);
TotalHeadMoment=TotalHeadMoment+abs(size-1-0);
initial=0;
for( i=0;i<index;i++)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
else
for(i=index-1;i>=0;i--)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
TotalHeadMoment=TotalHeadMoment+abs(RQ[i+1]-0);
TotalHeadMoment=TotalHeadMoment+abs(size-1-0);
initial =size-1;
for(i=n-1;i>=index;i--)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
return 0;
}
OUTPUT:
CONCLUSION:
Thus the program to implement file allocation strategies using c program was executed
and the output was verified.
Ex.No:15c IMPLEMENTATION OF DISK SCHEDULING ALGORITHM
AIM:
ALGORITHM:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int RQ[100],i,j,n,TotalHeadMoment=0,initial,size,move;
printf("Enter the number of Requests\n");
scanf("%d",&n);
printf("Enter the Requests sequence\n");
for(i=0;i<n;i++)
scanf("%d",&RQ[i]);
printf("Enter initial head position\n");
scanf("%d",&initial);
printf("Enter total disk size\n");
scanf("%d",&size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d",&move);
// logic for look disk scheduling
/*logic for sort the request array */
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(RQ[j]>RQ[j+1])
{
int temp;
temp=RQ[j];
RQ[j]=RQ[j+1];
RQ[j+1]=temp;
}
}
}
int index;
for(i=0;i<n;i++)
{
if(initial<RQ[i])
{
index=i;
break;
}
}
// if movement is towards high value
if(move==1)
{
for(i=index;i<n;i++)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
for(i=index-1;i>=0;i--)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
}
// if movement is towards low value
else
{
for(i=index-1;i>=0;i--)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
for(i=index;i<n;i++)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
}
50
Enter the head movement direction for high 1 and for low 0
CONCLUSION:
AIM:
ALGORITHM:
#include<stdio.h>
#include<stdlib.h>
int main()
int RQ[100],i,j,n,TotalHeadMoment=0,initial,size,move;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&RQ[i]);
scanf("%d",&initial);
scanf("%d",&size);
printf("Enter the head movement direction for high 1 and for low 0\n");
scanf("%d",&move);
for(i=0;i<n;i++)
for( j=0;j<n-i-1;j++)
if(RQ[j]>RQ[j+1])
int temp;
temp=RQ[j];
RQ[j]=RQ[j+1];
RQ[j+1]=temp;
int index;
for(i=0;i<n;i++)
if(initial<RQ[i])
index=i;
break;
if(move==1)
for(i=index;i<n;i++)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
for( i=0;i<index;i++)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
else
for(i=index-1;i>=0;i--)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
for(i=n-1;i>=index;i--)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
return 0;
}
OUTPUT:
CONCLUSION:
Thus the programme is executed successfully and output is verified.
Ex.No:16
AIM:
INSTALLATION PROCEDURE:
STEP 1: Download the VMWare Workstation application for your host operating
system and install it on your machine.
You can choose either Typical or Custom Wizard. We recommend selecting Custom if you want
to install with all the configurations. If you are okay with default configurations then go ahead
with Typical configurations.
STEP 3: Select Virtual Machine Hardware Compatibility
STEP 4:- Select the Operating System Media
STEP 19:- After powering on the Virtual machine, you will be treated with a welcome screen on
which you will see two options: Try Ubuntu and Install Ubuntu. Select Try Ubuntu if you want
to run Ubuntu in live mode. Select Install to continue the installation process.
STEP 20:-Select a keyboard Layout
Thus the Ubuntu operation system is installed over the virtual machine and its correctness
of working is verified.