gnu_bulletin_9401_12.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <TITLE> - Towards a New Strategy of OS Design</TITLE>
  2. <P>Go to the <A HREF="gnu_bulletin_9401_11.html">previous</A>, <A HREF="gnu_bulletin_9401_13.html">next</A> chapter.<P>
  3. <H1><A NAME="SEC12" HREF="gnu_bulletin_9401_toc.html#SEC12">Towards a New Strategy of OS Design</A></H1>
  4. <P>
  5. This article explains why FSF is developing a new operating system
  6. named the Hurd, which will be a foundation of the whole GNU system.
  7. The Hurd is built on top of CMU's Mach 3.0 kernel and uses Mach's
  8. virtual memory management and message-passing facilities.
  9. The GNU C Library will provide the Unix system call interface, and will
  10. call the Hurd for needed services it can't provide itself.
  11. The design and implementation of the Hurd is being lead by Michael
  12. Bushnell, with assistance from Richard Stallman, Roland McGrath, Jan
  13. Brittenson, and others.
  14. <P>
  15. <H3><A NAME="SEC13" HREF="gnu_bulletin_9401_toc.html#SEC13">Part 1: A More Usable Approach to OS Design</A></H3>
  16. <P>
  17. The fundamental purpose of an operating system (OS) is to enable a variety of
  18. programs to share a single computer efficiently and productively. This
  19. demands memory protection, preemptively scheduled timesharing,
  20. coordinated access to I/O peripherals, and other services. In addition,
  21. an OS can allow several users to share a computer. In
  22. this case, efficiency demands services that protect users from harming
  23. each other, enable them to share without prior arrangement, and mediate
  24. access to physical devices.
  25. <P>
  26. On today's computer systems, programmers usually implement these goals
  27. through a large program called the kernel. Since this program must be
  28. accessible to all user programs, it is the natural place to add
  29. functionality to the system. Since the only model for process
  30. interaction is that of specific, individual services provided by the
  31. kernel, no one creates other places to add functionality. As time goes
  32. by, more and more is added to the kernel.
  33. <P>
  34. A traditional system allows users to add components to a kernel only if
  35. they both understand most of it and have a privileged status within the
  36. system. Testing new components requires a much more painful
  37. edit-compile-debug cycle than testing other programs. It cannot be done
  38. while others are using the system. Bugs usually cause fatal system
  39. crashes, further disrupting others' use of the system. The entire
  40. kernel is usually non-pageable. (There are systems with pageable
  41. kernels, but deciding what can be paged is difficult and error prone.
  42. Usually the mechanisms are complex, making them difficult to use even
  43. when adding simple extensions.)
  44. <P>
  45. Because of these restrictions, functionality which properly belongs
  46. <EM>behind</EM> the wall of a traditional kernel is usually left out of
  47. systems unless it is absolutely mandatory. Many good ideas, best
  48. done with an open/read/write interface cannot be implemented
  49. because of the problems inherent in the monolithic nature of a
  50. traditional system. Further, even among those with the endurance to
  51. implement new ideas, only those who are privileged users of their
  52. computers can do so. The software copyright system darkens the mire by
  53. preventing unlicensed people from even reading the kernel source.
  54. <P>
  55. Some systems have tried to address these difficulties. Smalltalk-80
  56. and the Lisp Machine both represented one method of getting around the
  57. problem. System code is not distinguished from user code; all of the
  58. system is accessible to the user and can be changed as need be. Both
  59. systems were built around languages that facilitated such easy
  60. replacement and extension, and were moderately successful. But they
  61. both were fairly poor at insulating users and programs from each other,
  62. failing one of the principal goals of OS design.
  63. <P>
  64. Most projects that use the Mach 3.0 kernel carry on the
  65. hard-to-change tradition of OS design. The internal
  66. structure is different, but the same heavy barrier between user and
  67. system remains. The single-servers, while fairly easy to construct,
  68. inherit all the deficiencies of the monolithic kernels.
  69. <P>
  70. A multi-server divides the kernel functionality up into logical
  71. blocks with well-defined interfaces. Properly done, it is easier to
  72. make changes and add functionality. So most multi-server projects do
  73. somewhat better. Much more of the system is pageable. You can debug
  74. the system more easily. You can test new system components without
  75. interfering with other users. But the wall between user and system
  76. remains; no user can cross it without special privilege.
  77. <P>
  78. The GNU Hurd, by contrast, is designed to make the area of <EM>system</EM>
  79. code as limited as possible. Programs are required to communicate only
  80. with a few essential parts of the kernel; the rest of the system is
  81. replaceable dynamically. Users can use whatever parts of the remainder
  82. of the system they want, and can easily add components themselves for
  83. other users to take advantage of. No mutual trust need exist in advance
  84. for users to use each other's services, nor does the system become
  85. vulnerable by trusting the services of arbitrary users.
  86. <P>
  87. This has been done by identifying those system components which
  88. users <EM>must</EM> use in order to communicate with each other. One of these is
  89. responsible for identifying users' identities and is called the
  90. <EM>authentication server</EM>. In order to establish each other's identities,
  91. programs must communicate, each with an authentication server they
  92. trust. Another component establishes control over system components by
  93. the superuser, provides global bookkeeping operations, and is called
  94. the <EM>process server</EM>.
  95. <P>
  96. Not all user programs
  97. need to communicate with the process server; it is only necessary for
  98. programs which require its services. Likewise, the authentication
  99. server is only necessary for programs that wish to communicate their
  100. identity to another. None of the remaining services carry any special
  101. status; not the network implementation, the filesystems, the program
  102. execution mechanism (including setuid), or any others.
  103. <P>
  104. <H4><A NAME="SEC14" HREF="gnu_bulletin_9401_toc.html#SEC14">The Translator Mechanism</A></H4>
  105. <P>
  106. The Hurd uses Mach ports primarily as methods for communicating between
  107. users and servers. (A Mach port is a communication point on a Mach task
  108. where messages are sent and received.) Each port implements a
  109. particular set of protocols, representing operations that can be
  110. undertaken on the underlying object represented by the port. Some of
  111. the protocols specified by the Hurd are the I/O protocol, used for
  112. generic I/O operations; the file protocol, used for filesystem
  113. operations; the socket protocol, used for network operations; and the
  114. process protocol, used for manipulating processes et al.
  115. <P>
  116. Most servers are accessed by opening files. Normally, when you open a file,
  117. you create a
  118. a port associated with that file that is owned by the server that owns
  119. the directory containing the file. For example, a disk-based
  120. filesystem will normally serve a large number of ports, each of which
  121. represents an open file or directory. When a file is opened, the
  122. server creates a new port, associates it with the file, and returns the
  123. port to the calling program.
  124. <P>
  125. However, a file can have a <EM>translator</EM> associated with it. In
  126. this case, rather than return its own port which refers to the contents
  127. of the file, the server executes a translator program associated with
  128. that file. This translator is given a port to the actual contents of
  129. the file, and is then asked to return a port to the original user to
  130. complete the open operation.
  131. <P>
  132. This mechanism is used for <CODE>mount</CODE> by having a translator
  133. associated with each mount point. When a program opens the mount
  134. point, the translator (in this case, a program which understands the
  135. disk format of the mounted filesystem) is executed and returns a port to
  136. the program. After the translator is started, it need not be run again
  137. unless it dies; the parent filesystem retains a port to the translator
  138. to use in further requests.
  139. <P>
  140. The owner of a file can associate a translator with it
  141. without special permission. This means that any program can be
  142. specified as a translator. Obviously the system will not work
  143. properly if the translator does not implement the file protocol
  144. correctly. However, the Hurd is constructed so that the worst
  145. possible consequence is an interruptible hang.
  146. <P>
  147. One way to use translators is to access hierarchically structured data
  148. using the file protocol. For example, all the complexity of the user
  149. interface to the <CODE>ftp</CODE> program is removed. Users need only know
  150. that a particular directory represents FTP and can use all the standard
  151. file manipulation commands (e.g <CODE>ls</CODE> or <CODE>cp</CODE>) to access the
  152. remote system, rather than learning a new set. Similarly, a simple
  153. translator could ease the complexity of <CODE>tar</CODE> or <CODE>gzip</CODE>.
  154. (Such transparent access would have some added cost, but it would be
  155. convenient.)
  156. <P>
  157. <H4><A NAME="SEC15" HREF="gnu_bulletin_9401_toc.html#SEC15">Generic Services</A></H4>
  158. <P>
  159. With translators, the filesystem can act as a
  160. rendezvous for interfaces which are not similar to files. Consider a
  161. service which implements some version of the X protocol, using Mach
  162. messages as an underlying transport. For each X display, a file can
  163. be created with the appropriate program as its translator. X clients
  164. would open that file. At that point, few file operations would be useful
  165. (read and write, for example, would be useless), but new operations
  166. (<CODE>XCreateWindow</CODE> or <CODE>XDrawText</CODE>) might become meaningful. In this
  167. case, the filesystem protocol is used only to manipulate
  168. characteristics of the node used for the rendezvous. The node need
  169. not support I/O operations, though it should reply to any such
  170. messages with a <CODE>message_not_understood</CODE> return code.
  171. <P>
  172. This translator technique is used to contact most of the services in the Hurd
  173. that are not structured like hierarchical filesystems. For example,
  174. the password server, which hands out authorization tags in exchange
  175. for passwords, is contacted this way. Network protocol servers
  176. are also contacted in this fashion. Roland McGrath thought up this
  177. use of translators.
  178. <P>
  179. <H4><A NAME="SEC16" HREF="gnu_bulletin_9401_toc.html#SEC16">Clever Filesystem Pictures</A></H4>
  180. <P>
  181. In the Hurd, translators can also be used to present a filesystem-like
  182. view of another part of the filesystem, with some semantics changed.
  183. For example, it would be nice to have a filesystem that cannot itself be
  184. changed, but nonetheless records changed versions of its files
  185. elsewhere. (This could be useful for source code management.)
  186. <P>
  187. The Hurd will have a translator which creates a directory which is a
  188. conceptual union of other directories, with collision resolution rules
  189. of various sorts. This can be used to present a single directory to
  190. users that contains all the programs they would want to execute. There
  191. are other useful variations on this theme.
  192. <P>
  193. <H4><A NAME="SEC17" HREF="gnu_bulletin_9401_toc.html#SEC17">What The User Can Do</A></H4>
  194. <P>
  195. No translator gains extra privilege by virtue of being hooked into the
  196. filesystem. Translators run with the uid of the owner of the file being
  197. translated, and can only be set or changed by that owner.
  198. The I/O and
  199. filesystem protocols are carefully designed to allow their use by
  200. mutually untrusting clients and servers. Indeed, translators are just
  201. ordinary programs. The GNU C library has a variety of facilities to
  202. make common sorts of translators easier to write.
  203. <P>
  204. Some translators may need special privileges,
  205. such as the password server or translators which allow setuid execution.
  206. These translators could be run by anyone, but
  207. only if they are set on a root-owned node would they be able
  208. to provide all their services successfully. This is analogous to
  209. letting any user call the <CODE>reboot</CODE> system call, but only honoring it if
  210. that user is root.
  211. <P>
  212. <H4><A NAME="SEC18" HREF="gnu_bulletin_9401_toc.html#SEC18">Why This Is So Different</A></H4>
  213. <P>
  214. What this design provides is completely novel to the
  215. Unix world. Until now, OSs have kept huge
  216. portions of their functionality in the realm of system code, thus
  217. preventing its modification and extension except in extreme
  218. need. Users cannot replace parts of the system in their
  219. programs no matter how much easier that would make their task, and
  220. system managers are loath to install random tweaks off the net into
  221. their kernels.
  222. <P>
  223. In the Hurd, users can change almost all of the things that are
  224. decided for them in advance by traditional systems. In combination
  225. with the tremendous control given by the Mach kernel over task address
  226. spaces and properties, the Hurd provides a system in which
  227. users will, for the first time, be able to replace parts of the system
  228. they dislike,
  229. without disrupting other users.
  230. <P>
  231. Most Mach-based OSs to date have mostly implemented a wider set of the
  232. <EM>same old</EM> Unix semantics in a new environment. In contrast, GNU is
  233. extending those semantics to allow users to improve, bypass,
  234. or replace them.
  235. <P>
  236. <H3><A NAME="SEC19" HREF="gnu_bulletin_9401_toc.html#SEC19">Part 2: A Look at Some of the Hurd's Beasts</A></H3>
  237. <P>
  238. <H4><A NAME="SEC20" HREF="gnu_bulletin_9401_toc.html#SEC20">The Authentication Server</A></H4>
  239. <P>
  240. One of the Hurd's more central servers is the authentication
  241. server. Each port to this server identifies a user and
  242. is associated by this server with an <EM>id block</EM>. Each
  243. id block contains sets of user and group ids. Either
  244. set may be empty. This server is not the same as the password
  245. server referred to above.
  246. <P>
  247. The authentication server exports three services. First, it provides
  248. simple boolean operations on authentication ports: given two
  249. authentication ports, this server will provide a third
  250. port representing the union of the two sets of uids and gids.
  251. Second, this server allows any user with a uid of zero
  252. to create an arbitrary authentication port.
  253. Finally, this server provides RPCs (Remote Procedure Calls
  254. between different programs and possibly different hosts) which allow mutually
  255. untrusting clients and servers to establish their identities and pass initial
  256. information on each other. This is crucial to the security of the
  257. filesystem and I/O protocols.
  258. <P>
  259. Any user could write a program which implements the authentication
  260. protocol; this does not violate the system's security.
  261. When a service needs to authenticate a user, it communicates
  262. with its trusted authentication server. If that user is using a
  263. different authentication server, the transaction will fail and the
  264. server can refuse to communicate further. Because, in effect, this
  265. forces all programs on the system to use the same authentication
  266. server, we have designed its interface to make any safe operation
  267. possible, and to include no extraneous operations. (This is why
  268. there is a separate password server.)
  269. <P>
  270. <H4><A NAME="SEC21" HREF="gnu_bulletin_9401_toc.html#SEC21">The Process Server</A></H4>
  271. <P>
  272. The process server acts as an information
  273. categorization repository. There are four main services supported by
  274. this server. First, the process server keeps track of generic
  275. host-level
  276. information not handled by the Mach kernel. For example, the hostname,
  277. the hostid,
  278. and the system version are maintained by the process server.
  279. Second, this server maintains the Posix notions of sessions and
  280. process groups, to help out programs that wish to use
  281. Posix features.
  282. <P>
  283. Third, the process server maintains a one-to-one mapping between Mach
  284. tasks and Hurd processes. Every task is assigned a pid. Processes can
  285. register a message port with this server, which can then be given out to
  286. any program which requests it. This server makes no attempt to keep
  287. these message ports private, so user programs are expected to implement
  288. whatever security they need themselves. (The GNU C Library provides
  289. convenient functions for all this.) Processes can tell the process
  290. server their current <CODE>argv</CODE> and <CODE>envp</CODE> values; this server
  291. will then provide, on request, these vectors of arguments and
  292. environment. This is useful for writing <CODE>ps</CODE>-like programs and
  293. also makes it easier to hide or change this information. None of these
  294. features are mandatory. Programs are free to disregard all of this and
  295. never register themselves with the process server at all. They will,
  296. however, still have a pid assigned.
  297. <P>
  298. Finally, the process server implements <EM>process collections</EM>, which
  299. are used to collect a number of process message ports at the same time.
  300. Also, facilities are provided for converting between pids, process
  301. server ports, and Mach task ports, while ensuring the security of the
  302. ports managed.
  303. <P>
  304. It is important to stress that the process server is optional. Because
  305. of restrictions in Mach,
  306. programs must run as root in order to identify
  307. all the tasks in the system. But given that, multiple process servers
  308. could co-exist, each with their own clients, giving their own model of
  309. the universe. Those process server features which do not require root
  310. privileges to be implemented could be done as per-user servers. The
  311. user's hands are not tied.
  312. <P>
  313. <H4><A NAME="SEC22" HREF="gnu_bulletin_9401_toc.html#SEC22">Transparent FTP</A></H4>
  314. <P>
  315. Transparent FTP is an intriguing idea whose time has come. The popular
  316. <CODE>ange-ftp</CODE> package available for GNU Emacs makes access to FTP
  317. files virtually transparent to all the Emacs file manipulation
  318. functions. Transparent FTP does the same thing, but in a system wide
  319. fashion. This server is not yet written; the details remain to be
  320. fleshed out, and will doubtless change with experience.
  321. <P>
  322. In a BSD kernel, a transparent FTP filesystem would be no harder to
  323. write than in the Hurd. But mention the idea to a BSD kernel hacker,
  324. and the response is that "such a thing doesn't belong in the kernel".
  325. In a sense, this is correct. It violates all the layering principles of
  326. such systems to place such things in the kernel. The unfortunate side
  327. effect, however, is that the design methodology (which is based on
  328. preventing users from changing things they don't like) is being used to
  329. prevent system designers from making things better. (Recent BSD kernels
  330. make it possible to write a user program that provides transparent FTP.
  331. An example is <CODE>alex</CODE>, but it needs to run with full root
  332. privileges.)
  333. <P>
  334. In the Hurd, there are no obstacles to doing transparent FTP. A
  335. translator will be provided for the node <TT>`/ftp'</TT>. The contents of
  336. <TT>`/ftp'</TT> will probably not be directly listable, though further
  337. subdirectories will be. There will be a variety of possible formats.
  338. For example, to access files on uunet, one could <CODE>cd
  339. /ftp/ftp.uu.net:anonymous:mib@gnu</CODE>. Or to access files on a remote
  340. account, one might <CODE>cd /ftp/gnu.ai.mit.edu:mib:passwd</CODE>. Parts
  341. of this command could be left out and the transparent FTP program would
  342. read them from a user's <TT>`.netrc'</TT> file. In the last case, one might
  343. just <CODE>cd /ftp/gnu.ai.mit.edu</CODE>; when the rest of the data is
  344. already in <TT>`.netrc'</TT>.
  345. <P>
  346. There is no need to do a <CODE>cd</CODE> first--use any file command. To
  347. find out about RFC 1097 (the Telnet Subliminal Message Option), just
  348. type <CODE>more /ftp/ftp.uu.net/inet/rfc/rfc1097</CODE>. A copy command
  349. to a local disk could be used if the RFC would be read frequently.
  350. <P>
  351. <H4><A NAME="SEC23" HREF="gnu_bulletin_9401_toc.html#SEC23">Filesystems</A></H4>
  352. <P>
  353. Ordinary filesystems are also being implemented. The initial release of
  354. the Hurd will contain a filesystem upwardly compatible with the BSD 4.4
  355. Fast File System. In addition to the ordinary semantics, it will
  356. provide means to record translators, offer thirty-two bit user ids and
  357. group ids, and supply a new id per file, called the <EM>author</EM> of the
  358. file, which can be set by the owner arbitrarily. In addition, because
  359. users in the Hurd can have multiple uids (or even none), there is an
  360. additional set of permission bits providing access control for <EM>unknown
  361. user</EM> (no uids) as distinct from <EM>known but arbitrary user</EM> (some
  362. uids: the existing <EM>world</EM> category of file permissions).
  363. <P>
  364. The Network File System protocol will be implemented using 4.4 BSD as a
  365. starting point. A log-structured filesystem will also be implemented
  366. using the same ideas as in Sprite, but probably not the same format.
  367. A GNU network file protocol may be designed in time, or NFS may be
  368. extended to remove its deficiencies. There will also be various
  369. "little" filesystems, such as the MS-DOS filesystem, to help people
  370. move files between GNU and other OSs.
  371. <P>
  372. <H4><A NAME="SEC24" HREF="gnu_bulletin_9401_toc.html#SEC24">Terminals</A></H4>
  373. <P>
  374. An I/O server will provide the terminal semantics of
  375. Posix. The GNU C Library has features for keeping track of the
  376. controlling terminal and for arranging to have proper job control
  377. signals sent at the proper times, as well as features for obeying keyboard and
  378. hangup signals.
  379. <P>
  380. Programs will be able to insert a terminal driver into communications
  381. channels in a variety of ways. Servers like <CODE>rlogind</CODE> will be able
  382. to insert the terminal protocol onto their network communication port.
  383. Pseudo-terminals will not be necessary,
  384. though they will be provided for backward compatibility with older
  385. programs. No programs in GNU will depend on them.
  386. <P>
  387. Nothing about a terminal driver is forced upon users. A terminal
  388. driver allows a user to get at the underlying communications channel
  389. easily, to bypass itself on an as-needed
  390. basis or altogether, or to substitute a different terminal
  391. driver-like program. In the last case, provided the alternate
  392. program implements the necessary interfaces, it will be used by the C
  393. Library exactly as if it were the ordinary terminal driver.
  394. <P>
  395. Because of this flexibility, the original terminal driver will not
  396. provide complex line editing features, restricting itself to the
  397. behavior found in Posix and BSD. In time, there will be a
  398. <CODE>readline</CODE>-based terminal driver, which will provide
  399. complex line-editing
  400. features for those users who want them.
  401. <P>
  402. The terminal driver will probably not provide good support for the
  403. high-volume, rapid data transmission required by UUCP or SLIP. Those
  404. programs do not need any of its features. Instead they will be use the
  405. underlying Mach device ports for terminals, which support moving large
  406. amounts of data efficiently.
  407. <P>
  408. <H4><A NAME="SEC25" HREF="gnu_bulletin_9401_toc.html#SEC25">Executing Programs</A></H4>
  409. <P>
  410. The implementation of the <CODE>execve</CODE> call is spread across
  411. three programs. The library marshals the argument and
  412. environment vectors. It then sends a message to the file server that
  413. holds the file to be executed. The file server checks execute
  414. permissions and makes whatever changes it desires in the exec call. For
  415. example, if the file is marked setuid and the fileserver has the
  416. ability, it will change the user identification of the new
  417. image. The file server also decides if programs which
  418. had access to the old task should continue to have access to the new
  419. task. If the file server is augmenting permissions, or executing an
  420. unreadable image, then the exec needs to take place in a
  421. new Mach task to maintain security.
  422. <P>
  423. After deciding the policy associated with the new image, the filesystem
  424. calls the exec server to load the task. This server, using the
  425. BFD (Binary File Descriptor) library, loads the image. BFD supports a
  426. large number of object file formats; almost any supported format will
  427. be executable. This server also handles scripts starting with
  428. <CODE>#!</CODE>, running them through the indicated program.
  429. <P>
  430. The standard exec server also looks at the environment of the new image;
  431. if it contains a variable <CODE>EXECSERVERS</CODE> then it uses the programs
  432. specified there as exec servers instead of the system default. (This
  433. is, of course, not done for execs that the file server has requested be
  434. kept secure.)
  435. <P>
  436. The new image starts running in the GNU C Library, which sends a message to
  437. the exec server to get the arguments, environment, umask, current
  438. directory, etc. None of this additional state is special to the file or
  439. exec servers; if programs wish, they can use it in a different manner
  440. than the Library.
  441. <P>
  442. <H4><A NAME="SEC26" HREF="gnu_bulletin_9401_toc.html#SEC26">New Processes</A></H4>
  443. <P>
  444. The <CODE>fork</CODE> call is implemented almost entirely in the GNU C Library. The
  445. new task is created by Mach kernel calls. The C Library arranges to
  446. have its image inherited properly. The new task is registered with
  447. the process server (though this is not mandatory). The C Library
  448. provides vectors of functions to be called at fork time: one vector to
  449. be called before the fork, one after in the parent, and one after in
  450. the child. (These features should not be used to replace the normal
  451. fork-calling sequence; it is intended for libraries which need to close ports
  452. or clean up before a fork occurs.) The C library will
  453. implement both fork calls specified by the draft Posix.4a (the proposed
  454. standard dealing with the threads
  455. extension to the real-time extension).
  456. <P>
  457. Nothing forces the user to create new tasks this way. If a program
  458. wants to use almost the normal fork, but with some special
  459. characteristics, then it can do so. Hooks will be provided by the C
  460. Library, or the function can even be completely replaced.
  461. None of this is possible in a traditional Unix system.
  462. <P>
  463. <H4><A NAME="SEC27" HREF="gnu_bulletin_9401_toc.html#SEC27">Asynchronous Messages</A></H4>
  464. <P>
  465. As mentioned above, the process server maintains a "message port" for
  466. each task registered with it. These ports are public, and are used to
  467. send asynchronous messages to the task. Signals, for example, are
  468. sent to the message port. The signal message also provides a port as
  469. an indication that the sender should be trusted to send the signal.
  470. The GNU C Library lists a variety of ports in a table, each of which
  471. identifies a set of signals that can be sent by anyone who possesses
  472. that port. For example, if the user possesses the task's kernel port,
  473. it is allowed to send any signal. If the user possesses a special
  474. "terminal id" port, it is allowed to send the keyboard and hangup
  475. signals. Users can add arbitrary new entries into the C library's
  476. signal permissions table.
  477. <P>
  478. When a process's process group changes, the process server will send
  479. it a message indicating the new process group. In this case, the
  480. process server proves its authority by providing the task's kernel
  481. port.
  482. <P>
  483. The C library also has messages to add and delete uids currently used by
  484. the process. If new uids are sent to the program, the library adds them
  485. to its current set, and then exchanges messages with all the I/O servers
  486. it knows about, proving to them its new authorization. Similarly, a
  487. message can delete uids. In the latter case, the caller must provide
  488. the process's task port. (You can't harm a process by giving it extra
  489. permission, but you can harm it by taking permission away.) The Hurd
  490. will provide user programs to send these messages to processes. For
  491. example, the <CODE>su</CODE> command will be able to cause all the programs in
  492. your current login session, to gain a new uid, rather than spawn a
  493. subshell.
  494. <P>
  495. The C library will allow programs to add asynchronous messages they wish
  496. to recognize, as well as prevent recognition of the standard set.
  497. <P>
  498. <H4><A NAME="SEC28" HREF="gnu_bulletin_9401_toc.html#SEC28">Making It Look Like Unix</A></H4>
  499. <P>
  500. The C Library will implement all of the calls from BSD and Posix as well
  501. as some obvious extensions to them. This enables users to replace
  502. those calls they dislike or bypass them entirely, whereas in Unix
  503. the calls must be used "as they come" with no alternatives possible.
  504. <P>
  505. In some environments binary compatibility will also be supported.
  506. This works by building a special version of the library which is then
  507. loaded somewhere in the address space of the process. (For example, on
  508. a VAX, it would be tucked in above the stack.) A feature of Mach,
  509. called system call redirection, is then used to trap Unix system calls
  510. and turn them into jumps into this special version of the library.
  511. (On almost all machines, the cost of such a redirection is very small;
  512. this is a highly optimized path in Mach. On a 386 it's about two
  513. dozen instructions. This is little worse than a simple
  514. procedure call.)
  515. <P>
  516. Many features of Unix, such as signal masks and vectors, are handled
  517. completely by the library. This makes such features significantly
  518. cheaper than in Unix. It is now reasonable to use <CODE>sigblock</CODE> extensively
  519. to protect critical sections, rather than seeking out some other, less
  520. expensive method.
  521. <P>
  522. <H4><A NAME="SEC29" HREF="gnu_bulletin_9401_toc.html#SEC29">Network Protocols</A></H4>
  523. <P>
  524. The Hurd will have a library that will make it very easy to port 4.4 BSD
  525. protocol stacks into the Hurd. This will enable operation, virtually
  526. for free, of all the protocols supported by BSD. Currently, this
  527. includes the CCITT protocols, the TCP/IP protocols, the Xerox NS
  528. protocols, and the ISO protocols.
  529. <P>
  530. For optimal performance some work would be necessary to take advantage
  531. of Hurd features that provide for very high speed I/O. For most
  532. protocols this will require some thought, but not too much time. The
  533. Hurd will run the TCP/IP protocols as efficiently as possible.
  534. <P>
  535. As an interesting example of the flexibility of the Hurd design,
  536. consider the case of IP trailers, used extensively in BSD for
  537. performance. While the Hurd will be willing to send and receive
  538. trailers, it will gain fairly little advantage in doing so because
  539. there is no requirement that data be copied and avoiding copies
  540. for page-aligned data is irrelevant.
  541. <P>
  542. <P>Go to the <A HREF="gnu_bulletin_9401_11.html">previous</A>, <A HREF="gnu_bulletin_9401_13.html">next</A> chapter.<P>