home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.21 / text0090.txt < prev    next >
Encoding:
Internet Message Format  |  1990-10-26  |  6.9 KB

  1. From:  swart@src.dec.com (Garret Swart)
  2.  
  3. I believe in putting lots of interesting stuff in the file system name
  4. space but I don't believe that semaphores belong there.  The reason
  5. I don't want to put semaphores in the name space is the same reason
  6. I don't want to put my program variables in the name space:  I want
  7. to have lots of them, I want to create and destroy them very quickly
  8. and I want to operate on them even more quickly.  In other words, the
  9. granularity is wrong.
  10.  
  11. The purpose of a semaphore is to synchronize actions on an object.
  12. What kinds of objects might one want to synchronize?  Generally the
  13. objects are either OS supplied like devices or files, or user defined
  14. data structures.  The typical way of synchronizing files and devices
  15. is to use advisory locks or the "exclusive use" mode on the device.
  16. The more difficult case and the one for which semaphores were invented,
  17. and later added to Unix, is that of synchronizing user data structures.
  18.  
  19. In Unix, user data structures may live either in a process's private
  20. memory or in a shared memory segment.  In both cases there are probably
  21. many different data structures in that memory and many of these data
  22. structures may need to be synchronized.  For maximum concurrency the
  23. programmer may wish to synchronize each data structure with its own
  24. semaphore.  In many applications these data structures may come and
  25. go very quickly and the expense of creating a semaphore to synchronize
  26. the data can be important factor in the performance of the application.
  27.  
  28. It thus seems more natural to allow semaphores to be efficiently
  29. allocated along with the data that they are designed to synchronize.
  30. That is, allow them to be allocated in a process's private address
  31. space or in a mapped shared memory segment.  A shared memory segment
  32. is a much larger grain object, creating, destroying and mapping them
  33. can be much more expensive than creating, destroying or using a
  34. semaphore and these segments are generally important enough to the
  35. application to have sensible names.  Thus putting a shared memory
  36. segment in the name space seems reasonable.  
  37.  
  38. For example, a data base library may use a shared member segment named
  39. /usr/local/lib/dbm/personnel/bufpool to hold the buffer pool for the
  40. personnel department's data base.  The data base library would map
  41. the buffer pool into each client's address space allowing many data
  42. base client programs to efficiently access the data base.  Each page
  43. in the buffer pool and each transaction would have its own set of
  44. semaphores used to synchronize access to the page in the pool or the
  45. state of a transaction.  Giving the buffer pool a name is no problem,
  46. but giving each semaphore a name is much more of a hassle.
  47.  
  48. [Aside:  Another way of structuring such a data base library is as
  49. an RPC style multi-threaded server.  This allows access to the data
  50. base from remote machines and allows easier solutions to the security
  51. and failure problems inherent in the shared memory approach.  However
  52. the shared memory approach has a major performance advantage for systems
  53. that do not support ultra-fast RPCs.  Another approach is to run the
  54. library in an inner mode.  (Unix has one inner mode called the kernel,
  55. VMS has 3, Multics had many.)  This solves the security and failure
  56. problems of the shared segments but it is generally difficult for mere
  57. mortals to write their own inner mode libraries.]
  58.  
  59. One other issue that may cause one to want to unify all objects in
  60. the file system, at least at the level of using file descriptors to
  61. refer to all objects if not going so far as to put all objects in the
  62. name space, is the fact that single threaded programming is much nicer
  63. if there is a single primitive that will wait for ANY event that the
  64. process may be interested in (e.g. the 4.2BSD select call.)  This call
  65. is useful if one is to write a single threaded program that doesn't
  66. busy wait when it has nothing to do but also won't block when an event
  67. of interest has occurred.  With the advent of multi-threaded programming
  68. the single multi-way wait primitive is no longer needed as instead
  69. one can create a separate thread each blocking for an event of interest
  70. and processing it.  Multi-way waiting is a problem if single threaded
  71. programs are going to get maximum use out of the facility.
  72.  
  73. I've spoken to a number of people in 1003.4 about these ideas.  I am
  74. not sure whether it played any part in their decision.
  75.  
  76. Just to prove that I am a pro-name space kind of guy, I am currently
  77. working on and using an experimental file system called Echo that
  78. integrates the Internet Domain name service for access to global names,
  79. our internal higher performance name service for highly available
  80. naming of arbitrary objects, our experimental fault tolerant, log based,
  81. distributed file service with read/write consistency and universal
  82. write back for file storage, and auto-mounting NFS for accessing other
  83. systems.
  84.  
  85. Objects that are named in our name space currently include:
  86.  
  87.    hosts, users, groups, network servers, network services (a fault
  88.    tolerant network service is generally provided by several servers),
  89.    any every version of any source or object file known by our source
  90.    code control system
  91.  
  92. Some of these objects are represented in the name space as a directory
  93. with auxiliary information, mount points or files stored underneath.
  94. This subsumes much of the use of special files like /etc/passwd,
  95. /etc/services and the like in traditional Unix.  Processes are not
  96. currently in the name space, but they will/should be.  (Just a "simple
  97. matter of programming.")
  98.  
  99. For example /-/com/dec/src/user/swart/home/.draft/6.draft is the name
  100. of the file I am currently typing, /-/com/dec/src/user/swart/shell
  101. is a symbolic link to my shell, /-/com/dec/prl/perle/nfs/bin/ls is
  102. the name of the "ls" program on a vanilla Ultrix machine at DEC's Paris
  103. Research Lab..
  104.  
  105. [Yes, I know we are using "/-/" as the name of the super root and not
  106. either "/../" or "//" as POSIX mandates, but those other strings are
  107. so uhhgly and /../ is especially misleading in a system with multiple
  108. levels of super root, e.g. on my machine "cd /; pwd" types
  109. /-/com/dec/src.]
  110.  
  111. Things that we don't put in the name space are objects that are passed
  112. within or between processes by 'handle' rather than by name.  For
  113. example, pipes created with the pipe(2) call, need not be in the name
  114. space.  [At a further extreme, pipes for intra-process communication
  115. don't even involve calling the kernel.]
  116.  
  117. I personally don't believe in overloading file system operations on
  118. objects for which the meaning is tenuous (e.g. "unlink" => "kill -TERM"
  119. on objects of type process); we tend to define new operations for
  120. manipulating objects of a new type.  But that is even more of a
  121. digression than I wanted to get into!
  122.  
  123. Sorry for the length of this message, I seem to have gotten carried
  124. away.
  125.  
  126. Happy trails,
  127.  
  128. Garret Swart
  129. DEC Systems Research Center
  130. 130 Lytton Avenue
  131. Palo Alto, CA 94301
  132. (415) 853-2220
  133. decwrl!swart.UUCP or swart@src.dec.com
  134.  
  135. Volume-Number: Volume 21, Number 91
  136.  
  137.