operating system - Assignment, Assignments of Operating Systems

operation system Assignments to learn well and helpful

Typology: Assignments

2022/2023

Uploaded on 10/09/2022

unknown user
unknown user 🇱🇰

5

(1)

4 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Q1. Explain the steps in handling a page fault?
1. The memory address requested is first checked, to make sure it was a valid memory request.
2. If the reference was invalid, the process is terminated. Otherwise, the page must be paged in.
3. A free frame is located, possibly from a free-frame list.
4. A disk operation is scheduled to bring in the necessary page from disk. (This will usually block
the process on an I/O wait, allowing some other process to use the CPU in the meantime.)
5. When the I/O operation is complete, the processes page table is updated with the new frame
number, and the invalid bit is changed to indicate that this is now a valid page reference.
6. The instruction that cause the page fault must now be restarted from the beginning. (as soon as
this process gets another turn on the CPU.)
Q2. Describe the stages in demand paging of worse case?
1. Trap the operating system.
2. Save the user registers and process state.
3. Determine that the interrupt was a page fault.
4. Check that the page reference was legal and determine the location of the page on the disk.
5. Issue a read from the disk to a free frame:
a) Wait in a queue for this device until the read request is serviced.
b) Wait for the device seek and/or latency time.
c) Begin the transfer of the page to a free frame.
6. While waiting, allocate the CPU to some other user.
7. Receive an interrupt for the disk I/O subsystem (I/O completed.)
8. Save the registers and process state for the other user.
9. Determine that the interrupt was from the disk.
10. Correct the page table and other tables to show page is now in memory.
11. Wait for the CPU to be allocated to this process again.
12. Restore the user registers, process state, and new page table, and then resume the interrupted
instruction.
Q3. Differences between;
a) Second chance clock algorithm v/s Enhanced second chance algorithm
Second chance algorithm
A simple modification to FIFO that avoids the problem of throwing out a heavily used page is to
inspect the R bit of the oldest page. If it is 0, the page is both old and unused, so it is replaced
immediately. If the R bit is 1, the bit is cleared, the page is put onto the end of the list of pages,
and its load time is updated as though it had just arrived in memory. Then the search continues.
pf3

Partial preview of the text

Download operating system - Assignment and more Assignments Operating Systems in PDF only on Docsity!

Q1. Explain the steps in handling a page fault?

  1. The memory address requested is first checked, to make sure it was a valid memory request.
  2. If the reference was invalid, the process is terminated. Otherwise, the page must be paged in.
  3. A free frame is located, possibly from a free-frame list.
  4. A disk operation is scheduled to bring in the necessary page from disk. (This will usually block the process on an I/O wait, allowing some other process to use the CPU in the meantime.)
  5. When the I/O operation is complete, the processes page table is updated with the new frame number, and the invalid bit is changed to indicate that this is now a valid page reference.
  6. The instruction that cause the page fault must now be restarted from the beginning. (as soon as this process gets another turn on the CPU.)

Q2. Describe the stages in demand paging of worse case?

  1. Trap the operating system.
  2. Save the user registers and process state.
  3. Determine that the interrupt was a page fault.
  4. Check that the page reference was legal and determine the location of the page on the disk.
  5. Issue a read from the disk to a free frame: a) Wait in a queue for this device until the read request is serviced. b) Wait for the device seek and/or latency time. c) Begin the transfer of the page to a free frame.
  6. While waiting, allocate the CPU to some other user.
  7. Receive an interrupt for the disk I/O subsystem (I/O completed.)
  8. Save the registers and process state for the other user.
  9. Determine that the interrupt was from the disk.
  10. Correct the page table and other tables to show page is now in memory.
  11. Wait for the CPU to be allocated to this process again.
  12. Restore the user registers, process state, and new page table, and then resume the interrupted instruction.

Q3. Differences between;

a) Second chance clock algorithm v/s Enhanced second chance algorithm

Second chance algorithm  A simple modification to FIFO that avoids the problem of throwing out a heavily used page is to inspect the R bit of the oldest page. If it is 0, the page is both old and unused, so it is replaced immediately. If the R bit is 1, the bit is cleared, the page is put onto the end of the list of pages, and its load time is updated as though it had just arrived in memory. Then the search continues.

 The operation of this algorithm, called second chance clock algorithm. Enhanced Second-Chance Algorithm.  Improve algorithm by using reference bit and modify bit (if available) in concert  Take ordered pair (reference, modify)

  1. (0, 0) neither recently used not modified – best page to replace
  2. (0, 1) not recently used but modified – not quite as good, must write out before replacement
  3. (1, 0) recently used but clean – probably will be used again soon
  4. (1, 1) recently used and modified – probably will be used again soon and need to write out before replacement  When page replacement called for, use the clock scheme but use the four classes replace page in lowest non-empty class  Might need to search circular queue several times

b) Counting based algorithm v/s Page Buffering Algorithm

Counting based algorithm  Keep a counter of the number of references that have been to made each page.  LFU Algorithm: replaces page with smallest count  Keep a counter of the number of references that have been made to each page  Lease Frequently Used (LFU) Algorithm: replaces page with smallest count  Most Frequently Used (MFU) Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used Page Buffering Algorithm  Keep a pool of free frames.  When page faults, the desired page is read into a free frame from the pool before the victim is written to disk.  Allow the process to restart as soon as possible.  When convenient, evict victim Possibly, keep list of modified pages  When backing store otherwise idle, write pages there and set to non-dirty Possibly, keep free frame contents intact and note what is in them  If referenced again before reused, no need to load contents again from disk.  Generally useful to reduce penalty if wrong victim frame selected.