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.

.

Calculate how many disk I/O operations are required for contiguous. but there is room to grow in the end • The middle block is the 51st block. and indexed (single--level) allocation strategies. a file allocation table (FAT) is not used. • Do not include any I/O operations are needed to add a freed block to the free list. • Assumptions: • Each I/O operation reads or writes a whole block.e. for one block.. • In calculating the number of I/O operations. in the case of indexed allocation) is already in memory. the following conditions hold. assume that there is no room to grow in the beginning. but there is room to grow in the end. • The blocks are numbered 1 to 101 and the current positions of these blocks are also numbered 1 to 101. do not include the output operations nedded to rewrite that revised information to the directory entry on the disk. linked. if. Assume that the block information to be added is stored in memory. Exercise • Consider a file currently consisting of 100 blocks. . In the contiguous--allocation case. only the address of the starting block is in memory. • there is no room to grow in the beginning. • For linked allocation. if the location of the block of a file changes. Assume that the file control block (and the index block. i.

• Add the block at the end. • Add a block after the middle block. • Remove the beginning block. • Remove the middle block. . • Remove the end block.• Add a block at the beginning.

.

logical block:12 (b) Starting physical block:75. 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). Exercise On a system using contiguous allocation. logical block:2000 Ans(a) 1011 (b) 2074 . (a) Starting physical block:1000.

For the following. block to be read:600 (b) Last block read:500. location of the first block. Each file has a directory entry giving the file name. block to be read:200 Ans: 1 . Assume the last block read and the directory entry are already in main memory. length of file. Exercise A file system uses 256-byte physical blocks. (The location of the physical block to be read can be computed from the block number and the location of the first block) . 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. and the last block position.

* (Ans.( Ans (a) 5 (b) 3) . Exercise • Repeat the previous problem for a system using linked allocation. assume the system has in main memory the index block that contains the pointer to the last block read. In addition to the last block read. Assume the directory entry contains the location of the first index block(not the first block of the file). However no other index blocks are in the main memory.(a) 500 (b) 200) • Repeat the previous problem for a system using indexed allocation. Each index block contains pointers to 127 file blocks plus a pointer to the next index block.

111 001 101 . 444 b. Exercise Describe the interpretation of the following under the command chmod: a.