home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / v21 / 091 < prev    next >
Internet Message Format  |  1990-12-05  |  8KB

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