Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Exercise (Disk&File)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 22

Exercises

Exercise 1
Consider a file currently consisting of 100 blocks.
Assume that the file control block(and the index block,
in the case of indexed allocation) is already in memory.
Describe the type of operations required for
contiguous, linked, and indexed (single-level)allocation
strategies, if, for one block, the following conditions
hold. In the contiguous allocation case, assume that
there is no room to grow in the beginning, but there is
room to grow in the end. Assume that the block
information to be added is stored in memory.
(a) The block is added at the beginning.
(b) The block is added at the end.
Exercise
Consider a file currently consisting of 100 blocks. Assume that the file control block (and the index
block, in the case of indexed allocation) is already in memory. Calculate how many disk I/O
operations are required for contiguous, linked, and indexed (single--level) allocation strategies, if,
for one block, the following conditions hold. In the contiguous--allocation case, assume that there is
no room to grow in the beginning, but there is room to grow in the end. Assume that the block
information to be added is stored in memory.

Assumptions:
Each I/O operation reads or writes a whole block.
For linked allocation, a file allocation table (FAT) is not used, i.e., only the address of the starting block is in
memory.
The blocks are numbered 1 to 101 and the current positions of these blocks are also numbered 1 to 101.
Do not include any I/O operations are needed to add a freed block to the free list.
there is no room to grow in the beginning, but there is room to grow in the end
The middle block is the 51st block.
In calculating the number of I/O operations, if the location of the block of a file changes, do not include the output
operations nedded to rewrite that revised information to the directory entry on the disk.
Add a block at the beginning.
Add a block after the middle block.
Add the block at the end.
Remove the beginning block.
Remove the middle block.
Remove the end block.
Exercise
On a system using contiguous allocation,
compute the number of the physical block
corresponding to the logical block given the file
is stored starting at the indicated physical
block(assume block numbers start with 1).
(a) Starting physical block:1000; logical block:12
(b) Starting physical block:75; logical block:2000

Ans(a) 1011
(b) 2074
Exercise
A file system uses 256-byte physical blocks. Each file has a directory
entry giving the file name, location of the first block, length of file, and
the last block position. Assume the last block read and the directory
entry are already in main memory. For the following, indicate how many
physical blocks must be read to access the specified block(including the
reading of the specified block) on a system using contiguous allocation.
(a) Last block read:100, block to be read:600
(b) Last block read:500, block to be read:200

Ans: 1 . (The location of the physical block to be read can be computed


from the block number and the location of the first block)
Exercise
Repeat the previous problem for a system using linked
allocation.* (Ans- (a) 500 (b) 200)
Repeat the previous problem for a system using
indexed allocation. Assume the directory entry
contains the location of the first index block(not the
first block of the file). Each index block contains
pointers to 127 file blocks plus a pointer to the next
index block. In addition to the last block read, assume
the system has in main memory the index block that
contains the pointer to the last block read. However no
other index blocks are in the main memory.( Ans (a) 5
(b) 3)
Exercise
Describe the interpretation of the following
under the command chmod:
a. 444
b. 111 001 101

You might also like