Work Sheet 10 1.List sample file types? ### Executable, Object, Source code, Batch, Text, Word processor, Library, Print, Archive etc. 2.How can an index file used to speed up the access in direct-access file? ### The index contains pointers to the various blocks. To find an entry in the file, we first search the index, and then use the pointer to access the file directly and find the desired entry. 3.List two types of system directories ### A tree-structured directory that allows a user to create subdirectories to organize his files; A general graph structure that allows complete flexibility in the sharing of files and directories, but sometimes requires garbage collection to recover unused disk space. 4.List ways to share files between directories in operating systems. ### One way is to create a new directory entry called a link. A link is effectively a pointer to another file or subdirectory. The ohter way to implementing shared files is simply to duplicate all information about them in both sharing directories. Thus, both entries are identical and equal. 5.List three ways of allocating storage, and give advantage of each. ### Contiguous allocation is easy to access a file. It supports both swquential and direct access. Simple-only starting location and length are required; In linked allocation, there is no external fragmentation and any free block on the free-space list can be used to satisfy a request. A file can continue to grow as long as there are free blocks. It is never necessary to compact disk space. Indexed allocation supports direct access, without suffering from external fragmentation. 6.Do problems 10.6, 10.9, 10.12, 11.1, 11.4 and 11.6 10.6 ### If arbitrarily long names can be used, it is possible to simulate a multilevel directory structure. This can be done, for example, by using the character "/" in the file name to indicate the end of a subdirectory. If file names are limited to seven characters, the above scheme couldn't be used for arbitrary levels of directories, and in general the answer would be "no". The closest one could come would be to use a specific file as a symbol table, which would map arbitrarily long names (e.g. /usr/os/worksheet10.txt into shorter names eg. xzy9929, which would be used for actual file accesses. 10.9 ### a. Tape file ; b. Disk file. 10.12 ### a. Let these 4990 of 5000 users in a group, and let the file accessible for the group; b. Let the left 10 of 5000 users in a group, and let the file not accessible for the group. 11.1 ### Contiguous Allocation: a. All 100 blocks move one position to the end(Read and Write),and add one block at the begin (Write). Total are 201 IO operations; b. 50 blocks move one position to the end(Read and Write), and add one block at the position 50 (Write). Total are 101 IO operations; c. Add one block at the position 101(Write). Total is 1 IO operation; d. Just modify the information (stating location) in the control block. No IO operation; e. Should move 49 blocks one block distance(Write and Add). Total are 98 IO operations; f. Just modify the information (length) in the control block. No IO operation. Linked Allocation: a. Modify the started address and add one block at the begin(Write). One IO opeartion; b. Seek the position by read 50 blocks (Read), and add one block (Write). 51 IO operations; c. Seek the position by read 100 blocks(Read), and add one block (Read). 101 IO operations; d. Modify the control information. No IO operation; e. Seek the position by read 50 blocks (Read). 50 IO operations; f. Seek the position by read 99 blocks (Read). 99 IO operations. Indexed Allocation: a. Modify the index block and add one block (Write). 1 IO operation; b. Modify the index block and add one block (Write). 1 IO operation; c. Modify the index block and add one block (Write). 1 IO operation; d. Modify the index block. 0 IO operation; e. Modify the index block. 0 IO operation; f. Modify the index block. 0 IO operation. 11.4 ### Keep the bit map in main memory is possible for smaller disks. But not for larger ones. Such as a 1.3G disk with 512-byte blocks would need a bit map of over 310K to track its free blocks. If let it keep in main memory, its cost is very high. So, the bit map must be kept on mass storage. Also storing in main memory means that if there is power failure, the file system may be lost. 11.6 ### a. Contiguous allocation: starting address and displacement; Linked allocation: start at the begining and follow the pointers; Indexed allocation: mapping the address in the index table. b. Contiguous allocation: get the phisical address by the control inforation. Only one IO operation for reading the block 4; Linked allocation: get the block 4 from the begin block one by one. Need 4 IO operation; Indexed allocation: get the block phisical address by the index table. Only one IO operation for reading the block 4.