Page 237 - DCAP103_Principle of operating system
P. 237

Principles of Operating Systems



                   Notes         This design could be used, for example, on a multi-user computer or on a simple network of
                                 personal computers that shared a common file server over a local area network. Implicit in this
                                 design is that when a user tries to open a file, the operating system knows which user it is in
                                 order to know which directory to search. As a consequence, some kind of login procedure is
                                 needed, in which the user specifies a login name or identification, something not required with
                                 a single-level directory system. When this system is implemented in its most basic form, users
                                 can only access files in their own directories.

                                 6.12.2 Hierarchical Directory Systems
                                 The two-level hierarchy eliminates file name conflicts between users. But another problem is that
                                 users with many files may want to group them in smaller subgroups, for instance a professor
                                 might want to separate handouts for a class from drafts of chapters of a new textbook. What
                                 is needed is a general hierarchy (i.e., a tree of directories). With this approach, each user can
                                 have as many directories as are needed so that files can be grouped together in natural ways.
                                 This approach is shown in Fig. 6.14 (c). Here, the directories A, B, and C contained in the root
                                 directory each belong to a different user, two of whom have created subdirectories for projects
                                 they are working on.

                                 The ability to create an arbitrary number of subdirectories provides a powerful structuring tool
                                 for users to organize their work. For this reason nearly all modern PC and server file systems
                                 are organized this way.
                                 However, as we have pointed out before, history often repeats itself with new technologies.
                                 Digital cameras have to record their images somewhere, usually on a flash memory card. The
                                 very first digital cameras had a single directory and named the files DSC0001.JPG, DSC0002.
                                 JPG, etc. However, it did not take very long for camera manufacturers to build file systems with
                                 multiple directories, as in Fig. 6.14 b). What difference does it make that none of the camera
                                 owners understand how to use multiple directories, and probably could not conceive of any use
                                 for this feature even if they did understand it? It is only (embedded) software, after all, and thus
                                 costs the camera manufacturer next to nothing to provide. Can digital cameras with full-blown
                                 hierarchical file systems, multiple login names, and 255-character file names be far behind?
                                 6.12.3 Path Names
                                 When the file system is organized as a directory tree, some way is needed for specifying file
                                 names. Two different methods are commonly used. In the first method, each file is given an
                                 absolute path name consisting of the path from the root directory to the file. As an example,
                                 the path /usr/ast/mailbox means that the root directory contains a subdirectory usr/, which in
                                 turn contains a subdirectory ast/, which contains the file mailbox. Absolute path names always
                                 start at the root directory and are unique. In UNIX the components of the path are separated
                                 by /. In Windows the separator is \ . Thus the same path name would be written as follows
                                 in these two systems:
                                 Windows        \usr\ast\mailbox
                                 UNIX           /usr/ast/mailbox
                                 No matter which character is used, if the first character of the path name is the separator, then
                                 the path is absolute.
                                 The other kind of name is the relative path name. This is used in conjunction with the concept of
                                 the working directory (also called the current directory). A user can designate one directory as
                                 the current working directory, in which case all path names not beginning at the root directory
                                 are taken relative to the working directory. For example, if the current working directory is /
                                 usr/ast,  then  the  file  whose  absolute  path  is  /usr/ast/mailbox  can  be  referenced  simply  as
                                 mailbox. In other words, the UNIX command cp /usr/ast/mailbox /usr/ast/mailbox.bak nand



        230                               LOVELY PROFESSIONAL UNIVERSITY
   232   233   234   235   236   237   238   239   240   241   242