You can simulate a multilevel directory structure with a single level directory structure and arbitrarily long file names. To do this we will use a special character, say #, as the directory delimiter and we will specify a file as its path followed by the # symbol then the file name. A program then that wanted to use the concept of a current working directory could then just perform this concatenation of the path with the filename when a file is accessed. A file perl in directory /usr/local/bin/ would have a file name of #usr#local#bin#perl
Note that a directory has many other features such as access permissions directory data could be stored in a file that ends with the # symbol if necessary. File protection facilities could be added into the operating system as well, but they could not be enforced if this is to be implemented as a user level library. The directory /usr/local/bin/ would have its directory data in a file called #usr#local#bin#.
If we were to instead limit the file names to seven characters, we could still simulate directories but it is much more complicated. In fact we could simulate the low level inode/block mechanism. Each file in our system would be named with an identifier that could be looked up in another file to get matched with a name. This can be done in exactly the same way that directories are done with inodes in a typical file system.
Specifying file access to 4990 of 5000 users.
First, you could make a group, access, add all 4990 users that you want to have access to this file in this group, and then chmod the file like this:
-rw-rw---- jason access 1266 Mar 4 00:22 sol4.html
The second way you can do this in UNIX is more tricky. User group access is checked before global access is checked so you can create a group, deny, and chmod the file like this:
-rw----rw- jason deny 1266 Mar 4 00:22 sol4.html
Given a file with 100 blocks, how many disk I/O operations do the following procedures require for the various allocation strategies. This solution assumes that in contiguous allocation the length of the file (in blocks) and the pointer to the first block is stored in memory. This assumes that the linked allocation method has a pointer to the first, a pointer to the last block, and the length of the file are stored in memory and each block only has a pointer to the next block and not a pointer to the previous block. It assumes that in indexed allocation the index is completely in memory.
We will also be ignoring the cost of manipulating the free blocks list. However, if we were to take this into account for each add, it would cost the same as a remove from the beginning with linked allocation method (1 operation) and each remove would be the same as the cost of adding to the beginning of the with the linked allocation (1 operation). This is assuming that the free blocks list is actually implemented as a linked list with pointers to the first block in memory.
If any of you run Linux boxes, you know that if the system gets powered down before the disk drives are unmounted, then e2fsck gets run on the disks on boot to correct any inconsistencies.
The system just read blocks 125 and then 143.
The seek order is: 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130.
The total number of cylinder's seeked over is: 7081.
The seek order is: 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774.
The total number of cylinder's seeked over is: 1745.
The seek order is: 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 130, 86.
The total number of cylinder's seeked over is: 9769.
The seek order is: 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86.
The total number of cylinder's seeked over is: 3319.
The seek order is: 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 0, 86, 130.
The total number of cylinder's seeked over is: 9985.
Physics
Note that is close to 1. If we had made the simple approximation
that the (1cyl, 1ms) data point was purely overhead and that the (4999cyl, 18ms)
data point was 1ms overhead and 17ms seek time, we would not have been far
off.
Just for your enlightenment, I came up with my solution to the with the following perl script. Computers are for saving people time. Use them.
#!/usr/bin/perl -n # the -n flag does a 'while (<>) { ... }' around this program chomp; # remove trailing \n @order = split /\s*\,\s*/; # split string on , $prev = 143; $sum = 0; $time = 0; foreach(@order) { $time += 0.76 + 0.24 * sqrt(abs($prev - $_)); $sum += abs($prev - $_); $prev = $_; } print "Sum: $sum\n"; print "Seek Time: $time\n";
I ran this program in input of the following form:
86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 130, 86 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 0, 86, 130
.
This document was generated using the LaTeX2HTML translator Version 96.1-h (September 30, 1996) Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -split 0 -no_navigation sol4.
The translation was initiated by Jason D. Hartline on Wed Mar 4 04:28:50 EST 1998