Consider a file system on a disk that has a logical block size of 1024 bytes and
ID: 3539748 • Letter: C
Question
Consider a file system on a disk that has a logical block size of 1024 bytes and assume that the information about each file (i.e., the folder) is already in memory and that each pointer requires 8 bytes under linked and indexed allocation methods, answer the following questions: (5 points)
(a) How many blocks are required for storing a 259KB file under (i) contiguous, (ii) linked, and (iii) indexed allocation methods? Note that 1KB is 1024 bytes.
(b) How many blocks must be read from the disk under linked allocation when the user wants to access data on the 19857th byte of that file?
(c) How many blocks must be read from the disk under indexed allocation when the user wants to access data on the 47258th byte of that file?
Explanation / Answer
Given block size=1024 bytes(1KB block size)
pointer requires=8 bytes
file size =259kB=259*1024 bytes
(a) blocks required:
contiguous allocation:
-> Just lay out the file in contiguous disk blocks.
->here only file content going to store in each block
no.of blocks required=259*1024/1024=259 blocks required
linked allocation:
->have to store data + pointer to next block in each and every block
so in 1024 bytes of a block 8 bytes will be useful for storing a pointer=>1024-8=1016
->so now have to find how many 1016 blocks are required to store 259*1024 bytes of data and given by:
259*1024/1016=261.04=262 blocks required(last block will store 0.04 bytes of data so that holds internal fragmentation)
index allocation:
->store all pointers together in an index table
-> the index table itself can be stored as block
here for file 259 block --- for each block 1 ptr of 8 bytes i.e., 259*8=2072 bytes more required for ptrs=2.02= 3 more blocks
total blocks = 259+3=262 blocks required
(b) How many blocks must be read from the disk under linked allocation when the user wants to access data on the 19857th byte of that file?
Ans:
19857th byte----19857/1016(since here 8 bytes of block will go for pointer)=19.54=20
i.e., have to access 20th block to read 19827 byte in linked allocation
(c) How many blocks must be read from the disk under indexed allocation when the user wants to access data on the 47258th byte of that file?
->since here pointers are stored individually in indexed table , each block going to hold only the file data.
so:
47258/1024=46.15=47th block
i.e., to access 47258th byte have to access 47th block
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.