home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / linux / 22697 < prev    next >
Encoding:
Text File  |  1993-01-04  |  3.9 KB  |  72 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!modcomp!gamble!nigel
  3. From: nigel@gamble.uucp (Nigel Gamble)
  4. Subject: Re: real time
  5. References: <1993Jan3.054159.11008@umr.edu>
  6. Organization: Nigel Gamble, Consultant
  7. Date: Sun, 3 Jan 1993 11:45:51 GMT
  8. Message-ID: <C0A0oG.Iy@gamble.uucp>
  9. Lines: 61
  10.  
  11. In <1993Jan3.054159.11008@umr.edu> quandt@cs.umr.edu (Brian Quandt) writes:
  12. >What can anyone say about linux and real time support?  Same
  13. >question applies to 386bsd.  I tend to believe that this concept
  14. >would not be possible.  The reason being is that this (I believe)
  15. >is a fundamental design change in how the kernal works.
  16.  
  17. Linux, in common with other traditional UN*X implementations will not
  18. support real time applications.  Real time UN*X does need a fundamental
  19. design change in the kernel, usually referred to as a `fully preemptible'
  20. or `fully semaphored' kernel.  There are two main issues to consider:
  21. interrupt handling and process context switching.
  22.  
  23. Real time processes tend to be interrupt driven; they spend most of
  24. their time asleep, but when the external device they are controlling
  25. sends an interrupt, it is essential that they can be woken up to
  26. deal with the device within the designed time constraints of the
  27. system, e.g. `within 100 microseconds'.  When the interrupt occurs,
  28. the computer may be in the interrupt routine of some other device
  29. with interrupts disabled.  The interrupt routine cannot even begin
  30. to execute until interrupts are enabled again.  This has to be taken
  31. into consideration in the design of every device driver in the system.
  32. It is usual to have a design rule for interrupt handlers specifying the
  33. maximum time that they are allowed to run with interrupts disabled.
  34. This will typically be of the order of 100 microseconds.  If just one
  35. device breaks this rule, you have not got a real time system.
  36.  
  37. When the interrupt routine gets to run, it needs to wake up the user
  38. process and schedule it to run *now*.  The context of the currently
  39. executing process (if of lower priority) is saved and the new process
  40. is given the CPU.  So a context switch is forced, even if the current
  41. process is executing in the kernel.  In Linux all that the interrupt routine
  42. can do to wake up the new process is to mark it as runnable.  If the
  43. currently running process is executing a system call in the kernel, the
  44. new process must wait until the current process either completes the system
  45. call, or voluntarily calls sleep() or shedule().  Otherwise kernel data
  46. structures may be corrupted, since this is the way that they are protected
  47. in a traditional kernel design.
  48.  
  49. A real time fully preemptible kernel design allows multiple processes
  50. to be executing in kernel mode simultaneously.  On a uniprocessor this
  51. means logically simultaneously, but on a multiprocessor system this
  52. means *actually* simultaneously.  (It is interesting that the design
  53. needed for a good real time system also gives you the basis for a good
  54. multiprocessor system).  This is acheived by protecting the critical
  55. regions of kernel code with kernel semaphores.  The critical regions
  56. must be kept as short as possible; this is another design parameter.
  57. Now the wake_up() call (which is implemented as a semaphore signal
  58. operation) can actually cause a context switch to the new process
  59. without waiting for the current process to decide to call sleep()
  60. or schedule().  This, again, should typically take not more than
  61. 100 microseconds.
  62.  
  63. Assuming that the design rules are followed by the kernel *and all of
  64. the device drivers*, you can predict the worst case time from the
  65. initial interrupt through the interrupt handler, through the context
  66. switch, to the first user level instruction of the new (assuming highest
  67. priority) process, typically 300 microseconds.  If this worst case time
  68. is good enough for your application, you have a real time system.
  69. -- 
  70. Nigel Gamble                                    gamble!nigel@uunet.UU.NET
  71. Ft. Lauderdale, FL                              uunet!gamble!nigel
  72.