Department of Computer Science and
Engineering
Collegeof
Engineering
Mohali, Punjab- 140307
OPERATING SYSTEM
PRACTICAL FILE
SUBMITTED
TO: SUBMITTED
BY:
Rohini mam km sapna
1915261
CSE ABC
INDEX
EXPERIMENT 1 AIM: HOW TO INSTALL
WINDOWS
STEP 1:Upgrade
to Windows 10
Start > Settings > Update
& security > Activation.
FIG
1:Upgrade
STEP 2:Download
the Windows 10 Media Creation Tool
The Windows 10 download is around
2.5GB and will need to be copied to a blank DVD or a USB flash drive for the
installation.
FIG
2:Downloading of windows 10
STEP 3:
Run the Windows 10 Media Creation Tool
Find the downloaded MediaCreationTool.exe file in
yourDownloads folder and double-click it to run it.When the Windows 10 Setup
window appears, select the Create installation media for another PC option and
click the Next button.
FIG 3:Media
creation tool
STEP 4:Choose
Your Windows 10 Version
On the next screen, choose the Language, Edition and
Architecture (32-bit or 64-bit) to match your current version of Windows 10.
Don’t select one of the N editions — these lack Windows Media Player. Click
Next to continue.
FIG 4
STEP 5: Choose a Storage Device and Start the
Download
Select the device you’re going to use for the Windows 10
installation — USB flash drive or an ISO file for burning to DVD. Click
Next.Select the USB flash drive, or a folder on your PC, to store the Windows
10 setup files. Click Next and the 4GB download will begin.If you created a DVD
ISO file, you’ll now need to burn the file to a DVD before you can use it to
boot your PC. Else you can boot using the USB flash drive.
FIG 5
STEP 6:
Begin the Windows 10 Installation
After you boot your PC using the Windows 10 DVD or USB flash
drive, choose the Install now option and then Skip the request for a product
key to activate Windows. As long as you’ve already upgraded this PC to Windows
10, you won’t need a product key.
FIG 6
STEP 7:
Perform a Custom Install
After you boot your PC using the Windows 10 DVD or USB
flash drive, choose the Install now option and then Skip the request for a
product key to activate Windows.
STEP 8:
Choose Where to Install
Select the hard drive partition
you want to install Windows 10 on. This should already be labelled as Windows
7, 8 or 10, but it should also be the largest partition in the list.
STEP
9: Complete the Set Up
The Windows 10 installation will
now start.
STEP 10:
Confirm That Windows 10 Has Activated
Once Windows 10 is installed,
repeat Step 1 to check that it has been activated — you may need to click the
Activate button.
EXPERIMENT 2
AIM: HOW TO INSTALL UBUNTU
STEP1:Download
The Ubuntu ISO
Download Ubuntu Desktop 18.04 LTS
“Bionic Beaver”.
FIG1:
Download ubuntu
STEP2:Create
a Bootable Ubuntu USB Flash Drive
•
Prepare our flash drive for the Ubuntu
installation
•
Download the latest version using any of the
on-page links to download the Rufus
installer directly.
•
Click on ‘Select’ to locate and open the Ubuntu
ISO. Select ‘Start’ to begin preparing the boot device.
FIG 2:
Create a Bootable Ubuntu.
STEP 3:Preparing
to Boot Off USB
If you’re going to be installing of a USB drive prepared with
Rufus, then you’ll need to configure your BIOS appropriately. Entering the BIOS
requires pressing the correct key combination upon boot.You’ve typically got
two to three seconds to press the key that sends you into your BIOS
configuration instead of continuing with the preconfigured startup process.
Common keys to enter the BIOS include Delete, Esc, F1, F2, and F10. Observe as
your computer boots and press the key relevant to your setup just after
powering up your PC.Once in your BIOS, navigate to either your boot order or
(if your BIOS supports it) select the USB as the next primary boot source for
your next restart.While every BIOS is different, here’s an example of what to
expect when changing your boot order:
FIG
3:Preparing to Boot Off USB STEP 4:Installing
Ubuntu
•
If you wanted to test out Ubuntu before
installing, this is where you’d select ‘Try
Ubuntu’ instead. Pick your
preferred language and click ‘Install Ubuntu’
•
FIG 5: Installing ubuntu
•
Select the correct keyboard layout and locality
appropriate.If you have an active internet connection available, ensure that
‘Download updates while installing Ubuntu’ and ‘Install third-party software
for graphics and wi-fi hardware and additional media formats’ are checked
before selecting ‘Continue’ to proceed.
•
Select ‘Continue’ to confirm the changes to the
partition of your virtual disk and proceed.
•
Configure the correct time zone for your
installation, and select ‘Continue’ to proceed. Configure a name, computer
name, username, and secure password.
•
You will be presented with an installation
prompt indicating the status and progress of your setup.
FIG 6:
Welcome to UBUNTU
•
In a couple of minutes to perhaps as long as an
hour, depending on the speed of your hardware and connection type, you’ll be
rewarded with a prompt concluding your installation. Select ‘Restart Now’ to
finish your brand new installation of Ubuntu.
•
Some users may be presented with an error from
Virtual Box at this point. This is no cause for alarm. Instead, all you need to
do is close the error and manually start the virtual machine from Virtual Box.
•
Remove your USB flash drive if it’s in use, and
Press the ‘Enter’ key to continue booting your fresh installation of Ubuntu.
FIG 7:
UBUNTU
Congratulations! You’ve now got
Ubuntu up and running. It’s time to configure, customize, and optimise your
operating system while setting all your favourite applications.
EXPERIMENT 3
AIM: How to use dos commands
1. COLOR
Sets the default console foreground and background colours.
Syntax
COLOR [background][foreground]
Colour attributes are specified by 2 hex digits. There
should be no space between the two color numbers.
2. CD
Change Directory - Select a Folder (and drive)
Syntax
CD [/D] [drive:][path]
CD [..]
3. MD
Make Directory - Create a new folder/directory.
Syntax
MD [drive:]path [[drive:]path...]
4. DIR
Display a list of files and subfolders.
Syntax
DIR [pathname(s)] [display_format] [file_attributes]
[sorted] [time] [options]
5. COPY
Copy one or more files to another location.
Syntax
COPY [options] [/A|/B] source [/A|/B] [+ source2 [/A|/B]...] [destination
[/A|/B]] COPY source1 + source2..destination [options]
6. REN
Rename a file or files.
REN [drive:][path]SourceMaskTargetMask
7. MOVE
Move a file from one folder to another
Syntax
MOVE [options] [Source] [Target]
8. SYSTEMINFO
List system configuration.
Syntax
SYSTEMINFO [/S system [/U username [/P [password]]] ]
[/FO format] [/NH]
9. COMP
Compare two files (or sets of files). Display items which
do not match.
Syntax
COMP [pathname1] [pathname2] [/D] [/A] [/L] [/N=number]
[/C]
10.FC
Compare the contents of two files or sets of files. Display
any lines which do NOT match.
Syntax
FC [options] [drive1:][path1] filename1
[drive2:][path2] filename2
11.DEL
Delete one or more files.
Syntax
DEL [options] [/A:file_attributes] files_to_delete
12.RD
Remove (or Delete) a Directory.
Syntax
RD pathname
RD /S pathname
RD /S /Q pathname
12.FIND
Search for a text string in a file & display all the
lines where it is found.
Syntax
FIND [/V] [/C]
[/N] [/I] "string" [pathname(s)]
13.FINDSTR
Search for a text string in a file (or multiple files)
unlike the simple FIND command FINDSTR supports more complex
regular expressions.
Syntax
FINDSTR string(s) [pathname(s)]
[/R] [/C:"string"] [/G:StringsFile]
[/F:file] [/D:DirList]
[/A:color] [/OFF[LINE]] [options]
14.CON
CON (short for Console) is an input device, not a command.
Syntax
Copy from the
console to a new file: COPY CON
filename.txt
Type from
the console to a new file: TYPE CON
> Newfile.txt
Type from the console to overwrite a file:
TYPE CON >> Newfile.txt
15.PATH
Display or set a search path for executable files at the
command line.
Syntax
PATH pathname[;pathname] [;pathname] [;pathname]...
PATH
PATH ;
16.DATE
Display or change the date. Syntax
to display the date DATE /T
to set the system date DATE or
DATE <date_today>
17.TIME
Display or set the system time.
Syntax
TIME [new_time]
TIME
TIME /T
18.CLS
Clear the screen.
Syntax
CLS
If CLS is redirected to file, console or executed through FOR
/F it will print a line feed character (ASCII 10).
19.EXIT
Close the current batch script, exit the current subroutine
or close the CMD.EXE session, optionally setting an errorlevel.
Syntax
EXIT [/B] [exitCode]
EXPERIMENT 4
AIM: How to use Linux commands
1. ls
Syntax: ls
The
ls command is a command-line utility for listing the contents of a directory
2. mkdir
Syntax:
mkdirdirectoryname
This command is use to create a new directory.
3. cd
Syntax:
cd Directoryname
The
cd command changes your current directory
4. rmdir
Syntax:
rmdirdirectoryname
This command deletes the
directory
5.
Create a
file.
Syntax:
cat > filename
This command will create a new file. If a file with same
name is already present then it will remove the contents of old file with the
new contents.
6.
To view a
single file.
Syntax:
cat filename
This command is use to view the contents of the file.
7.
To view multiple
files.
Syntax: cat
filename1 filename2
This command file view the contents of file1 and file2
8.
To view
contents of a file preceding with line numbers.
Syntax:
cat –n filename
This command will show the content of file with line number
9.
Copy the
contents of one file to another file.
Syntax: cat
filename1 > filename2
This command will copy the contents of file1 to file2 and
will remove any content previously present in file2.
10.
Append the
contents of one file to the end of another file.
Syntax: cat filename1
>> filename 2
This command will append the contents of file1 to file2.
11.Display
content in reverse order.
Syntax:
tac filename
This command will display the contents of file in reverse
order i.e from the end to beginning of the file.
12. Highlight the end of line.
Sytnax:
cat –E “filename”
This command will hightlight the
end od line with $ sign.
EXPERIMENT 5
AIM: WAP to
implement FCFS.
#include<iostream> using
namespace std;
void findWaitingTime(int processes[], int n, int bt[], int
wt[])
{wt[0] = 0; for
(int i = 1; i< n ; i++ )
{wt[i] = bt[i-1] + wt[i-1] ;}
}
void findTurnAroundTime( int processes[], int n, int bt[],
int wt[], int tat[])
{ for (int i = 0;
i< n ; i++)
{tat[i] = bt[i] + wt[i];}
}
void findavgTime( int processes[], int n, int bt[])
{ int wt[n],
tat[n], total_wt = 0, total_tat = 0; findWaitingTime(processes, n, bt, wt);
findTurnAroundTime(processes, n, bt, wt, tat);
cout<<"Processes
"<<" Burst time "<<" Waiting time
"<<" Turn around time\n"; for (int i=0; i<n; i++)
{ total_wt =
total_wt + wt[i]; total_tat = total_tat + tat[i];
cout<<""<< i+1
<<"\t\t"<<bt[i] <<"\t "<<wt[i]
<<"\t\t "<< tat[i] <<endl;
}
cout<<"Average waiting time = "
<<
(float)total_wt / (float)n; cout<<"\nAverageturn around time =
"
<< (float)total_tat /
(float)n;
} int main()
{ int
processes[] = { 1, 2, 3}; int n = sizeof processes / sizeof processes[0]; int
burst_time[] = {10, 5, 8}; findavgTime(processes, n, burst_time); return 0;
}
EXPERIMENT 6
AIM: WAP to
implement SJF.
#include <bits/stdc++.h> using
namespace std; struct Process { int
pid; int bt; int art;
};
void findTurnAroundTime(Process
proc[], int n, int wt[], int tat[]) {
for (int i = 0; i< n; i++) tat[i] = proc[i].bt + wt[i];
}
void findWaitingTime(Process proc[],
int n, int wt[]) { int rt[n]; for (int i = 0; i< n; i++) rt[i] = proc[i].bt;
int complete = 0, t = 0, minm = INT_MAX; int shortest = 0, finish_time; bool check = false; while (complete != n) { for (int j = 0; j < n; j++) {
if ((proc[j].art <= t) &&
(rt[j] <minm) && rt[j] > 0) { minm = rt[j];
shortest = j; check = true;
}
}
if (check == false) {
t++; continue;
} rt[shortest]--; minm =
rt[shortest]; if (minm == 0)
minm = INT_MAX;
if (rt[shortest] == 0) { complete++; check = false; finish_time = t +
1; wt[shortest] = finish_time
proc[shortest].bt
proc[shortest].art; if
(wt[shortest] < 0) wt[shortest] = 0;
} t++;
}
}
void findavgTime(Process proc[], int
n) { int wt[n], tat[n], total_wt = 0,
total_tat = 0;
findWaitingTime(proc, n, wt);
findTurnAroundTime(proc, n, wt, tat);
cout<<"Processes
"<<" Burst time "<<" Waiting time
"<<" Turn around time\n"; for (int i = 0; i< n; i++) { total_wt =
total_wt + wt[i];
total_tat = total_tat + tat[i];
cout<<""<<
proc[i].pid<<"\t\t"<< proc[i].bt<<"\t\t
"<<wt[i] <<"\t\t "<< tat[i] <<endl;
}
cout<<"\nAverage waiting time = "<<
(float)total_wt / (float)n; cout<<"\nAverageturn around time =
"<< (float)total_tat / (float)n;
}
int main() {
Process proc[] = { { 1, 5, 1 }, { 2, 3, 1 }, { 3, 6, 2 }, { 4, 5, 3 }
}; int n = sizeof(proc) /
sizeof(proc[0]); findavgTime(proc, n);
return 0;
}
EXPERIMENT 7
AIM: WAP to
implement Priority scheduling.
#include<bits/stdc++.h> using
namespace std; struct Process { int
pid; int bt; int priority;
};
bool compare(Process a, Process b)
{ return (a.priority>b.priority);
}
void waitingtime(Process pro[], int
n, int wt[]) { wt[0] = 0;
for (int i = 1; i< n ; i++ ) wt[i] = pro[i-1].bt + wt[i-1] ;
}
void turnarround( Process pro[], int
n, int wt[], int tat[]) { for (int i =
0; i< n ; i++) tat[i] = pro[i].bt + wt[i];
}
void avgtime(Process pro[], int n)
{ int wt[n], tat[n], total_wt = 0,
total_tat = 0; waitingtime(pro, n, wt); turnarround(pro, n, wt, tat);
cout<<"\nProcesses
"<<" Burst time "<<" Waiting time
"<<" Turn around time\n"; for (int i=0; i<n; i++) {
total_wt = total_wt + wt[i];
total_tat = total_tat + tat[i];
cout<<""<<
pro[i].pid<<"\t\t"<< pro[i].bt<<"\t
"<<wt[i] <<"\t\t "<< tat[i] <<endl;
}
cout<<"\nAverage waiting
time = "<< (float)total_wt / (float)n;
cout<<"\nAverageturn around time = "<< (float)total_tat /
(float)n;
}
void scheduling(Process pro[], int
n) { sort(pro, pro + n, compare);
cout<<"Order in which
processes gets executed \n"; for
(int i = 0 ; i< n; i++) cout<< pro[i].pid<<"" ;
avgtime(pro, n);
}
int main() {
Process pro[] = {{1, 10, 2}, {2, 5, 0}, {3, 8, 1}}; int n = sizeof pro / sizeof pro[0]; scheduling(pro, n); return 0;
}
EXPERIMENT 8
AIM: WAP to
implement Round Robin.
#include<iostream> using
namespace std;
void findWaitingTime(int processes[], int n, int bt[], int
wt[], int quantum)
{ int rem_bt[n];
for (int i = 0 ;
i< n ; i++) rem_bt[i] = bt[i];
int t = 0; while (1)
{ bool done = true;
for (int i = 0 ; i< n; i++)
{
if (rem_bt[i] > 0)
{ done = false; if (rem_bt[i] >
quantum)
{
t += quantum;
rem_bt[i] -= quantum; }
else
{ t = t + rem_bt[i]; wt[i] = t - bt[i];
rem_bt[i] = 0; }
} } if (done == true) break; }
}
void findTurnAroundTime(int processes[], int n, int bt[],
int wt[], int tat[])
{ for (int i = 0; i< n ; i++)
tat[i] = bt[i] + wt[i]; }
void findavgTime(int processes[], int n, int bt[], int
quantum)
{ int wt[n], tat[n], total_wt = 0,
total_tat = 0; findWaitingTime(processes, n, bt, wt, quantum);
findTurnAroundTime(processes, n, bt, wt, tat); cout<<"Processes
"<<" Burst time "
<<"
Waiting time "<<" Turn around time\n"; for (int i=0;
i<n; i++)
{ total_wt = total_wt + wt[i]; total_tat =
total_tat + tat[i]; cout<<""<< i+1
<<"\t\t"<<bt[i] <<"\t "
<<wt[i]
<<"\t\t "<< tat[i] <<endl; }
cout<<"Average waiting time = "
<<
(float)total_wt / (float)n; cout<<"\nAverageturn around time =
"
<< (float)total_tat / (float)n; }
int main()
{ int processes[] = { 1, 2, 3}; int n =
sizeof processes / sizeof processes[0]; int burst_time[] = {10, 5, 8}; int
quantum = 2;
cout<<"Quantum="<<quantum<<"\n";
findavgTime(processes, n, burst_time, quantum); return 0; }
EXPERIMENT 9
AIM: WAP to
implement Deadlock Prevention.
#include <stdio.h> #include <stdlib.h>
int main() {
int Max[10][10],
need[10][10], alloc[10][10], avail[10], completed[10], safeSequence[10]; int p, r, i, j, process, count; count = 0;
printf("Enter the no of processes : ");
scanf("%d", &p);
for(i = 0; i< p; i++) completed[i] = 0;
printf("\n\nEnter the no of resources :
"); scanf("%d", &r);
printf("\n\nEnter the Max Matrix for each
process : "); for(i = 0; i< p; i++)
{
printf("\nFor process %d :
", i + 1);
for(j = 0; j < r; j++)
scanf("%d",
&Max[i][j]);
}
printf("\n\nEnter the allocation for each
process : "); for(i = 0; i< p; i++)
{
printf("\nFor process %d :
",i + 1);
for(j = 0; j < r; j++)
scanf("%d",
&alloc[i][j]);
}
printf("\n\nEnter the
Available Resources : ");
for(i = 0; i< r; i++)
scanf("%d", &avail[i]); for(i = 0; i< p; i++)
for(j = 0; j < r; j++) need[i][j] = Max[i][j] -
alloc[i][j];
do
{
printf("\n Max
matrix:\tAllocation matrix:\n"); for(i = 0; i< p; i++)
{
for( j = 0; j < r; j++) printf("%d ",
Max[i][j]); printf("\t\t"); for( j = 0; j < r; j++)
printf("%d ", alloc[i][j]);
printf("\n");
} process = -1;
for(i = 0; i< p; i++)
{
if(completed[i] == 0)//if not
completed
{ process = i
;
for(j = 0; j < r; j++)
{
if(avail[j] <
need[i][j])
{ process = -1; break;
}
}
}
if(process != -1)
break;
}
if(process != -1)
{
printf("\nProcess %d runs to completion!",
process + 1); safeSequence[count] = process + 1;
count++; for(j = 0; j < r; j++)
{
avail[j] += alloc[process][j]; alloc[process][j] = 0;
Max[process][j] = 0;
completed[process] = 1;
}
}
}
while(count != p && process != -1);
if(count == p)
{
printf("\nThe system is in a safe
state!!\n"); printf("Safe Sequence : <"); for( i = 0; i<
p; i++) printf("%d ", safeSequence[i]); printf(">\n");
}
else
printf("\nThe system is in an unsafe state!!");
}
OUTPUT:
Enter the no of processes: 5
Enter the no of resources: 3
Enter the Max Matrix for each
process:
For process 1: 7
5
3
For process 2: 3
2
2
For process 3: 7
0
2
For process 4: 2
2
2
For process 5: 4
3
3
Enter the allocation for each
process:
For process 1: 0
1
0
For process 2: 2
0
0
For process 3: 3
0
2
For process 4: 2
1
1
For process 5: 0
0
2
Enter the Available Resources: 3
3
2
Max matrix:
Allocation matrix:
7 5 3 0 1 0
3 2 2 2 0 0
7 0 2 3 0 2
2 2 2 2 1 1
4 3 3 0 0 2
Process 2 runs to completion!
Max matrix:
Allocation matrix:
7 5 3 0 1 0
0 0 0 0 0 0
7 0 2 3 0 2
2 2 2 2 1 1
4 3 3 0 0 2
Process 3 runs to completion!
Max matrix:
Allocation matrix:
7 5 3 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0
2 2 2 2 1 1
4 3 3 0 0 2
Process 4 runs to completion!
Max matrix:
Allocation matrix:
7 5 3 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
4 3 3 0 0 2
Process 1 runs to completion!
Max matrix:
Allocation matrix:
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
4 3 3 0 0 2
Process 5 runs to completion!
The system is in a safe state!! Safe Sequence: < 2
3 4 1 5 >
EXPERIMENT 10
AIM: SHELL PROGRAM.
# Create a script to enter a string and
then print its manipulation table.
$ cat table.sh
# To print multiplication table
echo "Enter a number for which the
multiplication table is to be written " read number1
echo "The length up to which
table is to be written "
read number2
echo "Multiplication table for" $number1
" is given below " count=1
while [ $count -le $number2 ]
do result=`expr $number1 \*
$count` echo $count "*" $number1 "=" $result count=`expr
$count + 1`
done
OUTPUT :
$ sh table.sh
Enter a number for which the
multiplication table is to be written
2
The length upto which table is to
be written
10
Multiplication table for 2 is given below
1 *
2 = 2
2 *
2 = 4
3 *
2 = 6
4 *
2 = 8
5 *
2 = 10
6 *
2 = 12
7 *
2 = 14
8 *
2 = 16
9 *
2 = 18
10 * 2
= 20
# Create a script to accept a number and
compute it's factorial.
$ cat factorial.sh
# To compute the factorial
echo "Enter the number whose factorial is to be
computed" read num temp=`expr $num - 1`
while [ $temp -ge 1 ] do
num=`expr $num \* $temp`
temp=`expr $temp - 1`
done echo "The factorial of number is :
$num"
OUTPUT :
$ sh factorial.sh
Enter the number whose factorial
is to be computed
5
The factorial of number is : 120
# Write a script to determine whether a
given number is prime or not.
$ cat prime.sh
# To find the number is prime or not echo "Enter
no: " read num i=2 while [ $i –le $num ]
do
if [ `expr $num % $i ` –eq 0 ]
then break
fi
i=`expr $i + 1` done
if [ $i -eq
$num ] then echo "$num is a prime number"
else echo "$num is not a
prime number"
fi
OUTPUT :
$ sh prime.sh Enter no: 4
4 is not a prime no.
$ sh prime.sh Enter no:
7
7 is a prime number
# Write a shell script to find out whether
the number entered is odd or even.
$ cat odd.sh
# check whether the entered number is even or odd
echo "Enter a no.: " read n x=`expr $n % 2` if [ $x -eq0 ]
then echo "EVEN"
else
echo "ODD"
fi
OUTPUT :
$ sh odd.sh Enter a no.:
2
EVEN
$ sh odd.sh Enter a no.:
15
ODD
#
Create a shell script ‘addphone’ that asks a user for a name and then a
phone Number. The name and phone number will be put in a file ‘phonebook’. You
should be able to run ‘addphone’ several times without destroying the previous
contents of ‘phonebook’.
# cat addphone.sh
# To enter a list of names c=1
while [ $c –eq1 ]
do
echo "Please enter the name
of person"
read name
echo "Please enter the phone
number of person" read phone echo
$name >> phonebook echo
$phone >> phonebook echo "Press 1 to continue , 2 to exit"
read c done OUTPUT :
$ sh addphone.sh
Please
enter the name of person Deepak
Please
enter the phone number of person 3957417
Press
1 to continue , 2 to exit 1
Please
enter the name of person Rahul
Please
enter the phone number of person 9888165135
Press
1 to continue , 2 to exit 1
Please
enter the name of person Rohit
Please
enter the phone number of person 9872821444
Press
1 to continue , 2 to exit 2
$ cat phonebook
Deepak
3957417
Rahul
9888165135
Rohit
9872821444
No comments:
Post a Comment