Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Fundamentals of Operating
Systems (COMP355/L )
A Student's Manual for Computer Lab Works
(COMP355L)
Dr. Mohamed Aissa [email protected]
Room 11 i 13
2
Observations
1. Linux is used in all the conducted lab works.
2. In many lab works, you have to fill tables with the appropriate
commands and to execute these commands.
3. In some exercises, you should write your observations or comments
Fundamentals of Operating Systems
(COMP355L )
Lab Work #1
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 1 Information Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L
4
Lab Work #1 Information Maintenance
Related Chapter Chapter Title
2 Operating-System Structures
STUDENT LEARNING OUTCOMES:
Upon completion of this computer lab, a successful student will be able to:
explain system calls,
get and set time or date
get and set system data
get and set process, file, or device attributes
determine the number of current users,
display the version number of the operating system
Execute many operations on information maintenance.
Information maintenance
Many system calls exist simply for the purpose of transferring information between the
user program and the operating system. We can distinguish the followings types of calls:
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
the number of current users,
the version number of the operating system,
the amount of free memory or disk space, and so on
Lab Work # 1 Information Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L
5
# Command Description Output
1. $ uname -r
The uname command prints information
relating to the kernel version, machine
name, processor type and node name. It
is most commonly used to identify which
version of the kernel a machine is
running
2. $ date;
3. $ date -I To print the date in format yy-month-
date
4. $ cal To print the month calendar
5. $ cal -y To print the calendar of the current year
6. $ cal 2014 To print the calendar of the year 2014
7. `
$ history $ history 10 (ten last commands) $ history –c (clear command history) $ !! (reexecute last command
To view the list of previously typed
commands you can use the bash
built-in command history
Activity #1
Lab Work # 1 Information Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L
6
# Command Description Output
8. $ ls -h show file sizes in human readable format, ie. Formatted for easy reading
9. $ find /home –user student
Find all files under /home
owned by the user student
10. $ find /home –type f -size -100k
Find all files under /home which
are less than 100 KB
11. $ find /home –type f -size +100k
Find all files under /home which
are bigger than 100 KB
12. $ ps ux Show all processes run by
the user
13. $ ps T Show all processes run
under the current terminal
by the user
14. $ ps aux Show all processes on the
system
Activity #2
Dr. Mohamed Aissa Student's Lab Works COMP355L
Fundamentals of Operating Systems
(COMP355L )
Lab Work #2
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 2 File Concept
Dr. Mohamed Aissa Student's Lab Works COMP355L
8
Lab Work #2 File Concept
Related Chapter Chapter Title
2 Operating-System Structures
6 File-System Interface
STUDENT LEARNING OUTCOMES:
Upon completion of this computer lab, a successful student will be able to:
Explain file attributes,
Execute many operations on files
Lab Work # 2 File Concept
Dr. Mohamed Aissa Student's Lab Works COMP355L
9
# Command Description Application
1. touch Create files
Exercise 1 Use a text editor to create the following files: MyData: in this file write your ID, name, major, …. MyCollege: in this file write your University, College, Department, ….
Answer
$ touch MyData MyCollege Now use text editor
2. touch File1 gets the time attributes of file2
Exercise 2
Assign the time attributes of the file MyCollege to the file MyData
Answer
$ touch MyData -r MyCollege
3. ls To see what files you have stored in your current directory
Exercise 3 List the file stored in your current directory Desktop
Answer
$ ls
4. 5. `
cat Displaying the Contents of a File
Exercise 4 Display the content of the file MyData
Answer
$ cat _____________
Activity #1
Lab Work # 2 File Concept
Dr. Mohamed Aissa Student's Lab Works COMP355L
10
Command Description Application
mv Renaming a File
Exercise 5 Rename the file MyData to MyData1
Answer
$ mv ___________ _____________
cp Making a Copy of a File
Exercise 6 Making a Copy of the file MyCollege and name it MyCollege1
Answer
$ cp ________ ______________
rm Removing a File
Exercise 7 Remove the file MyCollege1 from your current directory MyDesktop.
Answer
$ rm ____________
rm Removing .more than one file
Exercise 8 Making a Copy of the file MyCollege and name it MyCollege1 Remove the file MyCollege1 from your current directory MyDesktop.
Answer
$
$ rm ____________ __________
mv Moving Files Between Directories
Exercise 9 Remove the file MyCollege1 from your current directory MyDesktop
Answer
$ mv ____________ / ______________
Observation
You recall that the mv command can be used to rename a file. However, when the two
arguments to this command reference different directories, the file is actually moved from
the first directory into the second directory.
Activity
#2
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
11
Fundamentals of Operating Systems
(COMP355L )
Lab Work #3
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
12
Lab Work #3 Disk Maintenance (Under Windows)
Related Chapter Chapter Title
8 Mass Storage Structure
STUDENT LEARNING OUTCOMES:
Upon completion of this lab work, a successful student will be able to:
clean the hard disk,
launch error-checking operation,
launch error-checking operation,
execute the defragmentation operation
Disk Properties
Disk Cleanup The Disk Cleanup tool helps you free up space on your hard disk by searching your disk
For files that you can safely delete. You can choose to delete some or all of:
temporary Internet files
downloaded program files, such as ActiveX controls and Java applets
the Recycle Bin
temporary Windows files
optional Windows components that you are not using
installed programs that you no longer use.
The following provides step-by-step instructions on how to use the Disk Cleanup tool
under Windows.
Activity #1
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
13
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
14
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
15
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
16
Hard Disk Maintenance – Error Checking using Windows
ScanDisk tools
Chkdsk.exe is a utility which verifies the logical integrity of a file system. In the event of
the utility encountering logical inconsistencies in file system data, it will perform the
necessary actions to repair the file system data. The equivalent utility in earlier versions of
Windows was referred to as ScanDisk. The following describes how to perform error-
checking of a hard drive under Windows XP. Launch disk error checking by double-
clicking My Computer, right-clicking the hard disk drive you want to have checked,
clicking Properties
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
17
and selecting the Tools tab. Click Check Now.
Defragmenting the Hard Drive with Windows
In older file system architectures, if a file could not be stored contiguously, it could not be
saved to the disk. Newer architectures intentionally divide files into multiple pieces so as
to make more efficient use of disk storage space.
Since files are constantly being written, deleted, and resized, fragmentation is a natural and
ongoing occurrence. However, it is also one that has significant performance implications.
When a file is spread out over several locations, it takes longer to read and write. In fact,
the effects of fragmentation can be more widespread than that, causing long boot times,
random crashes and system freeze-ups.
Defragmentation is a time-consuming process, the more so the greater the extent of
fragmentation. It is therefore important to terminate any programs, including those running
in the background like firewalls and anti-virus programs – before starting the
defragmentation process. Failure to do so will mean that it is constantly interrupted,
adversely impacting the time the process takes possibly to the extent of it failing to
complete.
The following describes how to defragment your hard drive using Windows XP’s disk
defragmentation program, which is a free built in component of the operating system.
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
18
Note that you cannot defragment a hard disk that is completely full, and that the less free
space there is, the longer defragmentation will take. This is because the defragmentation
utility need some room in which to temporarily store fragments as it reassemble files.
If your hard disk is relatively full, it is therefore good practice to run Disk Cleanupbefore
attempting to defragment a drive.
Launch the Defragmenter Tool, either via
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
19
Backup
Disk Quota
Lab Work # 3 Disk Maintenance
Dr. Mohamed Aissa Student's Lab Works COMP355L Fall 2015
20
Fundamentals of Operating Systems
(COMP355L )
Lab Work #4
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 4 Directory Implementation
Dr. Mohamed Aissa Student's Lab Works COMP355L
22
Lab Work #4 Directory Implementation (under DOS)
Related Chapter Chapter Title
6 File-System Interface
STUDENT LEARNING OUTCOMES:
Upon completion of this computer lab, a successful student will be able to:
understand directory structure,
understand single-level directory,
understand two-level directory,
understand tree-level directories,
execute many operations on directories,
display the current directory,
change, make and delete directories,
Move a file from one directory to another
Lab Work # 4 Directory Implementation
Dr. Mohamed Aissa Student's Lab Works COMP355L
23
# Command Description Application
1. dir/w Display your current directory content
Exercise 1 Display your current directory content
Answer
D:\> dir/w
2. md Create directories
Exercise 2 Under root directory, create a directory "university" and then inside "university", create a subdirectory "college". Check that the operation was executed successfully.
Answer
D:\> md university D:\> cd university D:\university > md college
3. cd Access to directory
Exercise 3 Enter the directory college from the current directory university
Answer
D:\university >cd college D:\university\college >
4. cd .. Changing directories
Exercise 4 Return back to the directory university.
Answer
D:\university\college > cd..
D:\university >
Activity #1
Lab Work # 4 Directory Implementation
Dr. Mohamed Aissa Student's Lab Works COMP355L
24
5. ` copy Copy a file
Exercise 5 Copy a file file1 from the directory university to the subdirectory "college" under the name file2.doc . Check that the operation was executed successfully.
Answer
D:\university >copy file1.doc \college\file2.doc
del Delete a file
Exercise 6
Delete the file file1.doc from the subdirectory "college". Check that the operation was executed successfully.
Answer
D:\university >del \college\file1.doc
6. ` rd Delete a directory
Exercise 7 Display the content of the directory "university". Delete the subdirectory college.
Answer
D:\university >rd college
Observations
You can remove a directory with the rd command. The stipulation involved in removing a
directory is that no files be contained in the directory. If there are files in the directory
when rd is executed, you will not be allowed to remove the directory.
Activity #2
Fundamentals of Operating Systems
(COMP355L )
Lab Work #5
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 5 Directory Implementation
Dr. Mohamed Aissa Student's Lab Works COMP355L
26
Lab Work #5 Directory Implementation (Under Linux)
Related Chapter Chapter Title
6 File-System Interface
STUDENT LEARNING OUTCOMES:
Upon completion of this computer lab, a successful student will be able to:
understand directory structure,
understand single-level directory,
understand two-level directory,
understand tree-level directories,
execute many operations on directories,
display the current directory,
change, make and delete directories,
Move a file from one directory to another
Lab Work # 5 Directory Implementation
Dr. Mohamed Aissa Student's Lab Works COMP355L
27
# Command Description Application
7. pwd Display your current directory
Exercise 1 Display your current directory.
Answer
$ $
8. cd Changing directories
Exercise 2
Go to the directory student.
Answer
$
$
9. mkdir Create directories
Exercise 3
Inside student directory, create a directory "university" and then inside "university", create a subdirectory "college". Check that the operation was executed successfully.
Answer
$ $
10. ` mv Move a file from one Exercise 4
Activity #1
Lab Work # 5 Directory Implementation
Dr. Mohamed Aissa Student's Lab Works COMP355L
28
directory to another Copy the file MyCollege from Desktop to the subdirectory "college". Check that the operation was executed successfully.
Answer
$ $ $
11. ` rmdir Delete a directory
Exercise 5 Display the content of the directory "university". Delete the directory university.
Answer
$ $ $
12. ` rm -r dir Delete a directory
Exercise 6 Recreate the directory "university" and its subdirectory "college. Delete the directory "university" using a shorter method.
Answer
$ $ $
Observations
1. You can remove a directory with the rmdir command. The stipulation involved in
removing a directory is that no files be contained in the directory. If there are files
in the directory when rmdir is executed, you will not be allowed to remove the
directory.
2. An alternate method for removing a directory and the files contained in it, is using
the -r option to the rm command.
Dr. Mohamed Aissa Student's Lab Works COMP355L
29
Fundamentals of Operating Systems
(COMP355L )
Lab Work #6
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 6 Protection
Dr. Mohamed Aissa Student's Lab Works COMP355L
30
Lab Work #6 Protection
Related Chapter Chapter Title
6 File-System Interface
STUDENT LEARNING OUTCOMES:
Upon completion of this lab work, a successful student will be able to:
list the permissions assigned to all files and directories in a current directory,
assign permissions to users, groups and others
assign permissions to users, groups and others
create a file to direct the outputs of all the executed commands
Manage File Permissions and Ownership
Permission Types
Operation read write execute
Symbol r w x
Octal Value 4 2 1
Permissions can be presented in two ways:
Permissions apply to the user, the group and to others. An item has a set of 3 grouped permissions for each of
these categories.
User Group Other
rwx r-x r-x
4+2+1=7 4+1=5 4+1=5
Lab Work # 6 Protection
Dr. Mohamed Aissa Student's Lab Works COMP355L
31
UNIX system create files and directories with standard permissions as follows:
Files 666 -rw-rw-rw-
Directories 777 -rwxrwxrwx
File and Directory Ownership
ownership for each file and
directory
user group other
Symbol u g o
Changing Permissions with chmod. Changing user and group with chown and chgrp
1. Fill in the following table with the appropriate data. For Description, write the
allowed operations (read, write, execute).
Permission Permission with ( ) for
clarity Digit Mode
Permission Description
Owner Group Other
-rwxrwxr-- -(rwx)(rwx)(r--)
-rw-rw-r-- -(rw-)(rw-)(r--)
2. Fill the following table "Activity #1.
Lab Work # 6 Protection
Dr. Mohamed Aissa Student's Lab Works COMP355L
32
# Command Description Output
1.
chmod
Execute a command to display the
permissions of all the files and
directories residing in the directory
/home/student
2. Give the user, the Group and others all
the permissions of a file (file1).
3. Prevent the group from the execution
permission of a file (file1).
4. Prevent Others from the writing
permission of a file (file1).
5. Prevent Others from the execution
permission of a file (file1)..
6. Add read and write permissions for
Others of a file (file1).
7. Add execution permission for Others of
a file (file1).
3. Create a file named "Protection" and include in this file all the previous commands.
The outputs should be directed to a file "File_pro" saved in same current directory. The file text along with its outputs should be attached.;
Activity #1
33
Fundamentals of Operating Systems
(COMP355L )
Lab Work #7
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 7 CPU Scheduling Algorithms
Dr. Mohamed Aissa Student's Lab Works COMP355L
34
Lab Work #7 First Come First Served Algorithm (FCFS)
Related Chapter Chapter Title
5 CPU Scheduling Algorithm
STUDENT LEARNING OUTCOMES:
Upon completion of this lab work, a successful student will be able to:
Write FCFS algorithm
Implement this algorithm
Questions
1. Write FCFS algorithm
2. Implement this algorithm in C++ or in Linux
35
Fundamentals of Operating Systems
(COMP355L )
Lab Work #8
Dr. Mohamed Aissa
Office # 11 i 13
Lab Work # 8 Deadlocks
Dr. Mohamed Aissa Student's Lab Works COMP355L
36
Lab Work #8 Banker's Algorithm
Related Chapter Chapter Title
6 Deadlocks
STUDENT LEARNING OUTCOMES:
Upon completion of this lab work, a successful student will be able to:
Write Banker's algorithm
Implement this algorithm
Questions
3. Write Banker's algorithm
4. Implement this algorithm in C++ or in Linux