13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

188 File Structures Chapter 6A flat directory structure has some drawbacks. The entire directory must besearched to find a file. Clever data structures to represent the directory can speed up thissearch. For example, a linear directory can be improved by reordering it after everysearch to place the searched name at the start. The directory can also be represented as abinary search tree or as a hash table. Still, generating a list of files sharing some characteristic(like owner) will require an exhaustive search. Likewise, wild-card searches mustexamine the entire master directory.A flat directory structure is fine for small disks that can only hold a limited numberof files. Personal computers often use flat structures for floppy disks, for example. TheCP/M operating system follows this design.1.2 Two-level directoriesA two-level directory structure is used in the Tops-10 operating system. Every account isgiven a private directory, known as a user file directory. A user who wants to separatevarious projects can use several accounts. Now files have more complex full names: thename of the user file directory followed by the name of the file within that directory. Thelatter part of the file name is called the local name.Account names may be strings of integers, but more commonly, they are strings ofcharacters that describe the user (and perhaps the project). <strong>An</strong> account used by a student,Mary Smith, to prepare her doctoral dissertation might be called smith.thesis.Let’s say that Mary has been writing the simulation program described earlier and hasbuilt files such as runway.mod, plane.mod, and simulate.run. The name forthese files would be/smith.thesis/runway.mod/smith.thesis/plane.mod/smith.thesis/simulate.runand so on. We are using the slash character ( / ) to separate the account name (which weare also using as a directory name) from the file name. Of course, each operating systemwill have its own syntax for this separation.The name used to refer to a file is independent of who is referring to the file. BothMary and her adviser, Professor Helen Troy, use the same names for the same files. Forthis reason, we say that the names we have shown are absolute.However, Mary might prefer a shorter name for her files. The namerunway.mod is certainly easier to type than smith.thesis/runway.mod. Wewould like to assume the first part of the name by default. The rest of the name will beunderstood relative to the assumed first part. To distinguish absolute from relative filenames, we will adopt a convention that absolute names begin with /, whereas relativenames do not. Local names are file names relative to the directory in which the fileresides.To establish the meaning of relative names, a process might tell the file managerwhat the default part of the name should be. We will call this default the working directory.In general, we will provide service calls for all the facilities we would like to makeavailable to the user. As we will see in Chapter 7, these service calls can be used directlyby processes or indirectly by users interacting with processes.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!