intro.9.txt 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. INTRO(9)
  2. ========
  3. :doctype: manpage
  4. :man source: X15
  5. :man manual: X15 Kernel Developer{rsquo}s Manual
  6. NAME
  7. ----
  8. intro - introduction to kernel interfaces
  9. DESCRIPTION
  10. -----------
  11. X15 is an open source real-time microkernel intended to provide a performant
  12. and scalable environment for cache-coherent multiprocessor machines.
  13. Section 9 of the manual describes kernel interfaces, both internal and
  14. provided to application code hosted in kernel mode.
  15. Among the features provided are :
  16. * <<preemptive_multithreading,Preemptive multithreading>>
  17. * <<generic_development_tools,Generic development tools>>
  18. * <<multiprocessor_support,Multiprocessor support>>
  19. * <<virtual_memoru,Virtual memory>>
  20. * <<real_time,Real-time>>
  21. * <<portability,Portability>>
  22. Modules
  23. ~~~~~~~
  24. The module is the functional unit around which kernel sources are organized.
  25. A single module is made up of at least one public header file. There is
  26. usually also an opaque implementation file. An implementation header can
  27. complement the module for inline functions and private structures allowed
  28. to be allocated from the stack. Finally, a type-only header can also be
  29. present in order to avoid circular inclusions.
  30. The files of a module must strictly be named according to the module name.
  31. Here are the name patterns for each file of a module :
  32. *<module>.c*::
  33. Opaque implementation.
  34. *<module>.h*::
  35. Public header.
  36. *<module>_i.h*::
  37. Implementation header.
  38. *<module>_types.h*::
  39. Type-only header.
  40. Components
  41. ~~~~~~~~~~
  42. Modules are grouped into components, with one directory per component.
  43. The main components are :
  44. *arch*::
  45. Architecture-specific modules, located in arch/<arch>.
  46. *test*::
  47. Test modules.
  48. *vm*::
  49. Virtual memory system.
  50. *kern*::
  51. Machine-independent modules that don't belong in another component.
  52. [[preemptive_multithreading]]
  53. PREEMPTIVE MULTITHREADING
  54. -------------------------
  55. The X15 kernel provides threads which can be preempted at almost any time,
  56. in both kernel and user space. They have an associated scheduling policy
  57. and priority. Currently, the available scheduling policies are :
  58. *Fair scheduling (FS)*::
  59. A non real-time, proportionally fair policy.
  60. *First-in, first-out fixed priority (FIFO)*::
  61. A real-time, fixed-priority based FIFO policy.
  62. *Round-robin (RR)*::
  63. A real-time, fixed-priority based policy with round-robin among same
  64. priority threads.
  65. In addition, the kernel provides many thread synchronization facilities.
  66. The relevant modules are :
  67. module:kern/condition::
  68. Condition variable.
  69. module:arch/cpu::
  70. Architecture-specific processor interface which provides interrupt
  71. control functions.
  72. module:kern/mutex::
  73. Mutual exclusion lock.
  74. module:kern/rcu::
  75. Read-Copy Update (RCU) lockless synchronization.
  76. module:kern/semaphore::
  77. Semaphore.
  78. module:kern/sleepq::
  79. Low level sleep queue.
  80. module:kern/thread::
  81. Preemptive thread scheduling.
  82. module:kern/work::
  83. Work queue of deferred asynchronous lightweight jobs.
  84. All wait functions on synchronization objects can be time-bounded.
  85. This includes waiting for a mutex lock, a condition variable, or a
  86. semaphore.
  87. Mutex implementations
  88. ~~~~~~~~~~~~~~~~~~~~~
  89. In order to best satisfy either overall performance or latencies, the
  90. kernel provides several mutex implementations for the interface provided
  91. by the *mutex* module. Note that, whatever implementation is selected,
  92. the *rtmutex* module is always available. The mutex implementations are :
  93. module_mutex:adaptive::
  94. Adaptive spinning mutex, spinning instead of sleeping if the owner
  95. is running, in the hope the critical section is short and the mutex
  96. will be unlocked soon, to avoid expensive sleep/wakeup operations.
  97. This implementation should improve overall performance at the cost
  98. of increased latencies.
  99. module_mutex:pi::
  100. Real-time mutex with priority inheritance. This implementation is a
  101. wrapper in front of the *rtmutex* module. It should improve latencies
  102. at the cost of overall performance.
  103. module_mutex:plain::
  104. Default mutex, immediately sleeping on contention.
  105. [[generic_development_tools]]
  106. GENERIC DEVELOPMENT TOOLS
  107. -------------------------
  108. Along with the kernel sources are a set of generic data structures and
  109. other development tools :
  110. module:kern/bitmap::
  111. Arbitrary-length bit array.
  112. module:kern/bulletin::
  113. Publish-subscribe mechanism.
  114. module:kern/cbuf::
  115. Circular byte buffer.
  116. module:kern/clock::
  117. Low resolution clock.
  118. module:kern/error::
  119. Common errors and error handling functions.
  120. module:kern/hash::
  121. Hash functions for integers and strings.
  122. module:kern/hlist::
  123. Doubly-linked list specialized for forward traversals and O(1) removals.
  124. module:kern/kmem::
  125. Object caching and general purpose memory allocator.
  126. module:kern/list::
  127. Doubly-linked list.
  128. module:kern/macros::
  129. Useful generic macros.
  130. module:kern/perfmon::
  131. Performance monitoring.
  132. module:kern/rbtree::
  133. Red-black tree.
  134. module:kern/rdxtree::
  135. Radix tree (with integer keys).
  136. module:kern/slist::
  137. Singly-linked list.
  138. module:kern/syscnt::
  139. Generic 64-bits counter.
  140. module:kern/timer::
  141. Low resolution timer.
  142. X15 doesn't provide a generic queue interface, because the requirements
  143. often vary too much. Similarly, it doesn't provide a hash table interface.
  144. Instead, users can easily build specialized queues, hash tables and ring
  145. buffers on top of the provided facilities.
  146. See manpage:cenv for information about the subset of standard C interfaces
  147. supported.
  148. [[multiprocessor_support]]
  149. MULTIPROCESSOR SUPPORT
  150. ----------------------
  151. The X15 kernel is designed to support hardware with multiple processors.
  152. The scheduler should scale well up to 16-32 processors, with one
  153. run queue per processor. Threads can be bound to a specific set of
  154. processors, or temporarily pinned for short durations. Non real-time
  155. threads can be spontaneously migrated between processors in order to
  156. maximize processor utility.
  157. Here are some modules related to multiprocessor support :
  158. module:kern/atomic::
  159. Inter-processor atomic operations.
  160. module:kern/cpumap::
  161. Specialized bitmaps representing processor sets.
  162. module:kern/percpu::
  163. Per-processor data.
  164. module:kern/spinlock::
  165. Inter-processor spin locks.
  166. module:kern/sref::
  167. Scalable multiprocessor reference counters.
  168. module:kern/thread::
  169. Preemptive thread scheduling.
  170. module:kern/xcall::
  171. Low level inter-processor function calls.
  172. [[virtual_memoru]]
  173. VIRTUAL MEMORY
  174. --------------
  175. TODO Write when the virtual memory system is rewritten.
  176. [[real_time]]
  177. REAL-TIME
  178. ---------
  179. X15 complies with all the requirements of a real-time multiprocessor
  180. system. It is a fully preemptible kernel with short, bounded
  181. preemption-based critical sections. It provides real-time scheduling
  182. policies and a complete priority inheritance algorithm. Preemption and
  183. interrupts are clearly decoupled so that interrupts can remain enabled
  184. as much as possible. Multiprocessor synchronization uses rigorously
  185. fair spin locks. The modules related to real-time are :
  186. module:kern/rtmutex::
  187. Mutual exclusion with priority inheritance.
  188. module:kern/spinlock::
  189. Inter-processor spin locks.
  190. module:kern/thread::
  191. Preemptive thread scheduling.
  192. module:arch/trap::
  193. Interrupt and exception handling.
  194. module:kern/turnstile::
  195. Low level priority propagation capable sleep queue.
  196. Priority inheritance can also be enabled for regular mutexes. Please read
  197. Victor Yodaiken's report {against-priority-inheritance} in order to fully
  198. understand the implications of relying on priority inheritance.
  199. TODO Separate man page with more description
  200. [[portability]]
  201. PORTABILITY
  202. -----------
  203. Despite the fact that the kernel currently only supports the x86
  204. architecture, which will remain the reference port, the code is already
  205. very portable, thanks to a clear separation between architecture-specific
  206. and machine-independent modules, as well as good programming practice,
  207. in particular regarding type widths, endianness, and memory models.
  208. Ports are located in the arch directory. Here are the modules that
  209. must provide interfaces expected by the machine-independent layer :
  210. module:arch/atomic::
  211. Architecture-specific support for atomic instructions.
  212. module:arch/cpu::
  213. Processor interface.
  214. module:arch/pmap::
  215. Physical mappings, the MMU driver.
  216. module:arch/strace::
  217. Stack tracing.
  218. module:arch/tcb::
  219. Thread control block.
  220. module:arch/trap::
  221. Interrupt and exception handling.
  222. The machine-independent code assumes either an ILP32 or LP64 data model, and
  223. a completely relaxed memory model as allowed by the C11 specification.
  224. X15 currently requires a memory management unit, but that may change in
  225. the future.
  226. SEE
  227. ---
  228. manpage:cenv
  229. manpage:init
  230. manpage:style
  231. manpage:xbuild
  232. {x15-operating-system}