Os 2
Os 2
AIM
Make sure that you are using Usb Drive that is At least 4gb For The 32-Bit- Version and 8gb forthe 64-Bit
Version.
Rufus is one of several programs that allow you to create an “ISO image” on a USB drive. Tocreate a
bootable USB using Rufus, all we need is:
11
STEP 2: (a) Run the Media Creation Tool.exe. to upgrade or download Windows 10. STEP 3: At the next
Important Notes
1. In order to perform a clean installation of Windows 10, you must own a valid Windows 10product
key to activate Windows.
2. If you bought a pre-installed Windows 10 computer (on which the OS was pre-installed fromthe
computer manufacturer), then the product key is stored in BIOS and it will be retrieved automatically (from
BIOS) during Windows installation.
3. If you’re currently running Windows 8.1 or Windows 7 SP1 (already activated), and you wantto
upgrade your computer to Windows 10 select “Upgrade this PC now” at the next screen & then follow the
onscreen instruction to upgrade your OS to Windows 10.
STEP 4: Choose the Windows 10 Edition that you want to download and click Next.Important Notes
1. If you want to install Windows 10 on the current PC, leave the Use the recommendedoptions for this PC
box checked. At this case the Media Creation Tool will create a Windows 10 installation disk with the same
language, edition, and architecture as thecurrent PC.
12
STEP 7: Choose the destination location (where the ISO file will be saved/stored) & press Save.
1. Click Open DVD burner and place a blank DVD disk on the DVRW tray in order to createimmediately a
bootable Windows 10 DVD installation/repair disk, or
2. Click Finish.
13
EXP No : 2a
BASICS OF UNIX COMMANDS
DATE :
AIM:
COMMAND:
1. Date Command:
Syntax:
Z = Time zone
Syntax:
$date “+%H-%M-%S”
2. Calender Command:
This command is used to display the calendar of the year or the particular month of calendaryear.
a. $cal <year>
b. $cal <month><year>
Here the first syntax gives the entire calendar for given year & the second Syntax gives thecalendar of
reserved month of that year.
14
3. Echo Command:
To have the output in the same line, the following commands can be used
Syntax Secho
<text>text
To have the output in different line, the following command can be used.
>line2
>line3?
4. ‘who’ Command:
It is used to display who are the users connected to our computer currently.
Syntax: $who-option’s
Options:-
b-Display the last booting date or time or when the system was lastely rebooted.
5. ‘who am i’ Command:
Syntax: $who am i
6. ‘tty’ Command:
It will display the terminal name.
Syntax:$tty
$bc operations
^d
15
1 base- inputbase
Base:
8. ‘CLEAR’ Command:
It is used to clear the screen.
Syntax: Sclear
9. ‘MAN’ Command:
It helps us to know about the particular command and its options & working. It is like “help”command in
windows.
If the command does not contain any argument means it is working in the Currentdirectory.
Options:
a. used to list all the files including the hidden files.
c-list all the files columnwise.
d- list all the directories.
m-list the files separated by commas.
p- list files include “/” to all the directories.
r- list the files in reverse alphabetical order.
f-list the files based on the list modification date.
x-list in column wise sorted order.
16
DIRECTORY RELATED COMMANDS:
Syntax: $pwd
2. MKDIR Command:
To create or make a new directory in a current directory.
3. CD Command:
To change or move the directory to the mentioned directory.
4. RMDIR Command:
To remove a directory in the current directory & not the current directory itself.
1. CREATE A FILE:
2. DISPLAY A FILE:
To display the content of file mentioned we use CAT command without “>” operator.
Syntax:$cat 18ilename
3. COPYING CONTENTS:
To copy the content of one file with another. If file doesnot exist, a new file is created and if thefile exists
with some data then it is overwritten.
Syntax:
$cat ?n <filename>
17
4. SORTING A FILE:
Syntax:
$sort<filename>
To copy the contents from source to destination file. So that both contents are same.
Syntax:
6. MOVE Command:
To completely move the contents from source file to destination file and to remove the sourcefile.
Syntax:
7. REMOVE Command:
Syntax:
$em <filename>
8. WORD Command:
Synatx:
$uc <filename>
9. LINE PRINTER:
To print the line through the printer, we use Ip command.
$lp <filename>
10. PAGE Command:
This command is used to display the contents of the file page wire & next page can be wed bypressing the
enter key.
Syntax:
$pg <filename>
18
11. FILTERS AND PIPES:
Syntax: $head-<filename>
TAIL: This command is used to display the last ten lines of file.
Syntax: $tail<filename>
PAGE: This command shows the page by page a screen full of information is displayed herwhich the page
command displays a prompt and passes for the user to strike the enter key tocontinue scrolling.
MORE: It also displays the file page by page. To continue scrolling with more command, pressthe space
bar key.
Syntax: $more<filename>
GREP: This command is used to search and print the specified patterns from the file.
SORT: This command is used to sort the data in some order.Syntax: $sort<filename>
PIPE: It is a mechanism by which the output of one command can be channeled into the inputof another
command.
Syntax: $who | we –l
TR: The tr filter is used to translate one set of characters from the standard inputs to another.Syntax: $tr “[a-
z]”“[A-Z]”
1. Commmand:MESG
Description: The message command is used to give permission to other users send message toyour terminal.
Syntax: $mesg y
2. Command: WRITE
Description: This command is used to communicate with other users, who are logged in at thetime.
19
4. Command: MAIL
Description: It refers to textual information, which can be transferred from one user to another
5. Command: REPLY
Description: It is used to send reply to specified user.
Result:
Thus the basic unix commands has been studied and executed successfully.
20
EXP No : 2b(i)
SHELL PROGRAMMING - CONCATENATION OF TWO STRINGS
DATE :
AIM:
ALGORITHM:
Step2 : To concatenate the two strings and store the result in a new variable,
Step 4:Stop.
21
PROGRAM:
read str1
read str2
OUTPUT:
22
EXP No : 2b(ii)
SHELL PROGRAMMING - COMPARISON OF TWO STRINGS
DATE :
AIM:
ALGORITHM:
Step 3: else
Step 4: Stop
23
PROGRAM:
read strl
read str2
if [ $strl = $str2]
then
else
fi
OUTPUT:
SAMPLE 1:
SAMPLE 2:
24
EXP No : 2b(iii)
SHELL PROGRAMMING - MAXIMUM OF THREE NUMBERS
DATE :
AIM:
ALGORITHM:
Step 1: Prompt the user to enter a values for A ,B,C using the `echo`
command.
Step 2:Read the values of A,B ,C using the `read` command and store it in the
variable`a`,’b’,’c’.
Step 3.1: If A is greater than both B and C, output "A is greater" using the `
echo` command.
Step 3.2:Else if B is greater than both A and C, output "B is greater" using
Step 3.3: Else, output "C is greater" using the `echo` command.
Step 4:Stop.
25
PROGRAM:
read a
read b
read c
then
then
else
fi
OUTPUT:
Enter A:23
Enter B:45
Enter C:67
C is greater
26
EXP No : 2b(iv)
SHELL PROGRAMMING - FIBONACCI SERIES
DATE :
AIM:
ALGORITHM:
Step 1:Start.
Step 6.3:b=show
Step 7:End
27
PROGRAM:
read n
a=-1
b=1
i=0
while [ $i ?le $n ]
do
t=’expr $a +$b’
echo $t
a=$b
b=$t
i=’expr $i + 1
done
OUTPUT:
0
1
1
2
3
5
28
EXP No : 2b(v)
SHELL PROGRAMMING - ARITHMETIC OPERATIONS
USING CASE
DATE :
AIM:
ALGORITHM:
Step 1: Start
Step 6: Stop
29
PROGRAM:
echo “ 1.Addition”
echo “2.Subraction”
echo “ 3.Multiplication”
echo “ 4.Division”
read a
read b
read c
echo” b is $b c is $c
”case $a in
::
2) d='expr $b -$c
echo” the difference is $d”
::
3) d='expr $b \ $c
echo “the product is $d”
::
4) d='expr $b / $c
echo “the quotient is $d”
::
esac
30
OUTPUT:
1. Addition
2. Subraction
3.Multiplication
4.Division
b is 3 c is 4
the sum is 7
RESULT:
Thus the given shell programs are implemented and output is verified successfully.
31
EXP No : 3(a)
PROCESS MANAGEMENT USING SYSTEM CALLS: FORK
DATE :
AIM:
FORK:
ALGORITHM:
Step 5: Otherwise
Step 6: Stop
32
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include <unistd.h>
#include<sys/types.h>
pid_t pid:
pid = fork();
if (pid==0)
exit(0);
else
exit(EXIT_FAILURE);
return 0;
33
OUTPUT:
34
EXP No : 3(b)
WAIT SYSTEM CALL
DATE :
AIM:
ALGORITHM:
Step 1:Define the main function with an integer return type and two arguments: argc` and
`argv`.
Step 2:Declare a variable `pid` of type `pid_t` to store the process ID returned by the fork()system call.
Step 3:Call the `fork()` system call to create a new process. The return value of `fork()` will be0 in the child
process and a positive integer (the child's PID) in the parent process. If `fork()` returns a negative value,
print an error message and exit the program with a failure status.
Step 3.1:If `pid` is equal to 0, the code inside the `if` block will be executed in the child process.Print a
message indicating that it is the child process and print its process ID using `getpid()`.
Step 5:Exit the child process with a status of 0 using the `exit()` function. If `pid` is greater than0, the code
inside the `else if block will be executed in the parent process. Print a message indicating that it is the
parent process and print its process ID using `getpid()`.
Step 6:Declare a variable `status` of type `int` to store the exit status of the child process.
Step 7:Call the `wait()` system call to wait for the child process to terminate and store its exitstatus in
`status`.
Step 8:Print a message indicating that the child process has been reaped.
Step 9:If `fork()` returns a negative value, print an error message and exit the program with afailure status.
35
PROGRAM:
#include<stdio.h> // printf()
#include<stdlib.h> // exit()
#include<sys/types.h> // pid_t
#include<sys/wait.h> // wait()
{pid_t pid
; pid = fork():
if(pid==0)
int i;
for(i=0;i<8;i++)
{ printf("%d\n",i);
) exit(0);
int status;
wait(&status);
printf("Child is reaped\n");
}
else
{printf("Error in forking..\n")
;exit(EXIT_FAILURE);
}
return 0;
}
36
OUTPUT:
Child is reaped
37
EXP No : 3(c)
GETPID SYSTEM CALL
DATE :
AIM:
ALGORITHM:
Step 3:If the return value of `fork()` is less than 0, print an error message indicating that theprocess ID
could not be obtained and exit the program with a status of 1.
Step 4:If the return value of `fork()` is greater than or equal to 0, continue to the next step.
Step 5:In the parent process, call the `getpid()` system call to obtain the process ID and store itin an integer
variable `pid_t`.
Step 8:Call the 'sleep() function for 1 second to delay the execution of the program.
38
PROGRAM:
#include <stdio.h>
#include <sys/types.h>
int main(void)
if((fork())<0)
exit(1);
else
printf("Process id is %d\n",pid_1):
sleep(1);
exit(0);
}
return 0;
39
EXP No : 3(d)
EXIT SYSTEM CALL
DATE :
AIM:
ALGORITHM:
Step 2:Prompt the user to enter the last number and read the input using `scanf`.
Step 4:Inside the loop, use an `if` statement to check if the value of `` is equalto 6.
Step 5:If the condition is true, terminate the program using the `exit()` function with anargument of 0 to
indicate successful termination.
Step 6:If the condition is false, print the value of `i using `printf`.
Step 8:Add another `exit(0)` statement after the return statement to ensure thatthe program always
40
PROGRAM:
#include <stdio.h>
#include <stdlib.h>i
nt main()
int i, num;
scanf("%d", &num);
if (i == 6)
/*use exit () statement with passing 0 argument to show termination of the program without anyerror
message. */
exit(0):
else
return 0;
41
OUTPUT:
It is obtained.
42
EXP No : 3(e)
CLOSE SYSTEM CALL
DATE :
AIM:
ALGORITHM:
Step 1:Declare a variable `filedesc` of type `size_t` to store the file descriptor returned by the
`open system call.
Step 2:Call the `open` system call with the filename "testfile.txt" and the flags `0_WRONLY`(to open the
file for writing only) and `0_CREAT` (to create the file if it does not exist).
Step 3: Check if the return value of `open` is less than 0. If it is, return 1 to indicate failure. Callthe `close`
system call with the file descriptor returned by `open`.
Step 4:Check if the return value of `close` is less than 0. If it is, return 1 to indicate failure.
43
PROGRAM:
#include <stdlib.h>
#include <fcntl.h>
int main(){
if(filedesc < 0)
return 1;
if(close(filedesc) < 0)
return 1;
return 0;
44
OUTPUT:
RESULT:
Thus the program process management using system calls: fork, exit, getpid wait ,closehas been
implemented and output is verified successfully.
45
EXP No : 4(a)
IMPLEMENTATION OF FCFS SCHEDULING
DATE :
AIM:
ALGORITHM:
Step 2:Take input for the number of processes (n), burst times (b), and arrival times(a).
Write a regular expression for an identifier and number.Calculate the waiting time (w) for eachprocess by
subtracting the arrival time from the completion time.
Step 5:Calculate the turnaround time (t) for each process by subtracting the arrival time fromthe completion
time.
Step 6:Calculate the average waiting time (awt) and average turnaround time (att) by summingup the
respective values for all processes and dividing by the
Step 8:Print the waiting time and turnaround time for each process and the average waiting timeand
46
PROGRAM:
#include<stdio.h>
main()
int n,a[10].b[10],t[10],w[10].g[10].i.m;
floatatt=0,awt=0;
for(i=0;i<10;i++)
{
scanf("%d", &n):
printf("enter the burst times");
for(i=0;i<n;i++)
scanf("%d",&b[i]);
printf("\nenter the arrival times");
for(i=0;i<n;i++)
scanf("%d",&a[i]):
g[0]=0;
for(i=0;i<10;i++)
g[i+1]=g[i]+b[i]:
for(i=0;i<n;i++)
{
w[i]=g[i]-a[i]:
[i]=g[i+1]-a[i]:
awt=awi+w[i];
att=att+1/i];
}
awt #awt/n;
att=att/n;
printf("process waiting time\turnaround time\n");
for(i=0;i<n;i++)
{
printf("\tp%d\\%d %d\n",i,w[i],t[i]);
printf("the average waiting time is %fn",awt);
printf("the average turn around time is %n",att);
}
47
OUTPUT:
4983
0243
Process Waiting time Turn around time
0 0 4
p1 2 11
p2 9 17
p3 18 21
RESULT:
Thus the program FCFS scheduling is implemented and output is verified successfully.
48
EXP No : 4(b)
IMPLEMENTATION OF SJF SCHEDULING
DATE :
AIM:
ALGORITHM:
If two process have same btime,then FCFS is used to resolve the tie.
Step 6: Compute average wtime and ttime for each process as:wtimei+1=wtimei+btimei
ttimei=wtimei+btimei
Step 7: Compute average waiting time awat and average turn around tine atur.
Step 11:Stop.
49
PROGRAM:
#include<stdio.h>
int main()
int nj,temp,templ,temp2,pr[10],[10],[10],[10],p[10],I;
float att=0,awt=0;
for(i=0;i<10;i++)
{
b[i]=0;w[i]=0;
}
scanf("%d",&n);
printf("enter the burst times");
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
p[i]=i;
for(i=0;i<n;i++)
for(j=i;j<n;j++)
if(b[i]>b[j])
{
temp=b[i];
templ=p[i];
p[i]=p[j];
50
b[j]=temp;
p[j]=templ;
}
w[0]=0;
for(i=0;i<n;i++)
w[i+1]=w[i]+b[i];
for(i=0;i<n;i++)
t[i]=w[i]+b[i];
awt=awt+w[i];
att=att+t[i];
}
awt=awt/n;
att=att/n;
printf("\t process \t waiting time \ t turn around time \n");
for(i=0;i<n;i++)
printf("\t p[%d] \t%d \t\t %d\n",p[i],w[i],t[i]);
printf("the average waitingtime is %f",awt);
printf("the average turn around time is %f\n",att);
return 1;
}
51
OUTPUT:
24568
p[0] 0 2
p[1] 2 6
p[2] 6 11
p[3] 11 17
p[4] 17 25
RESULT:
Thus the program sjf scheduling has been implemented and output is verifiedsuccessfully.
52
EXP No : 4(c)
IMPLEMENTATION OF PRIORITY SCHEDULING
DATE :
AIM:
To implement the priority scheduling using c programming.
ALGORITHM:
Step 1:Define an array of structure process with members pid, btime, pri, wtime & time,
Step 2: Get length of the ready queue, i.e., number of process (say n)
a. If two process have same pri, then FCFS is used to resolve the tie.
Step 7: Compute average waiting time away and average turn around time atur
Step 8: Display the brime, pri, time and wtime for each process.
53
PROGRAM:
#include<stdio.h>
int main()
scanf("%d", &n);
for(i=0;i<n;i++)
printf(“\nP[%d]\n”,i+1);
printf("Burst Time:");
scanf(“%d”,&bt[i]);
printf "Priority:")
scanf("%d",&pr[i]);
//sorting burst time, priority and process number in ascending order using selection sort
for(i=0;i<n;i++)
pos=i;
for(j=i+1:j<n;j++)
if(pr[j]<pr[pos])
pos=j;
}
temp=pr[i];
pr[i]=pr[pos];
pr[pos]=temp;
temp=bt[i];
54
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
wt[0]=0; //waiting time for first process is zero
for(i=1;i<n;i++)
wt[i]=0;
for(j=0;j<i;j++)
wt[i]+=bt[j];
total+=wt[i];
}
avg_wt=total/n;
total=0;
//average waiting time
for(i=0;i<n;i++)
return 0;
55
OUTPUT:
P[1]
Burst Time:6
Priority:3
P[2]
Burst Time:2
Priority:2
P[3]
Burst Time:14
Priority: 1
P[4]
Burst Time:6
Priority:4
p[3] 14 0 14
p[2] 2 14 16
p[3] 6 16 22
p[4] 6 22 28
56
RESULT:
Thus the program priority scheduling has been implemented and output is verifiedsuccessfully.
57
EXP No : 4(d)
IMPLEMENTATION OF ROUND ROBIN SCHEDULING
DATE :
AIM:
ALGORITHM:
Step 1: Get length of the ready queue, i.e., number of process (say n) .
Step 6: If Bi> TS then process takes more than one round. Therefore turnaround and waitingtime should
include the time spent for other remaining processes in the same round.
Step 9 : Display the burst time, turnaround time and wait time for each process (in order ofrounds they were
processed).
Step11: Stop
58
PROGRAM:
#include<stdio.h>
int main(){
int count,j,n,time,remain,flag=0,time quantum;
int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10];
printf("Enter Arrival Time and Burst Time for Process Process Numbered %d:"count+1);
scanf("%d",&at[count]);
scanf("%d", &bt[count]);
rt[count]=bt[count];
}
scanf("%d", &time_quantum);
printf("\n\nProcess\r| TurnaroundTime| Waiting Time\n\n");
for(time=0,count=0; remain!=0;)
{
if(rt[count]<=time_quantum&&rt[count]>0)
{
time+=rt[count]:
rt[count]=0;
flag=1;
}
else if(rt[count]>0)
rt[count]-time quantum;
time+time quantum;
}
if(rt[count]==0 && flag==1)
{
remain--;
wait_time+=time-at[count]-bt[count];
turnaround_ time+=time-at[count];
59
flag=0;
if(count ==n-1)
count=0;
else if(at[count+1]<=time)
count++;
else
count=0;
}
return 0;
OUTPUT:
Enter Arrival Time and Burst Time for Process Process Number 1:0
Enter Arrival Time and Burst Time for Process Process Number 2:1
Enter Arrival Time and Burst Time for Process Process Number 3:2
Enter Arrival Time and Burst Time for Process Process Number 4 :3
60
Process Turn Arround Time Waiting Time
P[2] 9 4
P[3] 11 8
P[4] 14 10
P[1] 21 12
RESULT:
Thus the program round robin schedling has been impelemented and output is verified
successfully.
61
EXP No : 5
INTER PROCESS COMMUNICATION USING SHARED
DATE : MEMORY
AIM:
ALGORITHM:
Step 3:shmat(): Before you can use a shared memory segment, you have to attach yourself
to it using shmat(). void *shmat(int shmid ,void *shmaddr ,int shmflg);
shmid is shared memory id. shmaddr specifies specific address to use but we should set
it to zero and OS will automatically choose the address
Step 4: shmdt(): When you’re done with the shared memory segment, your program should
detach itself from it using shmdt(). int shmdt(void *shmaddr);
Step 5: shmctl(): when you detach from shared memory,it is not destroyed. So, to destroy
shmctl() is used. shmctl(int shmid,IPC_RMID,NULL);
62
PROGRAM:
#include<stdio.h>
#include<sys/types.h>
#include<sys/shm.h>
#include<sys/ipc.h>
int main(){
child=fork();
if(!child)
shmid=shmget(2041,32,IPC_CREAT|0666);
shmptr=shmat(shmid,0,0);
for(i=0;i<10;i++)
shmptr[i]='a'+i; putchar(shmptr[i]);
}
printf("\n\n %s", shmptr);
wait(NULL);
else{
shmid=shmget(2041,32,0666);
shmptr=shmat(shmid,0,0);
for(i=0;i<10;i++)
putchar(shmptr[i]);
shmdt(NULL);
shmctl(shmid,IPC_RMID,NULL);
}
return 0;
63
OUTPUT:
Parent writing
abcdefghij
Child is reading
abcdefghij
RESULT:
Thus the program inter process communication using shared memory and output isverified
successfully.
64
EXP No : 6
MUTUAL EXCLUSION BY SEMAPHORE
DATE :
AIM:
ALGORITHM:
Step 1: 2 threads are being created, one 2 seconds after the first one.
Step 2: But the first thread will sleep for 4 seconds after acquiring the lock.
Step 3: Thus the second thread will not enter immediately after it is called, it will enter 4 – 2 = 2secs after
it is called.
Step 4: Stop.
65
PROGRAM:
#include <stdio.h>
int mutex=1,full=0,empty=3,x=0;
int main(){
int n
void producer();
void consumer();
int wait(int);
int signal(int);
printf(“\nl.Producern2.Consumer\n3.Exit”);
while(1)
{
printf("\nEnter your choice:");
scanf("%d",&n);
switch(n)
{
case 1: if((mutex==1)&&(empty!=0))
producer();
else
printf("Buffer is full!!"):
break;
case 2: if(mutex==1)&&(full!=0))
consumer();
else
printf("Buffer is empty!!");
break;
case 3:exit(0);
break;
}
return 0;
int wait(int s)
return (--s);
int signal(ints)
66
{
return(++s);
}
void producer()
{
mutex=wait(mutex);
full=signal(full);
empty=wait(empty);
x++;
printf("nProducer produces the item %d",x);
mutex=signal(mutex);
}
void consumer()
mutex=wait(mutex):
full=wait(full);
empty=signal(empty);
67
OUTPUT:
1.Producer
2.Consumer
3.Exit
RESULT:
Thus the program mutual exclusion by semaphore is implemented and output is verified
successfully.
68
EXP No : 7
BANKERS ALGORITHM FOR DEAD LOCK AVOIDANCE
DATE :
AIM:
ALGORITHM:
Step 9. Stop.
69
PROGRAM:
#include<stdio.h>
void main(){
int r[1][10],av[1][10];
int all[10][10],max[10][10],ne[10][10],w[10],safe[10];
int i=0,j=0,k=0,l=0,np=0,nr=0,count=0,cnt=0;
scanf("%d",&np);
scanf("%d",&nr);
for(i=1;i<=nr;i++)
{
scanf("%d",&r[0][i]);
av[0][i]=r[0][i];
for(j=1;j<=nr;j++) all[i][j]=ne[i][j]=max[i][j]=w[i]=0;
for(i=1;i<=np;i++)
{
printf("\n");
for(j=1;j<=nr;j++)
{
scanf("%d",&all[i][j]);
av[0][j]=av[0][j]-all[i][j];
scanf("%d",&max[i][j]);
}
}
for(i=1;i<=np;i++)
for(j=1;j<=nr;j++)
ne[i][j]=max[i][j]-all[i][j];
}
for(i=1;i<=np;i++)
printf("pocess P%d",i);
for(j=1;j<=nr;j++)
{
printf("maximum d",max[i][j]);
printf("need %d",ne[i][j]);
printf("\n _ \n”);
printf("\nAvailability");
for(i=1;i<=nr;i++)
printf("R%d %d\t",i,av[0][i]);
printf("\n _ \n”);
printf("\n safe sequence");
for (count=1:count<=np:count++)
for(j=1;j<=nr:j++)
71
{
cnt=0;
for(j=1;j<=nr:j++)
cnt++;
if(cnt==nr)
k++;
safe[k]=i;
for(l=1;1<=nr;1++)
av[0][1]=av[0][1]+all[i][l];
printf("n P%d ",safe[k]);
printf("\n Availability");
for(l=1;1<=nr;I++)
printf("R%d %d",lav[0][1]);
w[i]=1;
}
getch();
72
OUTPUT:
321
112
412
444
345
524
pocess P1
allocated 3
maximum 4
need 1
allocated 2
maximum 4
need 2
allocated 1
maximum 4
need 3
73
RESULT:
Thus the program bankers algorithm has been implemented and output is verifiedsuccessfully.
74
EXP No : 8
DEADLOCK DETECTION ALGORITHM
DATE :
AIM:
ALGORITHM:
Step1:Mark each process that has a row in the Allocation matrix of all zeros.
Step 3:Find an index i such that process i is currently unmarked and the i th row of Qis less thanor equal to
W. That is, Q ik... Wk, for 1 ... k... m. If no such row is found, terminate the algorithm.
Step 4: If such a row is found, mark processi and add the corresponding row of the allocationmatrix to W.
That is, set Wk = Wk + Aik, for 1 ... k... m. Return to step 3.
75
PROGRAM:
#include<stdio.h>
int i,j,np.nr;
int main()
scanf("%d", &nr);
for(i=0;i<nr;i++){
printf("Total Amount of the Resource R%d: ",i+1);
scanf("%d", &r[i]);
}
for(i=0;i<np;i++)
for(j=0;j<nrp;j++)
scanf("%d",&request[i][j]);
printf("Enter the allocation matrix:");
for(i=0;i<n;i++)
for(j=0;j<nr;j++)
scanf("%d",&alloc[i][j]);
/*Available Resource calculation*/
for(j=0;j<nr;j++)
{
avail[j]=r[j];
for(i=0;i<np:i++)
{
avail[j]-=alloc[i][j];
}
}
// marking processes with zero allocation
for(i=0;i<np;i++)
{
int count=0;
76
for(j=0;j<nr;j++)
if alloc[i][j]==0)
count++;
else break;
}
if(count==nr)
mark[i]=1;
// initialize W with avail
for(j=0;j<nr;j++)
w[j]=avail[j];
//mark processes with request less than or equal to W
for(i=0;i<n;i++)
int canbeprocessed=0;
if(mark[i]!=1)
{
for(j=0;j<nr:j++)
if request[i][j]<=w[j])canbeprocessed=1;
else
canbeprocessed=0;
break;
}
if(canbeprocessed)
{
mark[i]=1;
for(j=0;j<nr;j++)
w[j]+=alloc[i][j];
}
}
77
//checking for unmarked processes
int deadlock=0;
for(i=0;i<np;i++)
if(mark[i]!=1)
deadlock=1;
if(deadlock)
printf("n Deadlock detected");
else
78
OUTPUT:
01001
00101
00001
10101
00010
00000
Deadlock detected
RESULT:
Thus the program deadlock detection algorithm has been implemented and output isverified
successfully.
79
EXP No : 9
IMPLEMENT THREADING
DATE :
AIM:
ALGORITHM:
Step 3: Even if thread 2 is scheduled to start while thread was not done,access to shared
Step 5:Stop.
80
PROGRAM:
Thread creation
#include <unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
sleep(1);
printf("welcome!\n");
return NULL;
int main()
pthread_t tid;
printf("before thread");
pthread_create(&tid.NULL.mythread.NULL);
pthread_join(tid.NULL);
exit(0);
81
OUTPUT:
To Compile
cc filename.c -1 pthread
To Run
./a.out
RESULT:
Thus the program threading has been implemented and output is verified successfully.
82
EXP No : 10
PAGING TECHNIQUE
DATE :
AIM:
ALGORITHM:
Step1: Start.
Step 3: Compare no. of pages available and display it.Step 4: Determine the corresponding page.
83
PROGRAM:
#include<stdio.h>
int main()
clrscr();
scanf("%d",&ms);
scanf("%d",&ps);
nop = ms/ps;
printf("\nThe no. of pages available in memory are %d ",nop):
scanf("%d",&np);
rempages= nop;
for(i=1;i<=np;i++)
scanf(“%d”,&s[i]);
if(s[i] >rempages)
printf("\nMemory is Full");
break;
for(j=0;j<s[i];j++)
scanf("%d",&fno[i][j]);
84
printf("Enter Logical Address to find Physical Address -- ");
else
{
pa=fno[x][y]*ps+offset;
85
OUTPUT:
Memory is Full
RESULT:
` Thus the program paging technique has been implemented and output is verifiedsuccessfully.
86
EXP No : 11(a)
MEMORY MANAGEMENT SCHEMES FIRST FIT
DATE :
AIM:
ALGORITHM:
Step 1:Declare structures hole and process to hold information about set of holes andprocesses
respectively.
Step 7: Print the list of process and their allocated holes or unallocated status.
Step 8: Print the list of holes, their actual and current availability.
Step 9: Stop
87
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;
clrscr();
scanf("%d",&nf);
for(i=1;i<=nb;i++){
printf ("Block%d:",i);
scanf("%d",&b[i]);
for(i=i;i<=nf;i++)
{
scanf("%d",&f[i]);
for(i=1;i<=nf;i++)
for(j=1;j<=nb;j++)
{
if(temp>=0)
if( highest<temp)
ff[i]=j:
highest=temp;
frag[i]=highest:
bf[ff[i]]=1;
highest=0;
printf("\nFile_no:\File_size \Block_no:\Block_size:\Fragement");
for(i=1;i<=nf;i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\\%d",i,f[i],ff[i],b[ff[i]].frag[i]);
getch();
}
89
OUTPUT:
Block 1: 5
Block 2: 2
Block 3: 7
Enter the size of the files:-
File 1:1
File 2:4
1 1 3 7 6
2 4 1 5 1
RESULT:
Thus the program memory management schemes first fit has been implemented andoutput is
verified successfully.
90
EXP No : 11(b)
MEMORY MANAGEMENT SCHEMES BEST FIT
DATE :
AIM:
ALGORITHM:
Step 1: Declare structures hole and process to hold information about set of holes and processes
respectively.
Step 8: Print the list of holes, their actual and current availability.
Step 9: Stop
91
PROGRAM:
#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<=nb;i++)
scanf "%d",&b[i]);
for(i=1;i<=nf;i++)
{
scanf(“%d”,&f[i]);
for(j=1;j<=nb;j++)
if(bf[j]!=1)
temp=b[j]-f[i];
if(temp>=0)
if(lowest>temp)
{
92
ff[i]=j;
lowest=temp;
}
frag[i]=lowerst;
bf[ff[i]]=1;
lowest=10000;
}
for(i=1;i<=nf &&ff[i]!=0;i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,ƒ[i],ff[i],b[ff[i]],frag[i]);
getch();
}
93
OUTPUT:
Block 1: 5
Block 2: 2
Block 3: 7
File 1:1
File 2:4
1 1 2 2 1
2 4 1 5 1
RESULT:
Thus the program memory management schemes best fit has been implemented andoutput is
verified successfully.
94
EXP No : 11(c)
MEMORY MANAGEMENT SCHEMES WORST FIT
DATE :
AIM:
ALGORITM:
Step 1: Declare structures hole and process to hold information about set of holes and processes
respectively.
Step 7: Print the list of process and their allocated holes or unallocated status.
Step 8: Print the list of holes, their actual and current availability.
Step 9: Stop
95
PROGRAM:
#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;
scanf "%d",&nb);
for(i=1;i<=nb;i++)
{
scanf "%d",&b[i]);
for(i=1;i<=nf;i++)
scanf(“%d”,&f[i]);
for(j=1;j<=nb;j++)
if(bf[j]!=1)
temp=b[j]-f[i];
96
if(temp>=0)
{
ff[i]=j;
break;
}
}
}
frag[i]=temp;
bf[ff[i]]=l;
for(i=1;i<=nf;i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,ƒ[i],ff[i],b[ff[i]],frag[i]);
getch( );
97
OUTPUT:
Block 1: 5
Block 2: 2
Block 3: 7
1 1 1 5 4
2 4 3 7 3
RESULT:
Thus the program memory management schemes worst has been implemented and isverified
successfully.
98
EXP No : 12(a)
FIFO PAGE REPLACEMENT ALGORITHM
DATE :
AIM:
ALGORITHM:
Step 1 : Start.
Step 10 : Stop.
99
PROGRAM:
#include<stdio.h>
#include<conio.h> i
nti,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
void main()
{
clrscr();
scanf(“%d”,&nof);
printf(“\n enter number of reference string..\n”);
scanf(“%d”,&nor);
printf(“\n enter the reference string..”);
for(i=0;i<nor;i++)
scanf(“%d”,&ref[i]);
printf(“\n the given reference string:”);
for(i+0;i<nor;i++)
printf(“%4d”,ref[i]);
for(i=1;i<=nof;i++)
frm[i]=-1;
printf(“\n”); for(i=0;i<nor;i++)
{
flag=0;
for(j=0;j<nof;j++)
{
if(frm[j]==ref[i])
flag=1;
break;
}
}
if(flag==0)
100
pf++;
victim++;
victim=victim%nof;
frm[victim]=ref[i];
for(j=0;j<nof;j++)
printf(“%4d”,frm[j]);
}
getch();
}
101
OUTPUT:
……………………………
5 6 4 1 2 3
Reference np5-> 5 -1 -1 -1
Reference np6-> 5 6 -1 -1
Reference np4-> 5 6 4 -1
Reference np1-> 5 6 4 1
Reference np2-> 2 6 4 1
Reference np3-> 2 3 4 1
RESULT:
Thus the program FIFO page replacement algorithm has been implemented and output isverified
successfully.
102
EXP No : 12(b)
LRU PAGE REPLACEMENT ALGORITHM
DATE :
AIM:
ALGORITHM:
Step 7: For each page in reference string in the given order, examine:
Step 9: Stop.
103
PROGRAM:
#include<stdio.h>
#include<conio.h>
int i,j,nof,nor,flag=0,ref[50],frm[50],pf=0,victim=-1;
int recent[10],lrucal[50],count=0;
int lruvictim();
void main()
clrscr();
scanf("%d",&nof);
scanf("%d",&nor);
for(i=0;i<nor;i++)
scanf("%d",&ref[i]):
printf("n ...............................................................”);
for(i=0;i<nor;i++)
printf("%4d".reflil);
for(i=1;i<=nof;i++)
frm[i]=-1;
Irucal[i]=0;
for(i=0;i<10;i++)
recent[i]=0;
printf("\n");
104
for( i=0;i<nor;i++)
flag=0;
for(j=0;j<nof;j++)
if(frm[j]==ref[i])
flag=1;
break;
if flag==0)
count++;
if(count<=nof)
victim++;
else victim=lruvictim();
pf++;
frm/victim]=ref[i];
for(j=0;j<nof:j++)
printf("%4d" frm[j]);
recent[ref[i]]=i;
105
int lruvictim()
int i,j,templ,temp2;
for(i=0;i<nof;i++)
templ=frm[i]:
lrucal[i]=recent[templ];
temp2=lrucal[0];
for(j=1;j<nof;j++)
if(temp2>lrucal[j])
temp2=lrucal[j];
for(i=0;i<nef;i++)
if (ref[temp2]==frm[i])
return i;
return 0;
106
OUTPUT:
……………………6 5 4 2 3 1
Reference NO 6-> 6 -1 -1
Reference
NO 5->
Reference
NO 4->
Reference
NO 2->
Reference
NO 3->
Reference
NO 1->
No.of page
faults...6
RESULT:
Thus the program LRU page replacement algorithm has been implemented and output isverified
successfully.
107
EXP No : 12(c)
OPTIMAL (LFU) PAGE REPLACEMENT ALGORITHM
DATE :
AIM:
ALGORITHM:
1. Step 1: Get length of the reference string, say len.
2. Step 2:Get reference string and store it in an array, say rs.
3. Step 3: Get number of frames, say nf.
4. Step 4: Create access array to store counter that indicates a measure of recent usage.
5. Step 5: Create a function arrmin that returns position of minimum of the given array.
6. Step 6: Initalize frame array upto length nf to -1.
7. Step 7:Initialize position of the page replacement, say / to 0.
8. Step 8: Initialize freq to 0 to track page frequency
9. Step 9: Initialize no. of page faults, say count to 0.
10. Step 10: For each page in reference string in the given order, examine:
a. Check whether page exist in the frame array.
b. If page exist in memory then
i. Store incremented freq for that page position in access array.
c. If page does not exist in memory then
i. Check for any empty frames.
ii. If there is an empty frame,
Assign that frame to the page
Store incremented freq for that page position in access array.
Increment count.
108
PROGRAM:
#include<stdio.h>
#include<conio.h>
int i,j,nof,nor, flag=0,ref[50],frm[50],pf=0,victim=-1;
int recent[10].optcal[50].count=0;
int optvictim();
void main()
{
clrscr();
printf(“\n OPTIMAL PAGE REPLACEMENT ALGORITHN");
printf("\n .............................................................. ”);
printf ("\n Enter the no.of frames");
scanf("%d",&nof);
printf("Enter the no.of reference string"):
scanf("%d",&nor);
printf("Enter the reference string");
for(i=0;i<nor;i++)
scanf("%d",&ref[i]):
clrscr();
printf("\n OPTIMAL PAGE REPLACEMENT ALGORITHM"):
printf(" ........................................................................ ”);
for(i=0;i<10;i++)
recent[i]=0;
printf("\n");
for(i=0;i<nor;i++)
flag=0
printf("\n\tref no %d ->\"ref[i]);
for(j=0;j<nof;j++)
{
if(frm[j]==ref[i])
{
flag=1;
break;
}
if flag==0){ count++;
109
if(count<=nof)
victim++;
else victim=optvictim(i);
pf++;
frm[victim]=ref[i];
for(j=0;j<nof;j++)
printf("%4d" frm[j]);
}
}
printf("n Number of page faults: %d",pf);
getch();
}
int optvictim(int index)
{
int i,j,temp,notfound;
for(i=0;i<nof;i++)
{
notfound=1;
for(j=index;j<nor;j++)
if(frm[i]==ref[j])
{
notfound=0;
optcal[i]=j;
break;
}
if (notfound==1)
return i;
}
temp=optcal[0];
for(i=1;i<nof;i++)
if temp<optcal[i])
temp=opical[i];
for(i=0;i<nof;i++)
if frm[temp]==frm[i])
return i;
return 0;
}
110
OUTPUT:
……………………6 5 4 2 3 1
Reference NO 6-> 6 -1 -1
Reference
NO 5->
Reference
NO 4->
Reference
NO 2->
Reference
NO 3->
Reference
NO 1->
RESULT:
Thus the program optimal page replacement algorithm has been implemented and outputis verified
successfully.
111
EXP No : 13(a)
SINGLE LEVEL DIRECTORY USING FILE ORGANIZATION
DATE :
AIM:
ALGORITM:
Step 1 : Start
Step 2 : Get name of directory for the user to store all the files
Accept filename
Accept filename
112
PROGRAM:
#include<stdio.h>
Struct
{
char dname[10]fname[10][10];
int fcnt;
}dir;
void main()
int i,ch;
char f[30];
clrscr();
dir.fcnt = 0;
printf("Enter name of directory --");
scanf("%s", dir.dname);
while(1)
{
printf("\n\n l. Create File \t2. Delete File\t3. Search File \n4. Display Files \t5. Exit\nEnter yourchoice--");
scanf("%d", &ch);
switch(ch)
{
case 1:
scanf("%s",dir.fname[dir.fcnt]);
dir.fcnt++:
break;
case 2:
scanf("%s",f);
for(i=0;i<dir.fcnt;i++)
{
if(strcmp(f,dir.fname[i])==0)
{
printf("File %s is deleted ",f);
strcpy(dir.fname[i],dir.fname[dir.fcnt-1]);
break;
}
if(i==dir.fcnt)
--
break;
case 3:
printf("\n Enter the name of the file"--");
scanf("%s" f);
for(i=0;i<dir.fcnt;i++)
{
if(strcmp(f, dir.fname[i])==0)
printf("File %s is found ", f);
break;
}
break;
case 4:
if(dir.fcnt==0)
printf("nDirectory Empty");
else
{
printf("\nThe Files are --");
for(i=0;i<dir.fcnt; i++)
printf("%s",dir.fname[i]);
}
break;
default;exit(0);
}
getch();
114
OUTPUT:
1. Create File
2. Delete File 3. Search File
4. Display Files
5. Exit
Enter your choice -1
1. Create File
2. Delete File 3. Search File
4. Display Files
5. Exit
Enter your choice -1
1. Create File
2. Delete File 3. Search File
4. Display Files
5. Exit
Enter your choice -1
1. Create File
2. Delete File 3. Search File
4. Display Files
5. Exit
Enter your choice -4The Files are -A B C1.Create File
2. Delete File
3. Search File
4. Display Files
115
5. Exit
1. Create File
2. Delete File
3. Search File
4. Display Files
5. Exit
Enter your choice -2
1. Create File
2. Delete File
3. Search File
4. Display Files
5. Exit
Enter your choice -5
RESULT:
Thus the program has been implemented and output is verified successfully.
116
.
EXP No : 13(b)
TWO LEVEL DIRECTORY USING FILE ORGANIZATION
DATE :
AIM:
ALGORITHM:
If directory exist then accept filename without collision else report error
If file exist in that directory then delete entry else report error
If file exist in that directory then Display filename else report error
117
PROGRAM:
#include<stdio.h>
Struct
char dname[10],fname[10][10];
int fcnt;
}dir[10];
void main()
int i,ch,dcnt,k;
clrscr();
dcnt=0;
while(1)
printf("\n4. Search File\t\t5. Display \t6. Exit \tEnter your choice --");
scanf("%d", &ch);
switch(ch)
case 1:
scanf("%s", dir[dcnt].dname);
dir[dcnt].fcnt=0;
dcnt++;
printf("Directory created");
break;
case 2:
printf("Enter name of the directory --");
scanf("%s",d):
for(i=0;i<dcnt;i++)
118
if(strcmp(d.dir[i].dname)==0)
scanf("%s",dir[i].fname[dir[i]_fcnt]);
dir[i].fcnt++;
break;
if(i==dcnt)
break;
case 3:
scanf( "%s",d);
for(i=0;i<dcnt;i++)
if (strcm
p(d,dir[i].dname)==0)
{
for(k=0;k<dir[i], fcnt;k++)
{
if stremp(f, dir[i].fname[k])==0)
dir[i].fcnt--;
119
strcpy(dir[i].fname[k],dir[i].fname[dir[i].fcnt]);
goto jmp;
goto jmp;
}
}
jmp: break;
case 4:
scanf("%s",d);
for(i=0;i<dcnt;i++)
if(strcmp(d,dir[i].dname)==0)
for(k=0;k<dir[i].fcnt;k++)
if(strcmp(f,dir[i].fname[k])==0)
goto jmp1;
}
}
goto jmp 1;
120
}
break;
case 5:
if(dcnt==0)
else
for(i=0;i<dent;i++)
printf ("\t%s",dir[i].dname);
for(k=0;k<dir[i].fent;k++)
break;
default:exit(0);
getch();
121
OUTPUT:
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --1
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --1
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice -2
Enter name of the directory –DIRIEnter name of the file--Al
File created
122
1. Create Directory
2. Create File 3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --2
File created
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --2
File created
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice –2
File created
123
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --5Directory Files
DIR1
Al A2 DIR2BI
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --4
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice --3
File A2 is deleted
124
1. Create Directory
2. Create File
3. Delete File
4. Search File
5. Display
6. Exit
Enter your choice –6
RESULT:
Thus the program two level directory using file organization has been implemented andoutput is
verified successfully.
125
EXP No : 14(a)
SEQUENTIAL FILE ALLOCATION
DATE :
AIM:
ALGORITHM:
Step 1:Assume no. of blocks in the disk as 20 and all are free.
c. Check to see whether any block in the range (start, start + length-1) is allocated. If so,
then go to step 2.
d. Allocate blocks to the file contiguously from start block to start + length - 1.
Step 6:Stop
126
PROGRAM:
#include<stdio.h>
#include<conio.h>
int n,i,j,b[20],sb[20],t[20],x,c[20][20];
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&b[i]);
for(j=0;j<b[i];j++)
c[i][j]=sb[i]++;
for(i=0;i<n;i++)
printf("%d\t %d \t%d\n",i+1.t[i].b[i]);
scanf("%d",&x);
printf("blocks occupied:");
for(i=0;i<b[x-1];i++)
printf("%4d",c[x-1][i]);
getch();
127
OUTPUT:
1 2 4
2 5 10
RESULT:
Thus the program sequential file allocation has been implemented and output is verified
successfully.
128
EXP No : 14(b)
INDEXED FILE ALLOCATION
DATE :
AIM:
ALGORITHM:
Step 2:Accept filenames and no, of blocks fo each fileStep 3: Obtrain start block for each file
Step 9: Stop
129
PROGRAM:
#include<stdio.h>
#include<conio.h>
main(){
int ,n,m[20],i,j,sb[20],s[20],b[20][20],x;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d",&sb[i],&s[i]);
scanf("%d",&m[i]);
for(j=0;j<m[i];j++)
scanf("%d",&b[i][j]);
printf("\nFile\t index\length\n");for(i=0;i<n;i++){
scanf("%d", &x);
i=x-1;
printf("Index is:%d",sb[i]);
for(j=0;j<m[i];j++)
printf("%3d",b[i][j]);
getch();
130
OUTPUT:
2 5 4 6 7 2 6 4 7
1 2 10
2 3 5
RESULT:
Thus the program indexed file allocation has been implemented and output is verified
successfully.
131
EXP No : 14(c)
LINKED FILE ALLOCATION
DATE :
AIM:
ALGORITHM:
Step 9: Stop
132
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct file
char frame[10];
int start,size,block[10];
}f[10];
scanf ("%d",&n);
for(i=0;i<n;i++){
scanf("%s",&f[i].fname);
scanf("%d",&f[i].start);
f[i].block[0]=f[i].start;
scanf("%d",&f[i].size);
for(j=1;j<=f[i].size;j++){
scanf("%d",&f[i].block[j]);
printf("File\tstart\tsize\tblock\n");
for(i=0;i<n;i++)
133
{
printf("%s\t%d\t%d\t" f[i].fname,f[i].start.f[i].size);
for(j=1;j<=f[i].size-1;j++)
printf(“%d--->”f[j]);
printf(“%d”f[i].block[j]);
printf(“\n);
getch();
134
OUTPUT:
Enter no of files:2
Enter file name:venkat
Enter starting block:20
Enter no.of blocks:6
Enter block numbers: 4
12
15
45
32
25
rajesh 12 5 6--5---4---3--->2
RESULT:
Thus the program linked file allocation has been implemented and output is verifiedsuccessfully.
135
EXP No : 15(a)
FCFS DISK SCHEDLING
DATE :
AIM:
ALGORITHM:
Step 1.Define an array of structure process with members pid, btime, wtime & ttime
.Step 2.Get length of the ready queue, i.e., number of process (say n).
a. wtimei+1= wtime,+btimei
b. ttime =wtimei+btimei
Step 6. Compute average waiting time awat and average turnaround time atur
process.
136
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
int main()
int RQ[100],i,n,TotalHeadMoment=0,initial;
scanf("%d",&n);
;for(i=0;i<n;i++)
scanf("%d",&RQ[i]);
scanf("%d",&initial);
for(i=0;i<n;i++)
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
return 0;
137
OUTPUT:
50
RESULT:
Thus the program FCFS disk scheduling has been implemented and output is verifiedsuccessfully.
138
EXP No : 15(b)
SSTF DISK SCHEDULING
DATE :
AIM:
ALGORITHM:
Step 1.Define an array of structure process with members pid, btime, wtime & ttime.
Step 2.Get length of the ready queue, i.e., number of process (say n).
a. wtimei+1= wtime,+btimei
b. ttime =wtimei+btimei
Step 6. Compute average waiting time awat and average turnaround time atur
process.
139
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
int main()
int RQ[100],in, TotalHeadMoment=0,initial,count=0;
printf ("Enter the number of Requests\n");
scanf(“%d”,&n);
scanf ("%d",&initial);
while(count!=n)
int min=1000,d,index;
for(i=0;i<n;i++)
if(min>d)
min=d;
index=i:
TotalHeadMoment=TotalHeadMoment+min;
initial=RQ[index]:
count++;
}
printf ("Total head movement is %d”,TotalHeadMoment);
return 0;
140
OUTPUT:
RESULT:
Thus the program sstf disk scheduling has been implemented and output is verifiedsuccessfully.
141
EXP No : 15(c)
SCAN DISK SCHEDULING
DATE :
AIM:
ALGORITHM:
Step 1.Define an array of structure process with members pid, btime, wtime & ttime.
Step 2.Get length of the ready queue, i.e., number of process (say n).
a. wtimei+1= wtime,+btimei
b. ttime =wtimei+btimei
Step 6. Compute average waiting time awat and average turnaround time atur
process.
142
PROGRAM:
#include<stdi o.h>
#include<math.h>
int main()
float avg;
scanf(“%d”,&max);
scanf(“%d”, &head);
scanf(“%d”,&n);
1; i<= n; i++)
Scanf(“%d”,&tem
p);
queue1[temp1] = temp;
temp1++;
else
queue2[temp2] =
temp;temp2++;
143
}
{
If (queue l[i]> queue l [j])
queue1[i]
=queue1[j];
queue1[j] =temp;
if(queue2[i]< queue2[j])
temp = queue2[i];
queue2[i] =
queue2[i];queue2[j]
= temp;
}}
queue[i] = queue1[j];
144
queuei] = max;
for (i=templ + 2, j = 0;
seek += diff;
diff);
return 0;
145
OUTPUT:
RESULT:
Thus the program scan disk scheduling has been implemented and output is verifiedsuccessfully.
146
EXP No : 16
INSTALL ANY GUEST OPERATING SYSTEM LIKE LINUX USING
DATE : VMWARE
AIM
ALGORITHM:
Step 1: Download the VMWare workstation. Set up is around 307 MB. Currently, version 12 isavailable.
Please note we have set up screens on version 11.
Step2: Install VMWarre on your machine. Setup is simple and requires clicking NextButton a couple of
times.
Step3: After installation open the VMWare workstation by using either the start menu orshortcut created
on the desktop.
Step7: In the Next step you need to specify a key or a serial number of the operating system.If you are
using the version then that part can be skipped.
Step8: Enter the names for the virtual machine and specify a path to the directory where you want to
create your virtual machine. It is recommended that the drive you’re selecting to install avirtual machine
should have sufficient space.
Step9: Specify the amount of disk space you want to allocate for a virtual machine.
Allocate disk space according to the size of the software you are going to install on the virtualmachine.
Step10:On the next screen it will show the configuration you selected for a virtual machine.
Step11:It will allocate Hardware according to the default setting but you can change it byusing Customize
button in the above screen.
You can specify what amount of RAM. A processor has to be allocated for a virtualmachine. Do not
allocate complete RAM or a complete Processor for a virtual machine. Also, donot allocate very little
RAM or processor. Leave default setting or allocate in such a way that your application should be able to
run on the virtual machine. Else it will result in a show virtualmachine.
Step12:Click on the Finish button to create the virtual machine at the specified location andwith specified
resources.
If you have specified a valid file (.iso, .rar., .nrg) for the operating system it will take standard
time to complete the operating system setup on the virtual machine, and then it will beready to use your
regular OS
147