操作系统assignment代写 Question 1 For these questions consider a Unix like file system as on slide 11 of lecture 21 where the number of direct blocks is 12.
For these questions consider a Unix like file system as on slide 11 of lecture 21 where the number of direct blocks is 12. Each block is 8KiB (8,192 bytes) and a block number consists of 8 bytes.
For all questions show your working. You may write a program to help calculate these answers. If you do this, include this program in the answer box below. Ensure that the program is clear with good comments. The markers will not run this program but they will read it to allocate marks for your working.
If you do not provide a program, please show your working in each question a) to e).
All numbers in the answers should be the number of bytes. Exact answers required. Each part is 2pts.
a) What is the maximum size for a file which does not use an indirect block?
b) What is the maximum size for a file which uses the single indirect block? (not the double or triple).
c) What is the maximum size for a file which uses the double indirect block? (not the triple).
d) What is the maximum size for a file in this system?
e) How many levels of indirection would be needed if we were to extend this file system to accommodate files up to 8 exbibyte (an exbibyte = 10246 bytes) in size?
Question 2 操作系统assignment代写
Using the same file system as in Question 1 describe every block access (read or write) which is required to complete the tasks below.
The descriptions should be in the same order as the accesses. i.e. If you need data from a block before continuing you must describe the access to that block before continuing. Sometimes different orders will work. The markers will look for workable orders.
For access to a data block you should describe it like this:
1 read of block 4 to get bytes 25,000 to 25,100
Block numbers of the file start at 0. Byte positions in the file start at 0.
For access to an index block you should describe it like this:
1 read to get a block number from the single indirect block
2 reads to get a block number from the double indirect block and the corresponding index block
You do not need to specify the block numbers or the locations for indirect and index blocks.
All read requests are valid. All write requests happen inside the existing file data, i.e. the file size will not change.
The inode for the file has been found and read into memory.
All blocks outside the inode are NOT in memory at the start of each task but if loaded once during the task they stay in memory until that task is completed.
File access times do NOT have to be written to the on disk inode.
File modified times do have to be written to the on disk inode.
The on disk inode occupies one block and several changes can be written with one write.
All device reads and writes work on individual blocks.
a) Writing 100 bytes starting at byte position 8,100 of the file.
b) Reading 100 bytes starting at byte position 8,486,900 of the file.
Question 3 操作系统assignment代写
A file has 10 blocks. For each of the following requests calculate the number of disk accesses (both reads and writes need to be counted) which are required to satisfy the request under the three different allocation techniques. Put the answers in the table.
Each request is independent of the other requests. i.e. Each request starts from the initial file setup.
- In the contiguous allocation technique the starting and length values are in memory. There is room to grow at both ends of the file. There is always enough space for the file somewhere on the disk.
- In the linked technique the first and last block numbers are in memory. It is a doubly linked list of blocks. The last block holds the value -1 in its next block pointer. The first block holds the value -1 in its previous block pointer.
- In the indexed technique the index block is in memory. The index is single-level.
You may assume changes to metadata about the file are only in memory. i.e. They do not require block accesses.
Block numbers start at zero.
- Read block number 5
- Read all even numbered blocks.
- Add a new block at the start of the file.
- Add a new block at the end of the file.
- Insert a new block between blocks number 4 and number 5.
- Remove the first block in the file.
- Remove the last block in the file.
- Remove all even numbered blocks. Do this in the most efficient way you can think of.
|Request||Contiguous allocation||Linked allocation||Indexed allocation|
Question 4 操作系统assignment代写
Consider this global two-dimensional array stored in row-major order, 100 rows and 100 columns:
int A = new int;
where A is at location 256 in a paged memory system with pages of size 256. A small process that manipulates the array resides in page 0 (locations 0 to 255). Thus, every instruction fetch will be from page 0. Each integer in A occupies one memory location.
There are three frames. For the following questions use LRU replacement, and assume that frame 0 contains the process code and local variables of page 0, the other two are initially empty.
a) Say how many page faults are caused by the following code. Explain your answer.
for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) A[i][j] = 0;
b) Say how many page faults are caused by the following code. Explain your answer.
for (int j = 0; j < 100; j++) for (int i = 0; i < 100; i++) A[i][j] = 0;
c) How do your answers in a) and b) relate to the concepts of “locality of reference” and “working sets”?’
Question 5 操作系统assignment代写
Here is an array with a page reference string in the header row. This machine has 4 frames. Initially all frames are free.
Each following row shows the changes to the frame content over time for each frame in the machine.
Copy this array and paste it into the answer box 4 times. Fill the arrays in with the changes made using each of specified page replacement algorithms.
Show the cells which change as pages get replaced. The first 4 changes have been done for you. Each value you enter is the result of a page fault.
Only enter a number into the table if the corresponding frame changes its contents, it makes it easier for the marker to mark.
- FIFO – First In First Out
- LRU – Least Recently Used
- LFU – Least Frequently Used (if there are multiple pages with the same lowest frequency choose in a FIFO manner)
- Optimal (if there are multiple pages which are not used again choose in a FIFO manner).