OS lab Manual
OS lab Manual
AIM:
To study about Installation of Windows Operating Systems.
PROCEDURE:
Installing a Windows operating system
The wizard provides a step by step guidance for installing an operating system. Follow the
instructions on the screen and the tips listed below to install a Windows operating system.
1. Drive Selection
Figure 1. Drive Selection step (for Windows)
Attention: The selected drive will be formatted during the installation. Back up all data on it
before the installation.
Note: The drivers will be installed automatically after the OS installation. It is recommended to
restart your server to ensure that all installed drivers take effect.
2. OS Selection
Figure 2. OS Selection step (for Windows)
The IP address is made up of four parts separated by dots. The following table lists the valid
value range for each part.
IP Address Part 1 Part 2 Part 3 Part 4
Valid values 1 – 223 0 – 255 0 – 255 0 – 255
3. Installation Settings
Figure 3. Installation Settings step – 1 (for Windows)
Administrator Password: You can change your administrator password later from the operating
system.
If you want to do advanced configurations, expand the list by clicking the arrow icon next
to Advanced.
Figure 4. Installation Settings step – 2 (for Windows)
Refer to the following table for the valid values when you type the required address information.
Address Part 1 Part 2 Part 3 Part 4
IP Address 1 – 126; 128 – 223 0 – 255 0 – 255 1 – 254
Subnet Mask 0 – 255 0 – 255 0 – 255 0 – 255
Default Gateway 0 – 255 0 – 255 0 – 255 0 – 255
Preferred DNS Server 1 – 126; 128 – 223 0 – 255 0 – 255 0 – 255
Alternate DNS Server 1 – 126; 128 – 223 0 – 255 0 – 255 0 – 255
Figure 5. Installation Settings step – 3 (for Windows)
Components: You can select one or more components for installation according to your
requirements.
Include run-once commands: If you want to run specified commands at the end of the
installation process, select the check box. A command-type area is displayed. Type one
command and click Add. The command is added to the command list. You can add five
commands at most. If you want to remove a certain command, select it and click Remove. The
commands in the command list will be run one time only and in the order you type them.
4. Partition Options
Figure 6. Partition Options step (for Windows)
If no existing partition is detected on the drive, select Repartition the drive during installation.
RESULT:
The above program has been executed successfully
Ex.No:2.a BASICS OF UNIX COMMANDS
Date:
AIM
To study various UNIX command in detail.
Command : Cat
Purpose : It is used to display the contents of the file as well as used to create a new file.
Command : More
Purpose : It is used to display the contents of the file on the screen at a time.
Command : Wc
Purpose : It is used to count the number of lines ,words and characters in a file or group of files.
Command : File
Command : Spell
Purpose : It is used to split the given file into smaller pieces of given size.
Syntax : split –size <file name > < splitted file name >
Example : $ split –2 devi de
Command : Cp
Command : Mv
Purpose : It is used to move a file within a directory with different names and also used to move
a file to different directory with its original name.
Command : Rm
Command : chmod
Purpose : It is used to change the file permissions. In the terminal, the command to use to change
file permission is “ chmod “. In short, “chmod 777” means making the file readable, writable
and executable by everyone.
Command : cd
Purpose : It is used to change the control from one working directory to another specified
directory.
Command : cd ..
Purpose : It is used to quit from current directory and move to the previous
directory.
Syntax : cd ..
Example : $ cd ..
Command : Who
Purpose : It is used to get the information about all the users currently working in the system.
Syntax : who
Example : $ who
Command : Who am i
Purpose : It is used to know in which terminal the user is currently logged on.
Syntax : who am i
Example : $ who am I
Command : Date
Purpose : It is used to display the system date and time.
Syntax : date
Example : $ date
Command : Cal
Purpose : It prints the calender for the specified year and month.
Command : Id
Purpose : It is used to display the login name.
Syntax : id
Example : $
id
Command : Clear
Syntax : clear
Example : $ clear
Command : Uname
Purpose : It is used to display the details about the OS in which we are working.
Command : Tty
Syntax : tty
Example : $ tty
Command : Pwd
Purpose : It is used to display the absolute pathname of current working directory.
Syntax : pwd
Example : $ pwd
Command : Bc
Syntax : bc <operation>
Example : $ bc 3+5 8 ^d
Command : Ls
Command : Echo
Command : Man
Purpose : It gives details about the unix commands.
Command : Tail
Command : Pr
Purpose : It is used to display the contents of the file by separating them into pages and each
page begins with the header information.
Command : Cut
Purpose : It is used to extract selected fields or columns from each line of one or more files and
display them on the standard output device.
Command : Paste
Purpose : It concatenates the line from each input file column by column with tab characters in
between them.
Command : Join
Purpose : It is used to extracts common lines from two sorted files and there should be the
common field in both file.
Command : Uniq
Purpose : It compares adjacent lines in the file and displays the output by eliminating duplicate
adjacent lines in it.
Command : Sort
Purpose : It sorts one or more files based on ASCII sequence and also to merge the file.
Syntax : sort [options] <file name >
Example : $ sort -r devi
Command : Nl
Purpose : It is used to add the line numbers to the file.
Command : grep
Purpose : It is used to search the specified pattern from one or more files.
RESULT:
AIM
To write a shell PROGRAM to convert the given Fahrenheit value to centigrade value.
ALGORITHM
Step 1 : Start
Step 2 : Read Fahrenheit value
Step 3 : Convert Fahrenheit to centigrade using the formulae: (Fahrenheit – 32) × 5/9
Step 4 : Print centigrade
Step 5 : Stop
PROGRAM (degconv.sh)
# Degree conversion
echo "Enter Fahrenheit : "
read f
c=`expr \( $f - 32 \) \* 5 / 9`
echo "Centigrade is : $c"
OUTPUT
[Cse@localhost ~]$ sh degconv.sh
Enter Fahrenheit : 213
Centigrade is : 100
RESULT
The above program has been executed successfully
EX NO: 2.C AREA AND CIRCUMFERENCE OF A
CIRCLE DATE:
AIM
To write a shell PROGRAM to find area and circumference of the circle
ALGORITHM
Step 1: Start
Step 2: read the value of radius in r
Step 3: Calculate area using the formula 3.14*r*r
Step 4: Calculate circumference using the formula 2*3.14*r
Step 5: print the area and circumference
Step 6: stop
PROGRAM (area.sh)
echo "Enter the radius of the circle"
read r
area=`expr 22 / 7 \* $r \* r`
cf=`expr 2 \* 22 / 7 $r`
echo "Area of circle=
$area"
echo "circumference of circle= $cf"
OUTPUT
[Cse@localhost ~]$ sh area.sh
Enter the radius of the circle
3
Area of circle= 28
Circumference of circle= 18
RESULT
The above program has been executed successfully
EX NO:2.D SIMPLE INTEREST
CALCULATION DATE:
AIM
To write a shell PROGRAM to calculate simple interest.
ALGORITHM
Step 1 : Start
Step 2 : Read the values principal, rate and years
Step 3 : Compute simpleinterest using the formulae: (principal × rate × years) / 100
Step 4 : Print simpleinterest
Step 5 : Stop PROGRAM
PROGRAM (simpint.sh)
echo "Enter Principal amount : "
read p
echo "Enter number of years : "
read n
echo "Enter rate of interest : "
read r
si=`expr "scale=2; $p * $n *$r / 100" | bc`
echo "Simple Interest : $si"
OUTPUT
[Cse@localhost ~]$ sh simpint.sh
Enter Principal amount : 1285 Enter number of years : 3
Enter rate of interest : 5
Simple Interest: 192.75
RESULT
The above program has been executed successfully
EX NO: 2.E PROGRAM TO SWAP THE TWO
NUMBERS DATE:
AIM
To write a shell PROGRAM to swap the values of two variables without using third variable.
ALGORITHM
Step 1 : Start
Step 2 : Read the values of x and y
Step 3 : Print the value of x and y before swapping
Step 4 : swap the values of two variables without using third variable
Step 5 : Print the value of x and y after swapping
Step 6 : Stop the PROGRAM
PROGRAM(swap.sh)
echo "Enter the value of x and y"
read x y
echo "Before swapping x=$x
y=$y" x=`expr $x + $y`
y=`expr $x - $y`
x=`expr $x - $y`
echo "After swapping x=$x y=$y"
OUTPUT
[Cse@localhost ~]$ sh swap..sh
Enter the value of x and y
35
Before swapping x=3 y=5
After swapping x=5 y=3
RESULT
The above program has been executed successfully
EX NO: 2.F ODD OR
EVEN DATE:
AIM
To write a shell PROGRAM to check the given number is even or odd.
ALGORITHM
Step 1 : Start
Step 2 : Read number
Step 3 : If number divisible by 2 then Print "Number is Even"
Step 3.1 : else Print "Number is Odd"
Step 4 : Stop
PROGRAM (oddeven.sh)
echo "Enter a non-zero number :
" read num rem=`expr $num % 2`
if [ $rem -eq 0 ]
then
echo "$num is Even"
else
echo "$num is Odd"
fi
OUTPUT
[Cse@localhost ~]$ sh oddeven.sh
Enter a non-zero number: 12
12 is Even
RESULT
PROGRAM (big3.sh)
echo "Give value for A B and C: "
read a b c
if [ $a -gt $b -a $a -gt $c ]
then
echo "A is the Biggest number"
elif [ $b -gt $c ]
then
echo "B is the Biggest number"
else
echo "C is the Biggest number"
fi
OUTPUT
[Cse@localhost ~]$ sh big3.sh
Give value for A B and C: 4 3 6
C is the Biggest number
RESULT
The above program has been executed successfully
EX NO: 2.H SIMPLE
CALCULATOR DATE:
AIM
To write a shell PROGRAM to design the simple calculator using case statement.
ALGORITHM
Step 1 : Start
Step 2 : Read operands a and b
Step 3 : Read option
Step 4 : If option = 1 then Calculate c = a + b
Step 4.1 : else if option = 2 then Calculate c = a – b
Step 4.2 : else if option = 3 then Calculate c = a * b
Step 4.3 : else if option = 4 then Calculate c = a / b
Step 4.4 : else if option = 5 then Calculate c = a % b
Step 4.5 : else Print "Invalid option"
Step 5 : Print c
Step 6 : Stop Shell PROGRAM.
PROGRAM (calc.sh)
echo "Enter the two numbers : "
read a b
echo " 1. Addition"
echo " 2. Subtraction"
echo " 3. Multiplication"
echo " 4. Division"
echo " 5. Modulo Division"
echo "Enter the option : "
read option
case $option in
1) c=`expr $a + $b` echo "$a + $b = $c";;
2) c=`expr $a - $b` echo "$a - $b = $c";;
3) c=`expr $a \* $b` echo "$a * $b = $c";;
4) c=`expr $a / $b` echo "$a / $b = $c";;
5) c=`expr $a % $b` echo "$a % $b = $c";;
*) echo "Invalid Option"
esac
OUTPUT
[Cse@localhost ~]$ sh calc.sh
Enter the two numbers : 2 4
1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Modulo Division
2. Enter the option : 1
3. 2 + 4 = 6
RESULT
The above program has been executed successfully
EX NO: 2.I EXECUTE VARIOUS UNIX COMMANDS USING CASE STATEMENTS
DATE:
AIM
To write a shell PROGRAM to do the execution of various unix commands using case
statement.
ALGORITHM
Step 1 : Start
Step 2 : Read choice from user
Step 3 : Perform the operation of corresponding unix commands as per the choice given
by the user.
Step 4 : Stop Shell PROGRAMming
PROGRAM (case.sh)
echo “Enter your choice”
read choice
case $choice in
1) pwd ;;
2) date ;;
3) ls ;;
4) who am i ;;
5) exit ;;
*)echo “Invalid
choice” esac
OUTPUT:
[Cse@localhost ~]$ sh arithmetic.sh
Enter your choice
3
area.sh simple.sh swap.sh oddoreven.sh leap.sh positive.sh
biggest.sh studentgrade.sh arithmetic.sh
RESULT
The above program has been executed successfully
EX NO: 2.J FACTORIAL OF A GIVEN
NUMBER DATE:
AIM:
To find the factorial of a given number.
ALGORITHM:
Step 1: Begin the
PROGRAM. Step 2: Read the
value of n.
Step 3: set the initial value, fact=1 and i=1.
Step 4: while(i<=n), then fact=fact*i and
i=i+1. Step 5: print fact.
Step 6: End the PROGRAM.
PROGRAM (fact.sh)
echo "Enter the Number :
" read n
f=1
i=1
while [ $i -le $n ]
do
f=`expr $f \* $i`
i=`expr $i + 1`
done
echo "The factorial $n! = $f"
OUTPUT
[Cse@localhost ~]$ sh fact.sh
Enter a positive number : 10
Factorial value : 3628800
RESULT:
The above program has been executed successfully
EX NO: 2.K PROGRAM TO FIND AND DISPLAY STUDENT
GRADE DATE:
AIM
To write a shell PROGRAM for finding and displaying student grade.
ALGORITHM
Step 1 : Start
Step 2 : Read student name, register number and 5 subject marks
Step 3 : If any of the subject mark is < 50 then
Print "fail"
Step 3.1 : else calculate the total and average (avg) for the given marks
Step 4 : if avg > 75 then
Print "First class with distinction"
Step 4.1 : else if avg > 65 then
Print "First Class"
Step 4.2 : else if avg > 65 then
Print "Second Class"
Step 4.3 : else Print "Third class"
Step 5: Stop
PROGRAM (studentgrade.sh)
echo “Enter student name”
read name
echo “Enter the student register no”
read no
echo “Enter the 5 subject marks”
read m1 m2 m3 m4 m5
total=`expr $m1 + $m2 + $m3 + $m4 + $m5`
avg=`expr $total / 5`
echo ” TOTAL MARKS = $total”
echo “AVERAGE = $avg”
if [ $m1 -lt 50 -o $m2 -lt 50 -o $m3 -lt 50 -o $m4 -lt 50 -o $m5 -lt 50 ]
then
echo “RESULT = FAIL”
exit
else
echo “RESULT = PASS”
fi
if [ $avg -ge 75 ]
then
echo “Grade = FIRST CLASS WITH DISTINCTION”
elif [ $avg -ge 65 ]
then
echo “Grade = FIRST CLASS”
elif [ $avg -lt 65 ]
then
echo “Grade = SECOND CLASS”
else
echo “Grade = THIRD CLASS”
fi
OUTPUT
[Cse@localhost ~]$ sh studentgrade.sh
Enter student
name XXX
Enter the student register no
12345
Enter the 5 subject marks
75 80 82 93 90
TOTAL MARKS = 420
AVERAGE = 84
RESULT = PASS
Grade = FIRST CLASS WITH DISTINCTION
RESULT:
PROGRAM (fibo.sh)
echo "Enter the Limit : "
read n
a=0
b=1
echo "FIBONACCI SERIES"
while [ $a -lt $n ]
do
echo "$a"
c=`expr $a + $b`
a=$b
b=$c
done
OUTPUT
[Cse@localhost ~]$ sh fibo.sh
Enter number of terms : 8
Fibonacci Series
0 1 1 2 3 5 8 13
RESULT:
PROGRAM (prime.sh)
echo "Enter the number : "
read num
i=2
do
then
break;
fi
i=`expr $i + 1`
done
then
else
fi
OUTPUT
[Cse@localhost ~]$sh prime.sh
Enter the number : 17
The number 17 is prime
RESULT:
The above program has been executed successfully
EX NO: 2.N PALINDROME OR
NOT DATE:
AIM:
To find sum of Digits, Reverse and the given Number is Palindrome or not.
ALGORITHM:
Step-1 Begin the
PROGRAM. Step-2 Enter the
number.
Step-3 when n=num, rev=0 & num>0 then goto step 4.
Step-4 when condition in step 3 is satisfied, perform a=n%10, rev=rev*10+a and n=n/10.
Step-6 Find whether the reverse number is equal to the given number or not.
If equal the number is palindrome
Step-7: If not equal the given number is not
palindrome Step-8: End the PROGRAM.
PROGRAM (palindrome.sh)
echo "Enter the number : "
read num
n=$num
rev=0
while [ $n -gt 0 ]
do
a=`expr $n % 10`
rev=`expr $rev \* 10 +
$a` n=`expr $n / 10`
done
RESULT:
The above program has been executed successfully
EX NO: 2.O TO CHECK WHETHER THE GIVEN STRING IS PALINDROME OR NOT
DATE:
AIM:
To write a shell PROGRAM to check whether the given string is palindrome or not.
ALGORITHM:
Step 1:Begin the PROGRAM.
Step 3: Reverse the string by using rev command and assign it into revstr variable.
Step 4: If the given string = revstr, then print the given string is Palindrome. Otherwise print the
given string is NOT Palindrome.
read str
if [ $str = $revstr ]
then
else
fi
OUTPUT: [Cse@localhost ~]$ sh spalindrome.sh
Enter the string
Malayalam
Malayalam is palindrome
RESULT:
The above program has been executed successfully
EX NO: 2.P PROGRAM TO COUNT THE NUMBER OF VOWELS,
CONSONANTS DATE: AND DIGITS IN THE GIVEN TEXT
AIM
To write a shell script to count the number of vowels, consonants and digits in the given text.
ALGORITHM
Step 1: Begin the PROGRAM.
Step 2: Get the string and find the length of the string.
Step 3: Initially vowel count=0 and consonant count=0.
Step 4: Use while loop and get the character one by one in the string, If it is vowel then take it as
vowel count. If it is not vowel take it as consonant count.
Step 5: Finally print the vowel count and consonant
count. Step 6: End the PROGRAM.
PROGRAM (vowels.sh)
read str
i=1
vc=0
cc=0
dig=0
len=`echo "$str"|wc -
c` while((i<=len))
do
ch=`echo "$str"|cut -
i` case $ch in
[aAeEiIoOuU]) ((vc++)) ;;
[0123456789]) ((dig++));;
*))((cc++)) ;;
esac
((i++))
done
echo "No of
of Digits=$dig”
OUTPUT:
[Cse@localhost ~]$ sh vowels.sh
Enter the string
Ams2016
No of vowels=1
No of
consonants=2 No
of Digits=4
RESULT
The above program has been executed successfully
PROGRAMS USING SYSTEM CALLS
AIM
To write a UNIX C program to create a child process from parent process using fork()
system call.
ALGORITHM
PROGRAM
#include<stdio.h>
#include<unistd.h>
main()
{
fork();
printf("Hello World\n");
}
OUTPUT
RESULT
The above program has been executed successfully
EX.NO: 3.B SIMULATION OF FORK, GETPID AND WAIT SYSTEM CALLS
DATE:
AIM
To write a UNIX C program simulate fork(),getpid() and wait() system call.
ALGORITHM
Step 1: Invoke a fork() system call to create a child process that is a duplicate of parent
process. Step 2: Retrieve the process id of parent and child process.
Step 3: If return value of the fork system call=0(i.e.,child process),generate the fibonacii series.
Step 4: If return value of the fork system call>0(i.e.,parent process),wait until the child
completes.
PROGRAM
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<conio.h>
main()
{
int a=-1,b=1,i,c=a+b,n,pid,cpid;
printf("\nenter no. of terms ");
scanf("%d",&n);
pid=getpid();
printf("\nparent process id is %d",pid);
pid=fork();
cpid=getpid();
printf("\nchild process:%d",cpid);
if(pid==0)
{
printf("\nchild is producing fibonacci series ");
for(i=0;i<n;i++)
{
c=a+b; printf("\n
%d",c); a=b;
b=c;
}
printf("\nchild ends");
}
else
{
printf("\nparent is waiting for child to complete");
wait(NULL); printf("\
nparent ends");
}
}
OUTPUT
[it27@mm4 ~]$ cc fork.c
[it27@mm4 ~]$ a.out
parent process id is
8723 child process:8723
parent process id is
8723 child process:8732
child is producing fibonacci series
0
1
1
2
3
child endsparent is waiting for child to complete
RESULT
AIM
To write a UNIX C program to implement execlp() system call.
ALGORITHM
Step 1:Use fork() system call to create a child process and assigns its id to pid variable.
Step 2: If the pid<0,an error message is displayed.
Step 3:If the pid is equal to zero,execlp() system call is invoked and the child process is
overwritten by the files in the directory.
Step 4:If the pid is greater than zero,display a message.
PROGRAM
#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
main()
{
int pid;
pid=fork();
if(pid<0)
{
fprintf(stderr,"fork failed\n");
exit(-1);
}
else if(pid==0)
{
execlp("/bin/ls","ls",NULL);
}
else
{
wait(NULL);
printf("Child Complete");
exit(0);
}
OUTPUT
[it1@localhost ~]$ cc ex1c.c
[it1@localhost ~]$ ./a.out
a1 ara.c arunv ex1aa.c facts itbgals kp matrix.v pre.c rad2.sh rad.c sk
wooow
a2 arain.c baabaaa ex1a.c fib.c k1 lee obu priya rad3.sh rad.sh ss xxx
a.c arav.c cat ex1b.c fio k2 lyffactz os rad1.c rad4.c sat sum.c
RESULT
The above program has been executed successfully
X. NO: 3.D SIMULATION OF I/O SYSTEM
CALLS DATE:
AIM
To write a UNIX C program to simulate I/O system calls such as open, read and write.
ALGORITHM
Step 1: Start the program.
Step 2: Enter the filename to be opened.
Step 3: Using open () system call, open the file in read only mode.
Step 4: Using read () system call, read the content through the file descriptors and put it in a
buffer.
Step 5: Display the content of the buffer.
Step 6: Stop the program.
PROGRAM
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
int fd;
char buf1[100],fname[30];
printf("Enter the filename:");
scanf("%s",fname);
fd=open(fname,O_RDONLY);
read(fd,buf1,30);
printf("\n The content is %s:",buf1);
close(fd);
}
OUTPUT
[it3@localhost ~]$ cc io.c
[it3@localhost ~]$ ./a.out
Enter the filename:f1
The content is : hi
Hello
RESULT
The above program has been executed successfully
EXP NO:4A
FIRST COME FIRST SERVE SCHEDULING
DATE:
AIM
To write the c program to implement first come first serve CPU scheduling algorithm.
ALGORITHM
3. Get the no of process and burst time of each process using for loop.
4. Find the waiting time of each process and turnaround time of each process.
5. Find the total waiting time and total turnaround time form individual process.
#include<stdio.h>
#include<stdlib.h>
int main()
int i,j,k,l,n,bt[10],wt[10],tn[10];
float avgwt=0,avgtn=0;
for(i=1;i<=n;i++)
wt[1]=0;
for(j=1;j<=n;j++)
{
wt[j+1]=bt[j]+wt[j];
avgwt=avgwt+wt[j];
}
for(k=1;k<=n;k++)
tn[k]=wt[k]+bt[k];
avgtn=avgtn+tn[k];
}
printf(" first come first serve\n");
avgwt=avgwt/n;
avgtn=avgtn/n;
printf(" the average waiting time is %f \n",avgwt); printf(" the average turn around time is %f
\n",avgtn);
}
OUTPUT
4
enter the 2 bursttime
5
enter the 3 bursttime
6
First come first serve
t
BT wt m
4 0 4
5 4 9
6 9 15
9.333333
RESULT
The above program has been executed successfully
EXP NO : 4B
AIM
To write the c program to implement shortest job first CPU scheduling algorithm.
ALGORITHM
3. Get the no of process and burst time of each process using for loop.
5. Allow that process to run and find the waiting time and
#include<stdio.h> int
main()
{
int n,i,j,temp,temp1,pr[10],b[10],t[10],w[10],p[10]; float
att=0,awt=0;
for(i=0;i<10;i++)
{ b[i]=0;
w[i]=0;
}
printf("enter the number of processes");
scanf("%d",&n);
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];
temp1=p[i];
b[i]=b[j];
p[i]=p[j];
b[j]=temp;
p[j]=temp1;
}
}
}
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;
for(i=0;i<n;i++) printf("\t%d]\t%d\t\t%d\
n",p[i],w[i],t[i]);
}
OUTPUT
1 0 4
2 4 9
0 9 15
3 15 21
RESULT
AIM
ALGORITHM
3. Get the no of process and burst time of each process using for loop.
6. Allow that process to execute and calculate the waiting and turnaround time of process.
#include<stdio.h>
#include<stdlib.h>
int main()
int i,j,k,l,m,p,n,bt[10],wt[10],tn[10],temp,pr[10];
float avgwt=0,avgtn=0;
for(i=1;i<=n;i++)
{
printf("enter the %d burst time",i);
scanf("%d",&bt[i]);
for(m=1;m<=n;m++)
{
for(p=m;p<=n;p++)
{
if(pr[m]>pr[p])
{
temp=pr[m];
pr[m]=pr[p];
pr[p]=temp
temp=bt[m];
bt[m]=bt[p];
bt[p]=temp;
}
wt[1]=0;
for(j=2;j<=n;j++)
wt[j]=wt[j-1]+bt[j-1]; avgwt=avgwt+wt[j];
for(k=1;k<=n;k++)
tn[k]=wt[k]+bt[k];
avgtn=avgtn+tn[k];
}
printf("PRIORITY SCHEDULING \n");
printf("pr \t bt \t wt \t tn \t \n"); for(l=1;l<=n;l++)
{
printf("%d \t %d \t %d \t %d \t \n",pr[l],bt[l],wt[l],tn[l]);
avgwt=avgwt /n
avgtn=avgtn /n;
}
OUTPUT
PRIORITY SCHEDULING
pr bt wt tn
2 2 0 2
4 3 2 5
RESULT
The above program has been executed successfully
EXP NO : 4D
ROUND ROBIN ALGORITHM
DATE:
AIM
ALGORITHM
3. Get the number of process and burst time of each process using for loop.
5. Take the first process and execute for the given time slice.
6. Take the next process and execute for the given time slice.
#include<stdio.h>
#include<string.h>
int main()
char p[10][5];
int et[10],wt[10],timer,count,pt[10],rt,i,j,totwt=0;
int n,found=0,m,tottt=0,tt[10];
float avgwt,avgtt;
for(i=0;i<n;i++)
{
printf(" ENTER THE PROCESS NAME:");
scanf("%s",&p[i]);
wt[0]=0;
i=0;
do
if(pt[i]>timer)
{
rt=pt[i]-timer;
strcpy(p[n],p[i]);
pt[n]=rt;
et[i]=timer; n+
+;
else
et[i]=pt[i];
} i+
+;
wt[i]=wt[i-1]+et[i-1];
while(i<n);
count=0;
for(i=0;i<m;i++)
{
for(j=i+1;j<=n;j++)
{
if(strcmp(p[i],p[j])==0)
count++;
found=j
}
}
if(found!=0)
{
wt[i]=wt[found]-(count*timer);
count=0;
found=0;
}
}
for(i=0;i<m;i++)
{
tt[i]=wt[i]+pt[i];
totwt+=wt[i];
tottt+=tt[i];
}
avgwt=(float)totwt/m;
avgtt=(float)tottt/m;
for(i=0;i<m;i++)
{
printf("\n %s \t %d\t %d\t %d",p[i],pt[i],wt[i],tt[i]);
}
printf("\n TOTAL WAITING TIME %d \n",totwt); printf("\n Average
}
OUTPUT
RESULT
AIM
ALGORITHM
SENDER PROGRAM
#include <stdio.h>
#include<sys/types.h>
#include <sys/ipc.h>
#include<sys/msg.h>
#include <unistd.h>
#include<string.h>
int main()
int mid;
char mess[20];
mid=msgget(27,IPC_CREAT|0777);
if(mid==-1)
#include <stdio.h>
#include<sys/types.h>
#include <sys/ipc.h>
#include<sys/msg.h>
#include <unistd.h>
#include<string.h>
int main()
mid==msgget(27,IPC_CREAT|0777);
if(mid==-1)
exit(0);
}
msgrcv(mid,mess,100,0,0);
RESULT
AIM
ALGORITHM
#include<stdio.h>
int n;
consumer(); int
wait(int);
n3.EXIT\n"); while(1)
{
printf("\nENTER YOUR CHOICE\n");
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;
int wait(int s)
return(--s);
int signal(int s)
return(++s);
}
void producer()
mutex=wait(mutex);
full=signal(full);
empty=wait(empty);
x++;
void consumer()
mutex=wait(mutex);
full=wait(full);
empty=signal(empty);
x--;
mutex=signal(mutex);
OUTPUT
1. PRODUCER
2. CONSUMER
3. EXIT
BUFFER IS EMPTY
RESULT
The above program has been executed successfully
EXP NO : 7
IMPLEMENTATION OF DEADLOCK DETECTION
DATE: USING BANKERS ALGORITHM
AIM
ALGORITHM
7. Allocate the resource for each process based on available and need of process.
#include<stdio.h>
void main()
int max[20],all[20],need[20],seq[20],avail,work,i,j=0,d,m,n,e;
printf("Enter no of process");
scanf("%d",&n);
printf("max of p %d is",i);
scanf("%d",&max[i]); printf("\
nAllocation of p %d is",i);
scanf("%d",&all[i]);
need[i]=max[i]-all[i];
printf("\nneed of p %d is : %d",i,need[i]);
printf("\nEnter available
resources"); scanf("%d",&avail);
printf("%d %d
%d",max[i],all[i],need[i]); m=d=n;
e=m+1;
while(m>0)
if(d==e)
m=0 ;
else
d=e;
e=0;
for(i=0;i<n;i++)
if((need[i]>0)&&(need[i]<=avail))
need[i]=0;
work=all[i]+avail;
avail=work;
seq[j]=i;
m--;
j++;
else
e++;
if(d==e)
printf("\n process are in unsafe state");
else
{
+)
printf("p %d\t",seq[i]);
OUTPUT:
P0 6 2 4
P1 8 5 3
P2 5 2 3
P3 6 2 4
RESULT
AIM
ALGORITHM
#include<stdio.h>
int max[100][100];
int alloc[100][100];
int need[100][100];
int avail[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);
n"); for(i=0;i<n;i++)
for(j=0;j<r;j++)
scanf("%d",&max[i][j]);
n"); for(i=0;i<n;i++)
for(j=0;j<r;j++)
{
scanf("%d",&alloc[i][j]);
}
}
printf("Enter the availableResources\
n"); for(j=0;j<r;j++)
{
scanf("%d",&avail[j]);
void show()
{
int i,j;
printf("Process\t Allocation\t Max\tAvailable\t");
for(i=0;i<n;i++)
{
printf("\nP%d\t ",i+1);
for(j=0;j<r;j++)
{
printf("%d ",alloc[i][j]);
}
printf("\t");
for(j=0;j<r;j++)
{
printf("%d ",max[i][j]);
}
printf("\t");
if(i==0)
{
for(j=0;j<r;j++)
printf("%d ",avail[j]);
}
}
}
void cal()
{
int finish[100],temp,need[100][100],flag=1,k,c1=0;
int dead[100];
int safe[100];
int i,j; for(i=0;i<n;i++)
{
finish[i]=0;
}
for(i=0;i<n;i++)
{
for(j=0;j<r;j++)
{
need[i][j]=max[i][j]-alloc[i][j];
}
}
while(flag)
{
flag=0; for(i=0;i<n;i+
+)
{
int c=0; for(j=0;j<r;j+
+)
{
if((finish[i]==0)&&(need[i][j]<=avail[j]))
{ c+
+;
if(c==r)
{
for(k=0;k<r;k++)
{
avail[k]+=alloc[i][j];
finish[i]=1;
flag=1;
}
if(finish[i]==1)
{
i=n;
}
}
}
}
}
}
j=0;
flag=0;
for(i=0;i<n;i++)
{
if(finish[i]==0)
{
dead[j]=i; j+
+;
flag=1;
}
}
if(flag==1)
{
printf("\n\nSystem is in Deadlock and the Deadlock process are\n");
for(i=0;i<n;i++)
{
printf("P%d\t",dead[i]);
}
}
else
{
printf("\n No Deadlock Occur");
}
}
OUTPUT
RESULT
AIM
To create the threads in application and make the synchronization using mutex
lock.
ALGORITHM
6. Main thread call the join() system call to wait for child threads are terminated.
#include<stdio.h>
#include<string.h>
#include<pthread.h>
#include<stdlib.h>
#include<unistd.h>
pthread_t tid[2];
int counter;
pthread_mutex_t lock;
unsigned long i = 0;
counter += 1;
i<(0xFFFFFFFF);i++);
return NULL;
}
int main(void)
int i = 0;
int err;
while(i < 2)
NULL); if (err != 0)
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
RESULT
AIM
To write the c program to implement the paging technique.
ALOGORITHM
4. Enter the page table details i.e. frame no for each page if not available put -1.
#include<stdio.h>
#define MAX 50
int main()
{
int page[MAX],i,n,f,ps,off,pno;
for(i=0;i<n;i++)
page[i]=-1;
for(i=0;i<n;i++)
printf("\n\n%d\t\t",i);
scanf("%d",&page[i]);
}
printf("\n\nEnter the logical address(i.e,page no & offset):"); scanf("%d
%d",&pno,&off);
if(page[pno]==-1)
}
OUTPUT
Pageno frameno
0 2
1 3
2 -1
3 8
4 10
RESULT
The above program has been executed successfully
EXP NO :11
IMPLEMENTATION OF MEMORY ALLOCATION METHODS
DATE:
AIM
To write the c program to implement Memory allocation methods technique.
ALOGORITHM
4. Enter the page table details i.e. frame no for each page if not available put -1.
a)WORST-FIT
#include<stdio.h>
#include<conio.h>
#define max 25
void main()
{
int frag[max],b[max],f[max],i,j,nb,nf,temp;
static int bf[max],ff[max];
clrscr();
printf("\n\tMemory Management Scheme - First 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)
{
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
Enter the number of blocks: 3
Enter the number of files: 2
OUTPUT
File No File Size Block No Block Size Fragment
1 1 1 5 4
2 4 3 7 3
b) Best-fit
#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();
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)
{
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("\nFile No\tFile Size \tBlock No\tBlock Size\tFragment");
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,f[i],ff[i],b[ff[i]],frag[i]); getch();
}
INPUT
Enter the number of blocks: 3
Enter the number of files: 2
OUTPUT
File No File Size Block No Block
Size Fragment
1 1 2 2
2 4 1 5
c) First-fit
#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
OUTPUT
File No File Size Block No Block
Size Fragment
1 1 3 7
2 4 1 5
RESULT
AIM
ALGORITHM
4. Check the need of replacement from old page to new page in memory
#include<stdio.h>
int main()
int i,j,n,a[50],frame[10],no,k,avail,count=0;
n");
scanf("%d",&n);
scanf("%d",&a[i]);
for(i=0;i<no;i++)
frame[i]= -1;
j=0;
{
printf("%d\t\t",a[i]);
avail=0;
for(k=0;k<no;k++)
if(frame[k]==a[i])
avail=1;
if (avail==0)
{
frame[j]=a[i];
j=(j+1)%no; count+
+; for(k=0;k<no;k+
+)
printf("%d\t",frame[k]);
printf("\n");
}
printf("Page Fault Is%d",count);
}
OUTPUT
1 1 -1 -1
2 1 2 -1
3 1 2 3
4 4 2 3
1 4 1 3
2 4 1 2
5 5 1 2
3 5 3 2
4 5 3 4
RESULT
AIM
ALGORITHM
2. Get the no. of pages, reference strings and the no. of frames.
3. Now find the page no. that has not been used for the longest period of time and
replace those page numbers with new arriving page numbers.
4. Record the number of page faults that has occurred during the page replacement
#include<stdio.h>
main()
{
int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20];
printf("Enter no of pages:");
scanf("%d",&n);
string:"); for(i=0;i<n;i++)
scanf("%d",&p[i]);
printf("Enter no of frames:");
scanf("%d",&f);
q[k]=p[k]; printf("\n\t%d\
n",q[k]); c++;
k++;
for(i=1;i<n;i++)
{ c1=
0;
for(j=0;j<f;j++)
{
if(p[i]!=q[j])
c1++;
if(c1==f)
{ c+
+;
if(k<f)
q[k]=p[i];
k++;
for(j=0;j<k;j++)
printf("\t%d",q[j]);
printf("\n");
else
{
for(r=0;r<f;r++)
{ c2[r]=
0;
for(j=i-1;j<n;j--)
{
if(q[r]!=p[j])
c2[r]++;
else
break;
for(r=0;r<f;r++)
b[r]=c2[r];
for(r=0;r<f;r++)
for(j=r;j<f;j++)
if(b[r]<b[j])
t=b[r];
b[r]=b[j];
b[j]=t;
for(r=0;r<f;r++)
if(c2[r]==b[0])
q[r]=p[i]; printf("\t
%d",q[r]);
printf("\n");
}
}
}
OUTPUT
Enter no of pages:10
Enter no of frames:3
7 5
7 5 9
4 5 9
4 3 9
4 3 7
9 3 7
9 6 7
9 6 2
1 6 2
RESULT
AIM
ALGORITHM
4. Check the page that will not be used for the longest period of time.
#include<stdio.h>
main()
int fr[5],i,j,k,t[5],p=1,flag=0,page[25],psz,nf,t1,u[5];
scanf("%d",&nf);
scanf("%d",&psz);
scanf("%d",&page[i]);
for(i=1; i<=nf; i+
+) fr[i]=-1;
{
if(full(fr,nf)==1)
break;
else
flag=0;
{
if(page[i]==fr[j])
flag=1;
printf(" \t%d:\t",page[i]);
break;
if(flag==0)
fr[p]=page[i];
p++;
for(j=1; j<=nf; j+
+) printf(" %d
",fr[j]);
printf("\n");
}
}
p=0;
flag=0;
if(page[i]==fr[j])
{
flag=1;
break;
if(flag==0)
{ p+
+;
if(fr[j]==page[k])
u[j]=k;
break;
else
u[j]=21;
for(j=1; j<=nf; j+
+) t[j]=u[j];
for(j=1; j<=nf; j++)
if(t[j]<t[k])
t1=t[j];
t[j]=t[k];
t[k]=t1;
if(t[1]==u[j])
fr[j]=page[i];
u[j]=i;
printf("page fault\t");
else printf("\
t");
printf("%d:\t",page[i]);
printf(" %d ",fr[j]);
printf("\n");
int k;
for(k=1;k<=n;k++)
if(a[k]==-1)
}
OUTPUT
1: 1 -1 -1 -1 -1
2: 1 2 -1 -1 -1
3: 1 2 3 -1 -1
RESULT
The above program has been executed successfully
EXP NO : 13
IMPLEMENTATION OF FILE ORGANIZATION TECHNIQUES
DATE:
AIM
ALGORITHM
PROGRAM
#include<stdio.h>
void main()
{
int master,s[20];
int i,j;
printf("enter number of master directorios:");
scanf("%d",&master);
printf("enter names of master directories:");
for(i=0;i<master;i++)
scanf("%s",&d[i]);
for(i=0;i<master;i++)
printf("enter size of master directorie:%s",d[i]); scanf("%d",&s[i]);
for(i=0;i<master;i++)
scanf("%s",&f[i][j]);
printf("\n");
printf(" directory\tsize\tfilenames\n");
printf("*************************************************\n");
for(i=0;i<master;i++)
printf("%s\t\t%2d\t",d[i],s[i]);
for(j=0;j<s[i];j++) printf("%s\
n\t\t\t",f[i][j]); printf("\n");
printf("\t\n");
}
OUTPUT
directory 2
Master2
bb
dd
ee
********************************************
Master1 2 aa bb
Master2 3 cc dd ee
AIM
To write the c program for implement the Indexed file allocation technique.
ALGORITHM
6. Select one segment as an index for the given file and store all the allocated blocks to
that segment.
#include<stdio.h>
#include<stdlib.h>
struct file
char name[20];
int size;
}file;
int mem[200];
void indexed()
scanf("%d",&n);
for(i=0;i<200;i++)
if(mem[i]==1)
first=i;
mem[first]=1;
break;
for(i=0,j=0;i<200;i++)
{
if((mem[i]==-1)&&(file.size >0))
loc[j]=i;
count++;
j++; file.size-=n;
else if(file.size<=0)
loc[j]=-1; j++;
break;
printf("\n");
}
int main()
{
int i;
for(i=0;i<200;i++)
{
mem[i]=1;
for(i=0;i<200;i++)
{
if((i%2!=0)&&(i%3!=0))
mem[i]=-1;
scanf("%s",file.name);
scanf("%d",&file.size);
indexed();
}
OUTPUT
1 -> 5
1 -> 7
1 -> 11
1 -> 13
1 -> 17
1 -> 19
1 -> 23
1 -> 25
1 -> -1
RESULT
The above program has been executed successfully
EXP NO : 14B
SEQUENTIAL FILE ALLOCATION
DATE:
AIM
To write the c program for implement the sequential file allocation technique.
ALGORITHM
#include<stdio.h>
#include<stdlib.h>
main()
int f[50],i,st,j,len,c,k,count=0;
for(i=0;i<50;i++)
f[i]=0;
X:
if(f[k]==0)
count++;
if(len==count)
for(j=st;j<(st+len);j++)
if(f[i]==0)
{ f[j]=
1;
printf("\n%d\t%d",,j,f[j]);
if(j==(st+len-1))
}
}
else
printf("file is not allocated");
count=0;
printf("\n if u want to enter more files(y-1/n-0)");
scanf("%d",&c);
if(c==1)
goto X;
else
exit(0);
}
OUTPUT
AIM
To write the c program for implement the linked list file allocation technique.
ALGORITHM
5. Allocate the required no of free segment to that file using linked list.
#include<stdio.h>
struct file
char name[20];
int size;
}file;
struct link
{
int present,next;
}ln[100];
int mem[200];
void linked()
{
int first=-1,count=0,i=0,j=0,n; printf("\
scanf("%d",&n);
for(i=0;i<200;i++)
{
if(mem[i]==-1)
{
first=i;
break;
}
}
ln[0].present=first;
for(i=1,j=1;i<200;i++)
if(mem[i]==-1)
file.size-=n;
ln[j].present=i;
ln[j-1].next=ln[j].present;
count++;
j++;
if(file.size<=0)
ln[j-1].next=-1;
break;
printf("%s : %d ",file.name,first);
for(i=1;i<count+1;i++)
int main()
{
int i; for(i=0;i<200;i++)
mem[i]=1;
}
for(i=0;i<200;i++)
{ if((i%2!=0)&&(i%3!
=0))
{
mem[i]=-1;
}
}
printf("\nEnter file name: ");
}
OUTPUT
[cs28105@localhost cs28105]$ cc
linked.c [cs28105@localhost
AIM
ALGORITHM
#include<stdio.h>
#include<stdlib.h>
int main()
{
int RQ[100],i,n,TotalHeadMoment=0,initial;
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);
for(i=0;i<n;i++)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
OUTPUT
RESULT
The above program has been executed successfully
EX NO : 15A(ii)
IMPLEMENTATION OF SCAN DISK SCHEDULING ALGORITHM
DATE:
AIM
To write a program to implement SCAN disk scheduling algorithm.
ALGORITHM
2. This algorithm scans all the cylinders of the disk back and forth.
3. Head starts from one end of the disk and move towards the other end servicing all
the requests in between.
4. After reaching the other end, head reverses its direction and move towards the
starting end servicing all the requests in between.
5. The same process repeats.
6. Stop
PROGRAM
#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 Scan disk scheduling
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;
}
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
// last movement for max size
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];
}
}
for(i=index-1;i>=0;i--)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
// last movement for min size
TotalHeadMoment=TotalHeadMoment+abs(RQ[i+1]-0);
initial =0;
for(i=index;i<n;i++)
{
TotalHeadMoment=TotalHeadMoment+abs(RQ[i]-initial);
initial=RQ[i];
}
}
}
OUTPUT
DATE:
AIM
PROCEDURE
1. Select the menu command to mount the VMware Tools virtual disk on the
guest operating system.
VMware
Product Action
vSphere Client Right-click the virtual machine and select Guest OS > Install
VMware Tools... or Guest OS > Upgrade VMware Tools...
Fusion Virtual Machine > Install (or Upgrade) VMware Tools
Workstation VM > Install (or Upgrade) VMware Tools
VMware
Product Action
Pro
Workstation Player > Manage > Install (or Upgrade) VMware Tools
Player
2. In the virtual machine, open a terminal window. Run the mount command with no
arguments to determine whether your Linux distribution automatically mounted
the VMware Tools virtual CD-ROM image.
If the CD-ROM device is mounted, the CD-ROM device and its mount point are listed in
a manner similar to the following output:
mkdir /mnt/cdrom
Some Linux distributions use different mount point names. For example, on some
distributions the mount point is /media/VMware Tools rather than /mnt/cdrom.
Modify the command to reflect the conventions that your distribution uses.
3. Change to a working directory, for example, /tmp and extract the tar file
into this /tmp folder.
cd /tmp
4. Delete any previous vmware-tools-distrib directory before you install VMware Tools.
The location of this directory depends on where you placed it during the previous
installation. Often this directory is placed in /tmp/vmware-tools-distrib.
List the contents of the mount point directory and note the file name of the VMware
Tools tar installer.
ls mount-point
Uncompress the installer.
tar zxpf /mnt/cdrom/VMwareTools-x.x.x-yyyy.tar.gz
The value x.x.x is the product version number, and yyyy is the build number of the
product release.
umount /dev/cdrom
If your Linux distribution automatically mounted the CD-ROM, you do not need to
unmount the image.
7. cd vmware-tools-distrib
sudo ./vmware-install.pl
Follow the prompts to accept the default values, if appropriate for your configuration.
Depending on the features you use, these instructions can include restarting the X
session, restarting networking, logging in again, and starting the VMware User process.
You can alternatively reboot the guest operating system to accomplish all these tasks.
Usually, the vmware-config-tools.pl configuration file runs after the installer file finishes
running. If you attempt to install a tar installation over an RPM installation, or the
reverse, the installer detects the previous installation and must convert the installer
database format before continuing.
RESULT
The above program has been executed successfully