Os Assignment
Os Assignment
1. Regular files - These are the most common type of file in Unix
and contain data such as text, images, and executable code.
2. Directories - These are containers for files and other directories.
3. Symbolic links - These are files that point to another file or
directory.
4. Device files - These represent hardware devices such as printers
or disk drives.
5. Named pipes - These are used for inter-process communication
between programs.
6. Sockets - These are used for network communication between
programs.
Each file in Unix has a set of permissions that determines who can
read, write, or execute the file. The permissions are divided into three
categories: user, group, and other, and can be set using the chmod
command.
b) How are Files Systems organized with UNIX ? Explain with an
example.
Unix file systems are organized hierarchically, with the root directory at
the top of the hierarchy, and all other directories and files located
beneath it. The root directory is denoted by a forward slash (/) and all
directories are separated by forward slashes.
/
|--home
|--user1
|--user2
Each directory in the file system can contain files and other
directories. For example, the "user1" directory might contain a file
named "file1.txt" and a subdirectory named "documents", which
contains several other files and subdirectories. The file system
hierarchy would then look like this:
/
|--home
|--user1
|--file1.txt
|--documents
|--document1.doc
|--document2.doc
|--subdirectory1
|--subdocument1.doc
|--subdocument2.doc
|--subdirectory2
|--subdocument3.doc
|--subdocument4.doc
|--user2
b) Explain LRU, FIFO, and OPT page replacement policy for given
page sequences. Page frame size is 4.
Page sequence - 2, 3,4,2,1,3,7,5,4,3,2,3,1
Calculate page hit & miss.
LRU, FIFO, and OPT are three common page replacement algorithms
used in operating systems to manage virtual memory.
● LRU (Least Recently Used) - In this algorithm, the page that has
not been used for the longest period of time is replaced when a
page fault occurs.
● FIFO (First-In, First-Out) - In this algorithm, the page that has
been in memory the longest is replaced when a page fault
occurs.
● OPT (Optimal) - In this algorithm, the page that will not be used
for the longest period of time in the future is replaced when a
page fault occurs.
Now let's apply these algorithms to the given page sequence with a
page frame size of 4.
Page sequence: 2, 3, 4, 2, 1, 3, 7, 5, 4, 3, 2, 3, 1
2, X, X, X
2, 3, X, X
2, 3, 4, X
X, 3, 4, 2
1, 3, 4, 2
1, 3, 7, 2
1, 5, 7, 2
1, 5, 4, 2
X, 5, 4, 3
X, X, 4, 3
X, X, 2, 3
X, 1, 2, 3
Page hit: 5
Page miss: 8
2. FIFO:
2, X, X, X
2, 3, X, X
2, 3, 4, X
2, 3, 4, X
1, 3, 4, X
1, 3, 7, X
1, 5, 7, X
1, 5, 4, X
X, 5, 4, 3
X, X, 4, 3
X, X, 2, 3
X, 1, 2, 3
Page hit: 4
Page miss: 9
3. OPT:
2, X, X, X
2, 3, X, X
2, 3, 4, X
X, 3, 4, 2
1, 3, 4, 2
1, 3, 7, 2
1, 5, 7, 2
X, 5, 4, 2
X, X, 4, 3
X, X, 2, 3
X, 1, 2, 3
Page hit: 6
Page miss: 7
As we can see from the above calculations, the OPT algorithm has the
least number of page faults and hence is the optimal algorithm, but it
is not always possible to use OPT as it requires future knowledge of
the page references. LRU and FIFO are the most common page
replacement algorithms used in practice.