Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer the following questions: 1. Give an example of an application that

ID: 3768132 • Letter: P

Question

Please answer the following questions:

1. Give an example of an application that could benefit from operating-system support for random access to indexed files.

(for 2 do not copy it directly from a online source unless it's exactly like this)

2. Answer this problem by assuming that there is no triple-indirect pointer and that the size of the disk blocks is 1KB (not KB8): Consider a file system that uses inodes to represent files. Disk blocks are 1 KB in size, and a pointer to a disk block requires 4 bytes. This file system has 12 direct blocks, as well as single, double, and triple indirect disk blocks. What is the maximum size of a file that can be stored in this file system.

Explanation / Answer

Ans 1:

An application that maintains a database of entries could benefit from such support. For instance, if a program is maintaining a employee database, then accesses to the database cannot be modeled by any predetermined access pattern. The access to records are random and locating the records would be more efficient if the operating system were to provide some form of tree-based index.

First, you should decide just what data you have to store. For example, if you were setting up a mail list database you would need one field each for name, address, city-state, and zipcode. Next decide how many characters will be allowed for each field (25 for name, 30 for address, 25 for city-state, and 5 for zipcode). The total length of an individual record would then be 85 characters.

Next you should consider how you want to access each record of your random access file. You may want to be able to search for a name or sort the file by zip code. A long and tedious way to do this would be to read through each and every record until the desired record is found. If the user knows exactly which record to read then the access time may be reduced significantly. One way to do this would be to create an index file. For example, if you wanted to find a specific record and you know the contents of one of the fields, you could look in the index file to find the matching field and record number. For a mail list database you might set up an index file containing all of the names and the record numbers corresponding to the names. Index files may be sequential or random access (for relation databases) but should contain as few fields as possible to optimize data access time. If the index is sequential it should be kept in memory and updated as the random file is updated.

If indexes are used, some thought must be taken as to updating and changing the index file. If a record is to be deleted, you might want to delete the index, thus removing any reference to the random access file record. This leaves an available record for late addition of a new record (if you keep track of which records have been deleted). If your file isn't expected to change very much you may not mind the wasted space taken up by the deleted record. Ideally, you should keep track of the locations of deleted records so that they can be reused when new records are added. Another way to get rid of the wasted records.

Ans 2:

block size = 1024

number of block numbers in an indirection block
= block size / 4
= 256

number of blocks for file data in that file object

= 16 + 256 + 256^2 + 256^3
Maximum file size:
(direct + single indirect + double indirect + triple indirect) * (blocksize)
= (16 + 1024/4 + (1024/4)^2 + (1024/4)^3) * (1024)
= (16+256+65536+16777216)*1024

=16843024*1024 bytes=16843024KB