wegrzyn.kernel 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. Received: from UCB-VAX.ARPA by MIT-MC.ARPA; MON 4 MAR 1985 2321 EST
  2. Received: by UCB-VAX.ARPA (4.24/4.42)
  3. id AA15228; Mon, 4 Mar 85 20:15:57 pst
  4. Return-Path: <decvax!encore!wegrzyn>
  5. Received: by decvax.UUCP (4.12/1.0)
  6. id AA02212; Mon, 4 Mar 85 12:25:14 est
  7. Received: by encore.UUCP (4.12/4.7)
  8. id AA02746; Mon, 4 Mar 85 11:47:22 est
  9. Date: Mon, 4 Mar 85 11:47:22 est
  10. From: decvax!encore!wegrzyn@Berkeley (Chuck Wegrzyn)
  11. Message-Id: <8503041647.AA02746@encore.UUCP>
  12. To: RMS@MIT-MC.ARPA
  13. Subject: Re: o.s overview
  14. Richard,
  15. Here is the overview document for the operating
  16. system I have built, and am building. It is rather sketchy
  17. since the bulk of the document is in hand written form. Tell
  18. me if it looks okay for the heart of GNU. I'll call you up
  19. in a few days.
  20. 1. Overview
  21. -----------
  22. The operating system is broken down into a number of components,
  23. some of which are separated processes, and others are imbedded
  24. in the kernel. The operating system is logically broken down into
  25. the following components :
  26. directory server maps 'file' names into directory
  27. entries (aka information
  28. entries);
  29. file server a repository of data collected into
  30. blocks on a disk (or disk-
  31. like device);
  32. kernel manager a program that controls the allocation
  33. of resources;
  34. process manager a program that schedules user
  35. processes;
  36. memory manager a program that provides the memory
  37. management features of the
  38. system;
  39. kernel a small, monolithic piece of code
  40. that controls i/o, provides
  41. lower level hardware support,
  42. and provides the send and
  43. receive message operations;
  44. init server a small program the initializes the
  45. system and handles major
  46. catastrophies;
  47. login manager a small program that allows users
  48. access to the system;
  49. network manager a program that provides the
  50. interface between the system
  51. and network services.
  52. A process is a separately scheduled piece of code that has it's
  53. own address space and machine state. A process that runs inside
  54. the address space of the kernel is called a 'manager'; one that
  55. runs outside is called a 'server'.
  56. 2. The Kernel
  57. -------------
  58. The kernel, written in a machine protable manner, is the only
  59. (hopeful) piece of code that needs to be modified when the
  60. system is ported from one machine to another. Further, since
  61. it is monolithic, i.e. runs with interrupts disabled, it should
  62. be easy to maintain.
  63. The kernel supports the following features,
  64. o multiple processors in a tightly coupled environment,
  65. o message passing : the basic means of communication and
  66. synchronization in the system,
  67. o interrupt handling and forwarding,
  68. o support for i/o,
  69. o low level scheduling and processor management.
  70. In the support of processes and scheduling, the kernel uses the
  71. following algorithm to determine the next process to run :
  72. Since the kernel can run on any machine, it will first
  73. lock the microscheduler queue. Once access is gained
  74. to this queue, the kernel looks for any manager ready
  75. to run; there will always be at least one manager ready
  76. to run : the process manager. After finding the manager
  77. ready to run, it marks it as running and release access
  78. to the microscheduler queue. The only exception to the
  79. "marking of the running manager" is the process manager.
  80. This single manager can have multiple instances of itself
  81. running : one on each processor. (Further information is
  82. presented below). Once the manager has been selected the
  83. kernel will load up the machine state and start execution
  84. of it. The system is fully capable of providing time
  85. slice interrupts, priority preemption, etc.
  86. To support the need for communication between processes, the kernel
  87. provides the concept of a message queue and message packets. A
  88. 'message queue' is a channel for the transmission of 'message
  89. packets'. A message packet contains raw, uninterpreted data, and
  90. references to other message queues. These message queue references
  91. allow processes to send, and receive information on other message
  92. queues. The fact that message queue references can be communicated
  93. between processes allows a simple means of resource passing:
  94. Each resource in the system, such as an open file, can
  95. be represented by a message queue reference. Any message
  96. sent on the message queue will implicitly refer to a
  97. particular file (only if the file server interprets it
  98. that way), and any message received on the message queue
  99. could refer to a specific file. This notion, though
  100. very simple allows powerful servers to be built.
  101. The kernel also supports interrupt handling and i/o control in
  102. two manners. It can support the traditional view : i/o can only
  103. be handled by a 'privileged' piece of code. The kernel can also
  104. provide a second style : managers that support i/o. Since managers
  105. run inside the kernel and are as privileged as the kernel, i/o
  106. services and interrupt handling can be provided in a very clean
  107. and simple scheme :
  108. i/o drivers and interrupt handlers are independently
  109. scheduled processes that run inside the kernel, i.e.
  110. they are managers.
  111. This allows the configuration of the system to be changed rather
  112. easily : by a simple edit of a 'configuration file' and a reboot
  113. of the system. It is also possible to provide a completely dynamic
  114. environment : managers could be dynamically created and destroyed,
  115. though on the first pass this isn't being supported.
  116. There are three interfaces to the kernel :
  117. o the server level interface,
  118. o the manager level interface, and
  119. o the hardware level interface.
  120. The server level interface is very simple, only two system calls
  121. are directly supported :
  122. SendMsg(msgptr,msgsize,fullqueuetimeout)
  123. char *msgptr;
  124. unsigned int msgsize,
  125. fullqueuetimeout;
  126. and
  127. RcvMsg(msgptr,emptyqueuetimeout)
  128. char *msgptr;
  129. unsigned int emptyqueuetimeout;
  130. The first call will take a message, pointed to by msgptr and whose
  131. size is msgsize, and transmit it to a specific message queue. If the
  132. message queue is full, the process will wait for fullqueuetimeout
  133. ticks. The second call will wait for a message and place it in
  134. the callers address space. If no message is immediately available
  135. the process will wait for at least emptyqueuetimeout ticks.
  136. The second interface to the kernel is similar to the server inter-
  137. face with a few exceptions. Unlike the server interface, the
  138. manager interface assumes that messages are part of the kernel
  139. address space. The manager interface also supports a few more
  140. requests. The calls for message handling are
  141. XmitMsg(msgptr,msgsize)
  142. char *msgptr;
  143. unsigned int msgsize;
  144. and
  145. GetMsg(msgptr)
  146. char *msgptr;
  147. There is no need for timeout support since all manager requests
  148. bypass the full queue check logic. The calls to support interrupt
  149. handling are
  150. WaitforInt(intlev,timeout)
  151. unsigned int intlev,
  152. timeout;
  153. and
  154. SimulateInt(intlev)
  155. unsigned int intlev;
  156. The first call forces a manager to wait for an I/O interrupt from
  157. level, intlev. The second call simulates (forces) an interrupt to
  158. occur. The timeout value on the first call is the amount of time
  159. to wait for the interrupt to 'naturally' occur before waking the
  160. manager with a SimulateInt call. The time is in clock ticks.
  161. Also supported at this level are synchronization locks. The locks
  162. are spinlocks. The calls for these services are
  163. Lock(lockid)
  164. unsigned int lockid;
  165. and
  166. UnLock(lockid)
  167. unsigned int lockid;
  168. The first call will wait for access to the specific lock, while
  169. the second call will free it. Note that lockids are "hardwired"
  170. into the system.
  171. The final interface to the kernel is that presented between it
  172. and the hardware support. It is assumed that the hardware support
  173. interface provides a certain number of features or routines. These
  174. include the ability to "loadup" the machine state of a process,
  175. manage the memory maps needed for a process, and intercept all
  176. interrupts. To this end, the interface needed by the kernel
  177. includes :
  178. SwapContext(oldcontext,newcontext)
  179. struct PROCESS *oldcontext,*newcontext;
  180. SetTimeSlice(timevalue)
  181. unsigned int timevalue;
  182. AddMemorytoContext(context)
  183. struct PROCESS *context;
  184. RmvMemoryfromContext(context)
  185. struct PROCESS *context;
  186. TestAndSet(addr)
  187. unsigned int *addr;
  188. Clr(addr)
  189. unsigned int *addr;
  190. The first call, SwapContext, is used to force the processor to
  191. save the current state and switch to a new one. The second call
  192. is used to set the time slice value and prime the clock, if
  193. necessary. The next two calls are used to manage the memory maps
  194. to the particular process contexts. Finally, the last two calls
  195. are used to provide a certain amount of multi-processor
  196. synchonization. In addition to the above calls, the kernel makes
  197. available to the hardware interface a routine call
  198. Intr(intlev)
  199. unsigned int intlev;
  200. This routine is the hardware levels way of telling the kernel that
  201. an interrupt has occurred. The 'intlev' are assigned by convention,
  202. and are not arbitrary.
  203. 3. The Process Manager
  204. ----------------------
  205. The process manager is a process that runs inside the kernel
  206. and is responsible for scheduling all user level processes.
  207. The process manager is also responsible for providing the
  208. support for such user level services as starting and stopping
  209. processes, and destroying them. The process manager is really
  210. composed of two separate kernel processes :
  211. o process scheduler,
  212. o process management.
  213. The process scheduler is responsible for finding a process
  214. ready to run and starting it. The process management phase
  215. is responsible for making a process 'known' to the scheduler,
  216. starting and stopping processes, and removing processes from
  217. the domain of the scheduler. No process has direct access
  218. to either of the processes contained in the process manager.
  219. The process scheduler is invoked for every idle processor
  220. in the system : there can be multiple copies of the scheduler
  221. running at a single time. The process scheduler is a program
  222. that selects one process out of possibly many and runs it. The
  223. program selected to run is based on the current priority of
  224. process and some other attributes, such as whether the process
  225. is real time, the amount of computation to i/o time, etc.
  226. The process management phase is a process that waits for requests
  227. from the kernel manager. These requests include the following
  228. o allow a process to compete for a processor,
  229. also known as starting a process;
  230. o prevent a process from competing for a processor,
  231. also known as stopping a process;
  232. o add a process to the known process list;
  233. o remove a process from the known process list;
  234. These requests are sent via the normal XmitMsg facility.
  235. The processes that make up the process manager share a number
  236. of tables and variables. To use any of them, the particular
  237. process must first issue a Lock() request. Once granted, the
  238. process can modify the tables as necessary.
  239. 4. Memory Manager
  240. -----------------
  241. The memory manager is a process that handles all memory for
  242. the system. It is involved whenever a process requires more
  243. memory, or the system needs more memory. The first type of
  244. request occurs when a process asks for more memory. The
  245. second type of request occurs when another process is created
  246. and memory must be allocated for it. Like the process manager,
  247. the memory manager is broken down into two separate components :
  248. o memory request process, and
  249. o memory support process.
  250. The memory request process is responsible for handling user
  251. request. It supports two features :
  252. AllocMem allocate some memory
  253. LiberMem return some memory.
  254. The AllocMem request allows the user to request 'chunks' of
  255. memory, and optionally indicate where the memory should be
  256. placed. The LiberMem request is used to return some 'chunks'
  257. of memory to the system. The memory request process works in
  258. conjunction with the memory support process and the process
  259. management process to do it's job.
  260. The memory support process is directly responsible for allocating
  261. physical memory, supporting the memory management of a process
  262. and swapping or demand paging. This process has no direct path
  263. between the user level processes and it : access is gained only
  264. through action of the memory request process and the process
  265. manager processes.
  266. 5. Kernel Manager
  267. -----------------
  268. The kernel manager is a process that is the single 'thread'
  269. through which all user process requests get funneled. It is
  270. responsible for collecting the message in another process'
  271. memory and mapping it into the kernel's address space; it
  272. determines which server is to get the message; verifies a
  273. few of the arguments; and a few other things. It is also
  274. responsible for the creation of new message queues, the
  275. mapping of message queue references from the external
  276. reference to the global, internal reference, etc.
  277. The services provided to the user process level include
  278. o create a new message queue,
  279. o destroy a message queue,
  280. o change a message queue's characteristics,
  281. o intercept a message queue,
  282. o fork a process,
  283. o terminate a process,
  284. o suspend or resume a process,
  285. o examine a process' state,
  286. o change a process' state, and
  287. o generate a 'soft' interrupt.
  288. 6. File Server
  289. --------------
  290. The file server is a process that provides a 'flat' file system
  291. for the operating environment. It provides, in addition, an
  292. number of other features :
  293. o all control data on the disk is independent of
  294. cpu format, i.e. all disks can be inter-
  295. changed with all disk drives, so long as
  296. the media is supported;
  297. o a two level file deletion mechanism is supported.
  298. Files can be deleted and recovered, if
  299. necessary;
  300. o an automatic part of the file system will permanently
  301. remove files, as the second stage of the
  302. deletion;
  303. o security is built in to the system - the file system
  304. supports access control lists, called ACLs.
  305. The ACLs provide for more than read, write
  306. and execute access - they also provide for
  307. deletion, recover, destroy, etc.
  308. o access to a file can be retracted - if a user has
  309. retract privileges to a file, they can take
  310. away access to the file from others;
  311. o files can have vary cluster allocation sizes;
  312. o it provides for the 'dynamic' connection of disks
  313. to itself; and
  314. o provides for overlapped operation.
  315. 7. Directory Server
  316. -------------------
  317. The directory server is a process that maps strings of characters
  318. into directory entries. In a sense, it is a simple little database.
  319. Access to a directory entry is guaranteed to happen in one disk
  320. access - through a unique hashing scheme names and a small
  321. internal table, the needed entry is found. Unlike most directory
  322. systems, the one provided doesn't hold only information about
  323. files. The directory entry is capable of holding any information :
  324. pointers to files on disks, process identifiers, and the like.
  325. Furthermore, the directory entries can hold a number of other
  326. things, such as the type of file being referenced (text, C source,
  327. etc). This makes it a general purpose directory system.
  328. The services supported by the directory server include :
  329. o creating a new directory entry,
  330. o destroying a directory entry,
  331. o modifying a directory entry, and
  332. o reading a directory entry.
  333. Filename, unlike most other systems have no significance to the
  334. directory server. These filenames can be any length and can hold
  335. any characters. The interpretation of these names, and any
  336. significance of characters, are left to the caller. As an example,
  337. two different file names are
  338. /a/b/c
  339. /a/b/c/d
  340. This gives the impression of a hierarchical directory, when in
  341. reality it is just a simple directory system. The difference
  342. is that the file a/b/c is not a directory holding 'hidden' pointers
  343. to files like d. It is really just a file; this gives the
  344. appearance that directories are really hidden from the caller.
  345. In actuality, the arguments to the directory server include a
  346. wildcard feature which once again gives the appearance of a true
  347. directory system.
  348. 8. The Init Server
  349. ------------------
  350. The init server is the first process that is brought up when the
  351. system is first initialized. It is responsible for starting the
  352. login processes, the network server and any other servers. It is
  353. also responsible for connecting the correct device managers to
  354. the kernel, and a number of other kernel related functions.
  355. 9. The Login Manager
  356. --------------------
  357. The login server process is used to allow users access to the
  358. system. It provides such necessary functions as user validation,
  359. connecting the user to the correct directory and program. The
  360. login server uses the directory server to hold information about
  361. each user. The information includes :
  362. o user's login identifier,
  363. o user's password,
  364. o user's security level,
  365. o user's classification categories,
  366. o starting directory, and
  367. o starting program.
  368. 10. The Network Manager
  369. -----------------------
  370. The network manager is a collection of process that convert
  371. internal kernel requests, sends and receives, to network
  372. requests. Because of it's unique structure it also allows
  373. support for multiple types of protocols, such as delta-t,
  374. IP/TCP, etc. Furthermore, it also contains a dynamic router,
  375. time synchronization support and node failure support.
  376. Because the network manager is 'hidden', user processes do
  377. not have direct access to it. They also don't have knowledge
  378. that a network exists.
  379. As you can see it includes a lot of stuff. That
  380. makes it somewhat flexible. I don't particularly care for
  381. Unices, and have tended to stay away from stupid things like
  382. chmod, etc. The file system I've built depends on ACLs and
  383. detail privileges; for this reason I'm not sure if chmod
  384. makes sense. There are a few other differences, as well.
  385. What is the status of Emacs? Could I get a copy
  386. of it within a week or so? I would like to 'play' around
  387. with it; sort of a beta test.
  388. chuck
  389. ucbvax!decvax!encore!wegrzyn
  390.