Operating System | Assignment 1
VerifiedAdded on 2022/10/02
|13
|1864
|30
Assignment
AI Summary
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Operating System 1
OPERATING SYSTEM
By Student's Name
Course Code and Name
Professor’s Name
University Name
City, State
Date of Submission
OPERATING SYSTEM
By Student's Name
Course Code and Name
Professor’s Name
University Name
City, State
Date of Submission
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Operating System 2
Question 1a
Given 3,1,4,1,2,3,5,3,2,1,2,5,4,3,5,2,4,2,5,3
Given the frame number is 3
i) Using LRU algorithm
It uses the principle of if a page fault occurs then the least recently used element is removed
and new element is inserted.
Note: The F is used to represent the page fault.
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 2 2 2 2 2 2 2 2 2
1 1 1 1 1 5 5 5 1 1 1 4
4 4 4 3 3 3 3 3 3 5 5
F F F F F F F F F F
3 5 2 4 2 5 3
3 3 3 4 4 4 4
4 4 2 2 2 2 2
Question 1a
Given 3,1,4,1,2,3,5,3,2,1,2,5,4,3,5,2,4,2,5,3
Given the frame number is 3
i) Using LRU algorithm
It uses the principle of if a page fault occurs then the least recently used element is removed
and new element is inserted.
Note: The F is used to represent the page fault.
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 2 2 2 2 2 2 2 2 2
1 1 1 1 1 5 5 5 1 1 1 4
4 4 4 3 3 3 3 3 3 5 5
F F F F F F F F F F
3 5 2 4 2 5 3
3 3 3 4 4 4 4
4 4 2 2 2 2 2
Operating System 3
5 5 5 5 5 5 3
F F F F
ii) FIFO algorithm
With this algorithm we replace the element inserted first
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 2 2 2 2 2 1 1 1 4
1 1 1 1 3 3 3 3 3 2 2 2
4 4 4 4 5 5 5 5 5 5 5
F F F F F F F F F
5 5 5 5 5 5 3
F F F F
ii) FIFO algorithm
With this algorithm we replace the element inserted first
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 2 2 2 2 2 1 1 1 4
1 1 1 1 3 3 3 3 3 2 2 2
4 4 4 4 5 5 5 5 5 5 5
F F F F F F F F F
Operating System 4
3 5 2 4 2 5 3
4 4 4 4 4 5 5
3 3 3 3 3 3 3
5 5 2 2 2 2 2
F F F
iii) Optimal page replacement algorithm
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 3 3 3 3 3 1 1 1 4
1 1 1 1 1 5 5 5 5 5 5 5
4 4 2 2 2 2 2 2 2 2 2
F F F F F F F
3 5 2 4 2 5 3
4 4 4 4 4 5 5
3 3 3 3 3 3 3
5 5 2 2 2 2 2
F F F
iii) Optimal page replacement algorithm
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 3 3 3 3 3 1 1 1 4
1 1 1 1 1 5 5 5 5 5 5 5
4 4 2 2 2 2 2 2 2 2 2
F F F F F F F
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Operating System 5
3 5 2 4 2 5 3
3 3 3 4 4 4 4
5 5 5 5 5 5 3
2 2 2 2 2 2 2
F
Using 4 frame
i) LRU
In this case F represent the faults
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 2 2 2 2 2 2 2 2 2
1 1 1 3 3 3 3 3 3 3 3 3
4 4 1 1 5 5 5 5 5 5 5
3 5 2 4 2 5 3
3 3 3 4 4 4 4
5 5 5 5 5 5 3
2 2 2 2 2 2 2
F
Using 4 frame
i) LRU
In this case F represent the faults
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 2 2 2 2 2 2 2 2 2
1 1 1 3 3 3 3 3 3 3 3 3
4 4 1 1 5 5 5 5 5 5 5
Operating System 6
4 4 4 4 4 1 1 1 4
F F F F F F F F
3 5 2 4 2 5 3
2 2 2 2 2 2 2
3 3 3 3 3 3 3
5 5 5 5 5 5 5
4 4 4 4 4 4 4
Using 4 frame
ii) FIFO
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 3 3 5 5 5 5 5 5 5
1 1 1 1 1 1 3 3 3 3 3 3
4 4 4 4 4 4 4 1 1 1 1
4 4 4 4 4 1 1 1 4
F F F F F F F F
3 5 2 4 2 5 3
2 2 2 2 2 2 2
3 3 3 3 3 3 3
5 5 5 5 5 5 5
4 4 4 4 4 4 4
Using 4 frame
ii) FIFO
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 3 3 5 5 5 5 5 5 5
1 1 1 1 1 1 3 3 3 3 3 3
4 4 4 4 4 4 4 1 1 1 1
Operating System 7
2 2 2 2 2 2 2 2 4
F F F F F F F F
3 5 2 4 2 5 3
5 5 5 5 5 5 5
3 3 2 2 2 2 2
1 1 1 1 1 1 1
4 4 4 4 4 4 3
F F
2 2 2 2 2 2 2 2 4
F F F F F F F F
3 5 2 4 2 5 3
5 5 5 5 5 5 5
3 3 2 2 2 2 2
1 1 1 1 1 1 1
4 4 4 4 4 4 3
F F
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Operating System 8
iii) Optimal page replacement algorithm
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 3 3 3 3 3 3 3 3 3
1 1 1 1 1 1 1 1 1 1 1 4
4 4 4 4 5 5 5 5 5 5 5
2 2 2 2 2 2 2 2 2 2
F F F F F
3 5 2 4 2 5 3
3 3 3 3 3 3 3
5 5 5 5 5 5 5
4 4 4 4 4 4 4
iii) Optimal page replacement algorithm
3 1 4 1 2 3 5 3 2 1 2 5 4
3 3 3 3 3 3 3 3 3 3 3 3 3
1 1 1 1 1 1 1 1 1 1 1 4
4 4 4 4 5 5 5 5 5 5 5
2 2 2 2 2 2 2 2 2 2
F F F F F
3 5 2 4 2 5 3
3 3 3 3 3 3 3
5 5 5 5 5 5 5
4 4 4 4 4 4 4
Operating System 9
2 2 2 2 2 2 2
Question 1b
i)
Page fault occurs when there is no free page in the frame ( Silberschatz et al,2018).
Therefore the process that follows is to evict one page from the free frame pool to the disk to
create more space for one of the resident pages to be moved to the free frame pool
ii )
Page fault will always occur and when it does and there exist a page in the free frame pool
then the page is moved into the set of resident pages while one of the resident pages is moved
to the free frame pool.
iii )
If the number of resident page is set to one then the free frame replacement algorithm that
will be used is the LRU page replacement
iv )
When the number of pages are zero then the page replacement in free frame algorithm
becomes as FIFO replacement algorithm
Question 2
2 2 2 2 2 2 2
Question 1b
i)
Page fault occurs when there is no free page in the frame ( Silberschatz et al,2018).
Therefore the process that follows is to evict one page from the free frame pool to the disk to
create more space for one of the resident pages to be moved to the free frame pool
ii )
Page fault will always occur and when it does and there exist a page in the free frame pool
then the page is moved into the set of resident pages while one of the resident pages is moved
to the free frame pool.
iii )
If the number of resident page is set to one then the free frame replacement algorithm that
will be used is the LRU page replacement
iv )
When the number of pages are zero then the page replacement in free frame algorithm
becomes as FIFO replacement algorithm
Question 2
Operating System 10
a).
The file-system in Unix has the concept of a “hard link” and a “soft link”. A link in Unix is a
pointer to files and thus links in UNIX are pointers which point to a file or at a directory.
Hard links are used in the Unix file-system by always referring the source, even if the file is
moved or deleted(Comer, 2015). But when using a soft link in Unix file-system to access and
create a soft link of the file, we cannot access the file through a soft link and the soft link
becomes dangling when the file is moved or deleted.
b)
Based on the Unix file-system implementation discussed, Unix does not allow a “hard link”
to a directory but will allow a “soft link” to a directory. Hard links create many problems in
Unix file system such as:
Hard link of a directory can link a parent to itself and thus creates a file system loop.
Hard links are more ambiguous.
Using hard links will break the directed acyclic graph structure of the file system and will
also risk the directory loops and dangling directory subtrees which will make the file-system
error prone.
c.)
When copying a file on a USB flash drive on the Unix system it is extremely important to
unmount the flash drive before removing the device because in Unix, once the data is copied
to the external USB drive the OS puts the write operation in a queue, and if you unplug the
USB device before the OS has finished performing its operations and also written all the data
and also created the links to access the data, then it is a problem and the copied file will not
a).
The file-system in Unix has the concept of a “hard link” and a “soft link”. A link in Unix is a
pointer to files and thus links in UNIX are pointers which point to a file or at a directory.
Hard links are used in the Unix file-system by always referring the source, even if the file is
moved or deleted(Comer, 2015). But when using a soft link in Unix file-system to access and
create a soft link of the file, we cannot access the file through a soft link and the soft link
becomes dangling when the file is moved or deleted.
b)
Based on the Unix file-system implementation discussed, Unix does not allow a “hard link”
to a directory but will allow a “soft link” to a directory. Hard links create many problems in
Unix file system such as:
Hard link of a directory can link a parent to itself and thus creates a file system loop.
Hard links are more ambiguous.
Using hard links will break the directed acyclic graph structure of the file system and will
also risk the directory loops and dangling directory subtrees which will make the file-system
error prone.
c.)
When copying a file on a USB flash drive on the Unix system it is extremely important to
unmount the flash drive before removing the device because in Unix, once the data is copied
to the external USB drive the OS puts the write operation in a queue, and if you unplug the
USB device before the OS has finished performing its operations and also written all the data
and also created the links to access the data, then it is a problem and the copied file will not
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Operating System 11
show in the USB drive . Only after the OS has finished all the operations and the USB device
has safely unmounted, the USB drive will normally appear on the flash drive’s file system.
File metadata is copied synchronously but the file data is copied asynchronously . This is
because the file system if writes everything to the disk as soon as write happens, it will be a
very slow process and would result in a slow system. Thus file systems, do not update
everything synchronously as this would result in performance issues and thus data is copied
asynchronously. For File, metadata is copied synchronously to sequence metadata updates in
the file system and maintain consistency.
Question 3
File system first removes pages related to the file from cache
Sets d time(deletion time)
Now file system looks for inode entry for the directory of file and the file itself
It does not removes inode entries, once entry is located file system marks it as
dirty/unused so that it can be reused for other files or directories( Gould and
Nevraev,2019)
show in the USB drive . Only after the OS has finished all the operations and the USB device
has safely unmounted, the USB drive will normally appear on the flash drive’s file system.
File metadata is copied synchronously but the file data is copied asynchronously . This is
because the file system if writes everything to the disk as soon as write happens, it will be a
very slow process and would result in a slow system. Thus file systems, do not update
everything synchronously as this would result in performance issues and thus data is copied
asynchronously. For File, metadata is copied synchronously to sequence metadata updates in
the file system and maintain consistency.
Question 3
File system first removes pages related to the file from cache
Sets d time(deletion time)
Now file system looks for inode entry for the directory of file and the file itself
It does not removes inode entries, once entry is located file system marks it as
dirty/unused so that it can be reused for other files or directories( Gould and
Nevraev,2019)
Operating System 12
Question 4a
Buffer is used by the user program for data transmission from the device. Virtual address is
as a result of having the buffer space in the user space. When the kernel wants to use the
Input output operation it will have to copy the data that is placed between the two buffers
that is the user buffer and its own buffer before and after the Input output operation . (Lin et
al 2016). Suppose you want to get access to user buffer. The virtual address in the user
program will be converted by the kernel to correspond to the physical address that best fit the
user program virtual address space. The conversion of the physical addresss to virtual address
is well performed in a software In cases where the user buffer space is not available in page
frame then the corresponding pages will be obtained from the substitute space. This activity
is experiences delays and therefore it is recommend that it is done carefully.
Question 4b.
System program must support a separate table for each process because if there will be only
one table for all process then it can't be tracked that which part of the file is accessed by
which process. Also, suppose a file is opened by the different process having the same file
descriptor then if the file is deleted then it will be still present on the disk because other
processes are still accessing the file or not closed the file. i.e close(fd) where fd is file
descriptor. When all process will close the file then the only file can be removed from disk.
So for an operating system, it should maintain the different table for the different process.
When a process is created then many information needs to store to keep track of the process's
activity.so the operating system should NOT maintain just one table that contains references
to files that are being accessed by all processes at the current time (Stallings and Manna,
2015 ). It should maintain a separate table for each process to keep track of all process
independently. Since step by step with proper reason are given for your full understanding.
Question 4a
Buffer is used by the user program for data transmission from the device. Virtual address is
as a result of having the buffer space in the user space. When the kernel wants to use the
Input output operation it will have to copy the data that is placed between the two buffers
that is the user buffer and its own buffer before and after the Input output operation . (Lin et
al 2016). Suppose you want to get access to user buffer. The virtual address in the user
program will be converted by the kernel to correspond to the physical address that best fit the
user program virtual address space. The conversion of the physical addresss to virtual address
is well performed in a software In cases where the user buffer space is not available in page
frame then the corresponding pages will be obtained from the substitute space. This activity
is experiences delays and therefore it is recommend that it is done carefully.
Question 4b.
System program must support a separate table for each process because if there will be only
one table for all process then it can't be tracked that which part of the file is accessed by
which process. Also, suppose a file is opened by the different process having the same file
descriptor then if the file is deleted then it will be still present on the disk because other
processes are still accessing the file or not closed the file. i.e close(fd) where fd is file
descriptor. When all process will close the file then the only file can be removed from disk.
So for an operating system, it should maintain the different table for the different process.
When a process is created then many information needs to store to keep track of the process's
activity.so the operating system should NOT maintain just one table that contains references
to files that are being accessed by all processes at the current time (Stallings and Manna,
2015 ). It should maintain a separate table for each process to keep track of all process
independently. Since step by step with proper reason are given for your full understanding.
Operating System 13
References
Comer, D., 2015. Operating system design: the XINU approach. Chapman and Hall/CRC.
Gould, J.M. and Nevraev, I., Microsoft Technology Licensing LLC, 2019. Fifo queue,
memory resource, and task management for graphics processing. U.S. Patent
Application 16/001,608.
Lin, M., Yao, Z. and Huang, T., 2016. F-LRU: An efficient buffer replacement algorithm for
NAND flash-based databases. Optik-International Journal for Light and Electron
Optics, 127(2), pp.663-667
Silberschatz, A., Gagne, G. and Galvin, P.B., 2018. Operating system concepts.
Stallings, W. and Manna, M.M., 2015. Operating systems: internals and design principles.
References
Comer, D., 2015. Operating system design: the XINU approach. Chapman and Hall/CRC.
Gould, J.M. and Nevraev, I., Microsoft Technology Licensing LLC, 2019. Fifo queue,
memory resource, and task management for graphics processing. U.S. Patent
Application 16/001,608.
Lin, M., Yao, Z. and Huang, T., 2016. F-LRU: An efficient buffer replacement algorithm for
NAND flash-based databases. Optik-International Journal for Light and Electron
Optics, 127(2), pp.663-667
Silberschatz, A., Gagne, G. and Galvin, P.B., 2018. Operating system concepts.
Stallings, W. and Manna, M.M., 2015. Operating systems: internals and design principles.
1 out of 13
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.