home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / notes / changes < prev    next >
Encoding:
Text File  |  1992-08-09  |  12.2 KB  |  259 lines

  1. # Overview of changes going from native Sprite to Sprite server.
  2.  
  3.                   -- dev --
  4.  
  5. - machine-independent code should stay the same, except need to
  6.   store some Mach ports in Fs_Device & other data structures (e.g.,
  7.   DevTty).  
  8. - machine-dependent code becomes facade over the Mach device
  9.   interface (anything under the FS switch table is open to being
  10.   completely rewritten).  
  11. - Input is done by a separate thread that does a read request and
  12.   blocks until it gets something from Mach, at which point it notifies
  13.   the rest of Sprite (equivalent to getting an input interrupt).
  14. - Console handled by reading/writing UNIX /dev/tty in raw mode, using
  15.   Sprite Td library and Sprite stdio.  Changed the tty output buffer
  16.   size in attempt to work around what appears to be a bug in the UX
  17.   telnetd.
  18. - tty code is potentially simplified: don't need intermediate buffer (which
  19.   was there to simplify buffer management at interrupt level).  
  20. - Some thought needed to get resource management (reference counts) right?
  21. - Note that we access remote devices using Sprite RPC, rather than Mach
  22.   IPC.  
  23. - The Sprite server will not use the attach/release mechanism to
  24.   truly open/close a block device--do it all in the open/close routines.
  25. - I started out trying to match up driver functionality, make sure that
  26.   the Sprite #define's would match up with the Mach #define's, etc.
  27.   This was apparently a waste of time, so I punted.
  28. - No more L1 commands.
  29.  
  30.                 -- fscache --
  31.  
  32. - initially use a fixed-size (4MB), wired-down FS cache.  
  33. - Get rid of machine-dependent call to lock cache pages (used in
  34.   native Sprite for sun4).
  35.  
  36.                    -- fs --
  37.  
  38. - needed more precise handling of VM segPtr
  39. - Sys_Stats command for "fscmd -O" was broken--would zero out state
  40.   information as well as counters. 
  41. - Ripped out useless (broken?) support for shared mapped files.
  42.  
  43.                   -- mach --
  44.  
  45. - Most of the mach module (e.g., hardware definitions, interrupt
  46.   masking, machine/boot initialization, calls to the monitor) goes away.
  47. - Some of the #define's should come from Mach (e.g., boundaries of user
  48.   address space).  
  49. - The machine-dependent process state code (e.g., exec & debugger
  50.   support) is replaced by a much smaller bit of machine-dependent code
  51.   that uses thread_{get,set}_state.
  52. - Some routines and globals were renamed to move them into other
  53.   modules (e.g., mach_Format -> fsMach_Format).
  54.  
  55.                   -- main --
  56.  
  57. - start-up code similar, though somewhat simpler, and order of module
  58.   initialization is different. 
  59. - Added flag to tell when there are multiple threads running (e.g., so
  60.   that code that calls UNIX can tell whether it's safe).
  61.  
  62.                   -- net --
  63.  
  64. - Network polling (for the debugger) goes away.  
  65. - changed to always send packets asynchronously.  (Native Sprite sends
  66.   some packets synchronously to avoid overwriting the buffer before
  67.   the packet is sent.)
  68. - Fixed bug in arp/rarp code that was tickled by receiving our own
  69.   broadcast packets.
  70. - Less bandwidth and more latency when using Mach device interface.
  71.   This means it's even more important than in native Sprite to avoid
  72.   going remote.
  73. - hacked local version of Mach to make maximum inband size big enough
  74.   to hold most Sprite RPC packets.  Big perf win for null RPCs; less
  75.   impressive win for Andrew benchmark.
  76.  
  77.                   -- proc --
  78.  
  79. - in native Sprite, when you're running in the kernel you have a
  80.   particular context and you can access your memory.  In a server, you
  81.   have to be more careful about accessing memory.  As far as contexts,
  82.   you can mostly use the same code, but there are places that need
  83.   attention, like getting the "current" context and doing a context
  84.   switch.  Also, the process could conceivably continue doing things
  85.   while the server is processing a request, which it not at all possible
  86.   in native version.  Also, processes can go away without your control,
  87.   so you either need a notification mechanism or be prepared for
  88.   tasks/threads to vanish at arbitrary times.  
  89. - Need additional locking (e.g., lock parent proc in Proc_NewProc)
  90.   because we now allow asynchronous kills.  (Native Sprite allows
  91.   asynchronous kills, but it appears to be supported only when the
  92.   killed process is not able to kill itself (e.g., it's migrated).)
  93.   Asynchronous kills also make it harder to ensure that request ports
  94.   point to the right PCB entry.  Also complicated interaction with sig
  95.   module, introduced deadlocks, etc.
  96. - Have to be careful about where a process exits, so that MIG buffers
  97.   get freed correctly.  
  98. - Sprite process model isn't same as Mach model (Mach can have
  99.   multiple threads per task): can either hack to make it use Mach
  100.   model, or can put in limitations/checks to make sure it uses the
  101.   Sprite model.
  102. - To help get PCB locking right, added a new type to represent a
  103.   locked PCB entry.
  104. - Server processes don't always have FS state because (1) they don't
  105.   need it (except for the ancestors of init) and (2) early server
  106.   threads (e.g., for network & timer) can't get it because it hasn't
  107.   been set up yet.
  108. - For exec(), changed interface to pass strings in directly,
  109.   rather than copying in one at a time.  In general, cross-address
  110.   space references (e.g., copyin/copyout, Vm_MakeAccessible) seem to
  111.   be more expensive with sprited than with native Sprite.
  112. - Big perf win from sticky segments.
  113. - Fixed deadlock in native interval timer code (was inconsistent about
  114.   locking monitor or PCB first).
  115.  
  116.               -- (proc) traps --
  117.  
  118. - Replace trap handling code with exception handler & MIG-based
  119.   syscall code.  Some of the standard "return from trap" code
  120.   (especially checking for signals) goes into the system call stubs in
  121.   the emulation library.
  122.  
  123.                   -- rpc --
  124.  
  125. - Fixed native Sprite race condition between timeout and receipt of
  126.   RPC ack (?) that would cause RPC channel to get doubly enqueued in
  127.   timeout queue.
  128. - Fixed native Sprite bug that would cause processes to hang when
  129.   trying to allocate a channel. 
  130. - Fixed native Sprite bug where Sprite would smash the arguments to
  131.   Test_Rpc via bogus Vm_MakeAccessible calls.
  132. - Cleaned up RPC timing histogram code.
  133.  
  134.              -- sched and sync --
  135.  
  136. - this gets simplified in some ways, because somebody else has
  137.   provided the basic synchronization mechanism (e.g., don't 
  138.   need sched master lock anymore).  In fact, the entire sched module
  139.   goes away (which requires some renaming, e.g., Sched_ContextSwitch
  140.   becomes Proc_ContextSwitch).
  141. - Is more complicated if you want to build synch primitives on top of
  142.   the given package (e.g., your synch 
  143.   package has to know something about impl of the lower-level package).
  144. - If native version is event-based, can either keep (e.g.,
  145.   single-server) or replace with condition variables (Sprite).  
  146. - Sprite condition variables don't require initialization; CThreads condition
  147.   variables do.  
  148. - Race conditions are more likely; pretend that you're on a
  149.   multiprocessor, even if you're on a uniprocessor.  
  150. - Sync_SlowWait had to be hacked because sprited implements the
  151.   process SUSPENDED state with a condition variable (rather than just
  152.   removing the process from the run queue).  (Maybe it would have been
  153.   cleaner to ditch the SUSPENDED state and make it a PCB flag.)
  154.  
  155.                 -- signals --
  156.  
  157. - server no longer manages time slices, so can't guarantee that
  158.   process will notice that it's got a signal.  To get same behavior as
  159.   native version, need mechanism to force the user process into a signal
  160.   handler or whatever.  This messes up the current Sprite signals
  161.   code something fierce, because routines like Sig_Handle and
  162.   Sig_SuspendProcess assume that the current process is the one that the
  163.   signal is being delivered to.  Some of the problems weren't
  164.   immediately obvious.  For example, if a process gets multiple
  165.   SIGDEBUGs, the Sprite server has to make sure the process isn't
  166.   already in the debug list (in native Sprite, the process puts itself
  167.   in the debug list, so it can't already be there).  Also, a process
  168.   normally changes its own state to EXITED or DEAD, so the usual
  169.   transition is from RUNNING.  With sprited, you can also go from
  170.   WAITING and SUSPENDED.  In an attempt to limit some of the
  171.   complications, suspending a process other than yourself is postponed
  172.   if that process is in the middle of a Sprite request.
  173. - C Threads doesn't provide support for "wake if signal" semantics.  
  174. - Hard to separate out machine-management functionality from UNIX
  175.   virtual machine management, e.g., do you really need to maintain all
  176.   that state on the signal stack, or can the kernel manage some of it;
  177.   complicated by the sheer hairiness of the code.  
  178. - Have to set up mapping from Mach exception codes to Sprite signals &
  179.   subcodes--rather tedious, especially with all the machine-dependent
  180.   subcodes.
  181.  
  182.                   -- sys --
  183.  
  184. - Get rid of the trap-based calls and use MIG-based stubs.  In a
  185.   couple places this requires some extra checks to verify that the
  186.   Sprite MIG type definitions are compatible with the Sprite C type
  187.   definitions.  This also requires writing various stubs in modules
  188.   that have direct user requests.
  189. - Allowing request queue to grow arbitrarily large is a bad idea;
  190.   it causes the "thrash" program to (eventually) see bogus pages.
  191.  
  192.                   -- timer --
  193.  
  194. - no clock interrupts, so for the timer queue do what the UX
  195.   server does: figure out when you want to get woken up, and do a
  196.   msg_receive with the corresponding timeout.  When you get woken up,
  197.   check whether it's time to execute something from the queue; if not,
  198.   recompute how long to wait and repeat.  If a new event gets added to
  199.   the queue with a timeout earlier that the current front of the queue,
  200.   do a send, which will force the waiting thread to reschedule.
  201. - Management of the current time-of-day is simplified--just ask the
  202.   kernel.  All the hardware management code goes away.  Also, can just
  203.   query Mach (HOST_SCHED_INFO) to get the timer resolution.
  204. - Make "Timer_Ticks" and timer "intervals" be the same as "Time" (lots of
  205.   edits because intervals are integers, and Time is a struct).
  206.  
  207.                    -- VM --
  208.  
  209. - throw out most of old VM implementation.  Write memory manager.
  210.   Write interface layer so that rest of Sprite sees the same interface.
  211. - Would like to avoid bookkeeping (in favor of having the kernel do it
  212.   and querying the kernel when necessary), but this causes performance
  213.   bottlenecks (e.g., for fork()).
  214. - Used a reference count instead of no-senders notification to manage
  215.   the memory objects.  I understand reference counts, and the
  216.   no-senders stuff looks like it has some strange special cases to
  217.   worry about (at least from looking at the UX code).
  218. - Note race condition in Vm_MakeAccessible: can get name port for the
  219.   segment via vm_region before the pager has gotten it via
  220.   memory_object_init.
  221. - Note problem with catching the server's exceptions for copyin &
  222.   copyout (no way for the pager to directly cause the copyin/copyout
  223.   to fail).
  224. - Vm_MakeAccessible abuse in native Sprite: calls that would map in a
  225.   struct, then map in objects pointed by the struct, overwriting
  226.   fields in the original struct (e.g., Test_RpcStub).  Could also be a
  227.   problem with, say, an array of string pointers that is passed in by
  228.   a user program: if you pass an element of the array to
  229.   Proc_MakeStringAccessible, it will mung the array.
  230. - Not being able to use the default pager is definitely a lose as far
  231.   as the performance of fork.  Even when you don't have to go to the
  232.   file server, you end up with a lot of zero-fill page faults...
  233.  
  234.                   -- misc. --
  235.  
  236. - Sprite should use more typedefs for, e.g., file offset and
  237.   lengths (sizes) of things.  
  238. - In order to make reintegration easier, I tried to avoid propagating
  239.   the Mach typedefs into old Sprite function definitions & types.
  240. - Fair amount of lint in some places (e.g., use of signed versus
  241.   unsigned integers in RPC module). 
  242.  
  243.          -- instrumentation and debugging --
  244.  
  245. - some numbers (e.g., resource usage) have to be done by the kernel,
  246.   so if Mach doesn't provide them, you either do without or you hack
  247.   the kernel.
  248. - added system call counting & timing to the ds5000 system call trap
  249.   handler in native Sprite.  This was a lot easier to do for sprited,
  250.   since there I could do it in C!
  251.  
  252.  
  253.                   -- mem --
  254.  
  255. - Goes away, at least initially: use ckalloc on top of UX malloc.
  256.   (Using ckalloc requires edits in a lot of places, though.)  Would
  257.   get better performance using binned memory allocator like the native
  258.   Sprite one?
  259.