Professional Documents
Culture Documents
2. Now get an USB flash drive or optical CD Drive and create a bootable device drive
from Power ISO/Rufus. Here I’m using a USB flash Drive.
3. Once Completed reboot your PC and press ESC/DEL/F10 to enter into the BIOS.
Check the key online according to your PC brand. In BIOS edit boot sequence
program and set your bootable device on top. Now Save and Exit BIOS. If done
correctly your PC will start booting from your bootable device.
1
Page
5. Now you will see a Install Now button hit it to start the setup.
6. Once you hit Install Now the setup will start gathering hardware information and it
will automatically take you to the next level.
2
Page
9. Now accept the Terms and Conditions from Microsoft and hit Next.
3
Page
11. Now after you select Custom installation you will land on a window called as
Partitioning window. Here you can create different Local Disk partitions of your HDD
drive or you can select the partition containing the previous window.
12. Once you are done with your partitioning hit Next and your window will start
installing. After it finishes up the window will ask for reboot. Reboot the window and
remove your bootable device before window boot again. 4
Page
5
Page
6
Page
16. After Setting the Pin your device is ready to use after displaying the screen message.
7
Page
Introduction: Ubuntu is an operating system with Linux kernel based on Debian and
distributed as free and open source software. It’s one of the most popular operating systems
for Desktop and Server.
1. Using a DVD?
It’s easy to install Ubuntu from a DVD. Here’s what you need to do:
Restart your computer. You should see a welcome screen prompting you to choose your
language and giving you the option to install Ubuntu or try it from the DVD.
If you don’t get this menu, read the booting from the DVD guide for more information.
Step 1: Most new computers can boot from USB. You should see a welcome screen
prompting you to choose your language and giving you the option to install Ubuntu or try it
from the CD.
If your computer doesn’t automatically do so, you might need to press the F12 key to bring
up the boot menu, but be careful not to hold it down – that can cause an error message.
•
Page
You should also make sure you have enough space on your computer to install
Ubuntu
If you are not connected to the internet, you will be asked to select a wireless network, if
available. We advise you to connect during the installation so we can ensure your machine is
up to date. So, if you set up your wireless network at this point, it’s worth then clicking the
Back button to go back to the last screen (Preparing to install Ubuntu) and ticking the box
marked ’Download updates while installing’.
9
Page
Use the checkboxes to choose whether you’d like to Install Ubuntu alongside another
operating system, delete your existing operating system and replace it with Ubuntu, or — if
you’re an advanced user — choose the ’Something else’ option
Depending on your previous selections, you can now verify that you have chosen the way in
which you would like to install Ubuntu. The installation process will begin when you click
the Install Now button.
Ubuntu needs about 4.5 GB to install, so add a few extra GB to allow for your files.
10
Page
If you are connected to the internet, this should be done automatically. Check your location is
correct and click ’Forward’ to proceed. If you’re unsure of your time zone, type the name of
the town you’re in or click on the map and we’ll help you find it.
Click on the language option you need. If you’re not sure, click the ’Detect Keyboard
Layout’ button for help.
11
Page
12
Page
All that’s left is to restart your computer and start enjoying Ubuntu!
13
Page
2a. FCFS
First Come First Serve Scheduling:
ALGORITHM:
PROGRAM
#include<iostream>
using namespace std;
cout << "Processes "<< " Burst time "<< " Waiting time " << " Turn around time\n";
int main()
{
int processes[] = { 1, 2, 3};
int n = sizeof processes / sizeof processes[0];
16
Page
ALGORITHM:
1. Start the program. Get the number of processes and their burst time.
2. Initialize the waiting time for process 1 as 0.
3. The processes are stored according to their burst time.
4. The waiting time for the processes are calculated a follows:
for(i=2;i<=n;i++).wt.p[i]=p[i=1]+bt.p[i-1].
5. The waiting time of all the processes summed and then the average time is calculate
6. The waiting time of each processes and average time are displayed.
7. Stop the program.
PROGRAM:
#include <bits/stdc++.h>
using namespace std;
struct Process {
int pid;
int bt;
int art;
};
while (complete != n) {
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;
18
Page
wt[shortest] = finish_time -
if (wt[shortest] < 0)
wt[shortest] = 0;
}
t++;
}
}
findWaitingTime(proc, n, wt);
findTurnAroundTime(proc, n, wt, tat);
20
Page
ALGORITHM:
1. Get the number of process and their burst time.
2. Initialize the array for Round Robin circular queue as ‘0’.
3. The burst time of each process is divided and the quotients are stored on the round
Robin array.
4. According to the array value the waiting time for each process and the average time
are calculated as line the other scheduling.
5. The waiting time for each process and average times are displayed.
6. Stop the program.
PROGRAM:
#include<iostream>
using namespace std;
int t = 0;
while (1)
{
bool done = true;
if (rem_bt[i] > 0)
Page
cout << "Processes "<< " Burst time "<< " Waiting time " << " Turn around time\n";
int main()
{
int processes[] = { 1, 2, 3};
int n = sizeof processes / sizeof processes[0];
int quantum = 2;
findavgTime(processes, n, burst_time, quantum);
return 0;
23
}
Page
24
Page
PROGRAM:
#include<bits/stdc++.h>
using namespace std;
struct Process
{
int pid;
int bt;
int priority;
};
{
Page
OUTPUT:
27
Page
Introduction
Virtual Box allows you to run an entire operating system inside another operating system.
Please be aware that you should have a minimum of 512 MB of RAM. 1 GB of RAM or
more is recommended.
Comparison to Dual-Boot
Many websites (including the one you're reading) have tutorials on setting up dual-boots
between Windows and Ubuntu. A dual-boot allows you, at boot time, to decide which
operating system you want to use. Installing Ubuntu on a virtual machine inside of Windows
has a lot advantages over a dual-boot (but also a few disadvantages).
• In order to get any kind of decent performance, you need at least 512 MB of RAM,
because you are running an entire operating system (Ubuntu) inside another entire
operating system (Windows). The more memory, the better. I would recommend at
least 1 GB of RAM.
• Even though the low commitment factor can seem like an advantage at first, if you
later decide you want to switch to Ubuntu and ditch Windows completely, you cannot
simply delete your Windows partition. You would have to find some way to migrate
out your settings from the virtual machine and then install Ubuntu over Windows
outside the virtual machine.
• Every time you want to use Ubuntu, you have to wait for two boot times (the time it
takes to boot Windows, and then the time it takes to boot Ubuntu within Windows).
Installation Process
Step 1: The first thing you have to do is to install oracle VirtualBox. Install it the same way
28
you would any normal Windows program. Then get Ubuntu disk image (.iso file).
Page
Step 3: You can call the machine whatever you want. If you're installing Ubuntu, it makes
sense to call it Ubuntu, I guess. You should also specify that the operating system is Linux.
Step 4: VirtualBox will try to guess how much of your memory (or RAM) to allocate for the
29
virtual machine. If you have 1 GB or less of RAM, I would advise you stick with the
recommendation. If, however, you have over 1 GB, about a quarter your RAM or less should
Page
be fine. For example, if you have 2 GB of RAM, 512 MB is fine to allocate. If you have 4
Click Next.
Step 5: If this is your first time using VirtualBox (which it probably is if you need a tutorial
on how to use it), then you do want to Create new hard disk and then click Next.
30
31
Page
Step 9: Click Create and wait for the virtual hard drive to be created. This is actually just a
very large file that lives inside of your Windows installation.
32
Page
34
Page
35
Page
CLASSIFICATION OF COMMANDS
DIRECTORY COMMANDS
1. To create a Directory: This command is used for creating a Directory.
36
4. To List all files: This command is used list all the files running in putty.
Syntax: ls
1) cat:
The cat command allows us to create single or multiple files.
Page
The cat command is also used to display content of a file on the screen.
Syntax: cat Filename
Sometimes you will need to append text to an already existing text file. This text
could come from any source, such as a line of text from the command line, the output
of a command or from another text file.This can also be achieved using cat command.
Syntax: cat >> Filename
2) cp: cp stands for copy. This command is used to copy files or group of files or
directory.
If the command contains two file names, then it copy the contents of first file to
the second file. If the second file doesn’t exist, then first it creates one and content is
38
copied to it. But if it exists then it is simply overwritten without any warning.
Page
3) grep: This command allows you to search for a particular string inside a file or folder.
It returns the whole line containing the phrase if it finds the perfect match.
Syntax: grep string filename (where string stands for the word to be searched).
4) head: The head command lets you read the first ten lines of the content inside a
file.You can also give the names of more than one file in the head command and it
will show the first ten lines of each file separately.You can also change the number of
lines you want to be displayed on the screen rather than the default first ten lines.
Syntax: head -5 filename
The above command will display the first five lines of content from the given file.
39
Page
6) sort : This command is used to sort a file, arranging the records in a particular order.
By default, the sort command sorts file assuming the contents are ASCII. Using
options in sort command, it can also be used to sort numerically.
40
= assign absolute
Page
A - all
INFORMATION COMMANDS
✓ Date :
Tells the system to print the date and time.
Syntax: Date [MM dd hh mm[yy] ]
Switches:
✓ +%D : it shows date as mm/dd/yy.
✓ +%H: shows hours 00-23.
✓ +%M: minutes from 0-59.
✓ Who :
It is use to get information about all users who are currently logged into the
system.
Syntax: Who
User name
✓ Who am i :
User or is getting information about himself.
Syntax: WHO AM I
✓ Echo :
It prints or echoes at the terminal whatever else user happens to type on the line.
Syntax: Echo ‘any line’
✓ Exit :
42
FILTER COMMANDS
A filter is a device that reads the standard and writes to the standard
output in a particular format. The format of the output depends on the properties of the
filter.
✓ GREP :
Grep is one of the most useful UNIX filters. It scans a file for the occurrence of
a pattern, and can display the selected pattern, the line numbers in which they are found,
or the filenames where the pattern occurs. Grep can also select lines containing the
pattern.
Syntax : $ grep options patterns filename(s)
E.g. $ grep president emp.lst
OPTIONS :
-c (continuous occurrence) : the –c (count) options counts the occurrences.
-n (displaying line numbers : the –n (number) option can be used to display the
line numbers containing the pattern, along the lines.
-v (deleting lines) : the –v (inverse) option selects all but the lines containing
the pattern.
✓ Cmp:
It is use to comparing two files. It uses two file names as arguments and displays
the difference on the terminal. Syntax: $ Cmp file1 file2
The two files are compared byte-by-byte and the location of the first mismatch
is echoed to the string.
Switches:
–l: list option gives a detailed list of byte number and differing bytes in octal for
each character that differ in both the files.
✓ Comm:
Compares two sorted files (ASCII collating sequence) and compares each line
of the first file with its corresponding line in the second file. Displays the columnar
43
outputs.
Page
MISCELLANEOUS COMMANDS
✓ Ln :
Files are linked with ln comand with two filenames as arguments.
44
45
Page
SHELL PROGRAMMING
A shell program runs in interpretive mode. It is not compiled to a separate executable file as a
C program is. Each statement is loaded into memory when it is to be executed. Shell scripts
consequently run slower than those written in high-level languages. Speed is not a factor in
many jobs we do, and in many cases, using the shell in an advantages- especially in system
administrative tasks. The Unix system administrator must be accomplished shell programmer.
SHELL SCRIPTS
When a group of command have to be executed regularly, they should be stored in a file, and
the file itself executed as a shell script or shell program. Though it’s not mandatory, we
normally use the .sh extension for shell scripts. Shell scripts are executed in a separate child
shell process, and this sub-shell need not be the same as your login shell. By default, the child
and parent shells belongs to the same type, but you can provide a special interpreter line in the
first line of the script to specify a different shell for your script. Use your vi editor to create the
shell script, script.sh.
EDITOR COMMANDS
Editors :
In an operating system, a editor is assumed authority which helps to create and modify
users files in data. Any ASCII text files such as a program or a document may be created
or modified using a text editor. There are three text editors present under UNIX i.e.
❑ Ed - line editor
❑ Vi - Screen editor
❑ Sed - Stream editor
* Ed :
It is just a line editor, like edlin in DOS. It is an older standard Unix editor originally written
by Ken Thompson and available on every Unix system. It takes no advantage on special
terminal features. So it can work on any terminal. It also forms the basis of other essential
programs. Ed was designed in early 1970's for a computing environment and was derived
from an earlier editor called Qed. Syntax : ed <filename>
*VI EDITOR :
UNIX provides a very versatile one—vi. Bill Joy created this editor for the BSD system. The
program is now standard on all the UNIX system. Vi uses a number of internal commands to
navigate to any point in a text file and edit the text there. It also allows you to copy and move
text within a file and also from one file to another. Vi offers cryptic, and sometimes
mnemonic, internal commands for editing work. MODES USED BY VI :
46
Page
*INPUT MODE :
Every key pressed after switching to this mode actually shows up as text. Pressing Esc in this
mode takes vi to command mode.
COMMAND FUNCTION
I Inserts text to left of cursors.
A Appends text to right of cursor.
I Inserts text at beginning of line.
A Appends text at end of line.
O Opens line below.
O Opens line above.
Replaces single character under cursor with ch
rch
(No [Esc] required).
Replaces single character under cursor with any number of
R
characters.
Replaces single character under cursor with any number of
S
characters.
S Replaces entire line.
COMMAND ACTION
:w Saves file and remains in editing mode.
:x Saves file and quits editing mode.
:wq As above.
:w n2w.p1 Like Save As …. In Microsoft windows.
:w! n2w.p1 As above, but overwrites existing file.
47
*NAVIGATION:
In this we consider the command mode. This is the mode you come to when you have finished
entering or changing your text. A Command Mode command doesn’t show up on screen but
simply performs a function. We begin with navigation. Don’t forget to avoid the cursors control
keys for navigation.
KEY FUNCTION
K Moves cursor up.
J Moves cursor down.
H Moves cursor left.
SL Moves cursor right.
B Moves back to the beginning of word.
E Moves forward to the beginning of word.
W Moves forward to the end of word.
O Moves the cursor to the positioned column.
$ Moves to the end of line.
G Goes to end of file.
*EDITING TEXT:
The editing facilities in vi are very elaborate and involve the use of operators.
Keys for Editing Text :
KEY FUNCTION
48
d Delete
Page
49
Page
5a. To 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
50
Page
$ 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
51
Page
$ 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
52
Page
$ cat odd.sh
# check whether the entered number is even or odd
echo "Enter a no.: "
read n
x=`expr $n % 2`
if [ $x -eq 0 ]
then
echo "EVEN"
else
echo "ODD"
fi
OUTPUT :
$ sh odd.sh
Enter a no.:
2
EVEN
$ sh odd.sh
Enter a no.:
15
ODD
53
Page
# cat addphone.sh
# To enter a list of names
c=1
while [ $c –eq 1 ]
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
54
Page
Algorithm:
Available:
• It is a 1-d array of size ‘m’ indicating the number of available resources of each type.
• Available[ j ] = k means there are ‘k’ instances of resource type Rj
Max:
• It is a 2-d array of size ‘n*m’ that defines the maximum demand of each process in a
system.
• Max[ i, j ] = k means process Pi may request at most ‘k’ instances of resource type Rj.
Allocation:
• It is a 2-d array of size ‘n*m’ that defines the number of resources of each type
currently allocated to each process.
• Allocation[ i, j ] = k means process Pi is currently allocated ‘k’ instances of resource
type Rj
Need:
• It is a 2-d array of size ‘n*m’ that indicates the remaining resource need of each
process.
• Need [ i, j ] = k means process Pi currently need ‘k’ instances of resource type Rj
for its execution.
• Need [ i, j ] = Max [ i, j ] – Allocation [ i, j ]
Program:
#include <iostream>
int main()
int n, m, i, j, k;
n = 5; // Number of processes
m = 3; // Number of resources
55
{ 2, 0, 0 }, // P1
{ 2, 1, 1 }, // P3
{ 0, 0, 2 } }; // P4
{ 3, 2, 2 }, // P1
{ 9, 0, 2 }, // P2
{ 2, 2, 2 }, // P3
{ 4, 3, 3 } }; // P4
f[k] = 0;
int need[n][m];
int y = 0;
if (f[i] == 0) {
int flag = 0;
flag = 1;
56
Page
break;
if (flag == 0) {
ans[ind++] = i;
avail[y] += alloc[i][y];
f[i] = 1;
return (0);
Output:
57
Page