Commit d9c8508

mo khan <mo@mokhan.ca>
2021-03-13 21:40:44
add notes on operating system stuff
1 parent ff62438
Changed files (1)
doc
doc/2.md
@@ -339,3 +339,221 @@ performance;
 
 After the system is written, bottleneck routines can be identified and can be replaced with
 assembly-language equivalents.
+
+## Operating-System Structure
+
+### Simple Structure
+
+MS-DOS
+
+```plaintext
+---------------------------
+| application program     |
+---------------------------
+| resident system program |
+---------------------------
+| MS-DOS device drivers   |
+---------------------------
+| ROM BIOS device drivers |
+---------------------------
+```
+
+UNIX
+
+```plaintext
+|----------------------------------------------------------------|
+| the users                                                      |
+|----------------------------------------------------------------|
+| shells and commands                                            |
+| compilers and interpreters                                     |
+| system libraries                                               |
+|----------------------------------------------------------------|
+|----------------------------------------------------------------|
+| system-call interface to the kernel                            |
+|----------------------------------------------------------------|
+|----------------------------------------------------------------|
+| signals terminal     | file system           | CPU scheduling  |
+| handling             | swapping block I/O    | page replacement|
+| character I/O system | system                | demand paging   |
+| terminal drivers     | disk and tape drivers | virtual memory  |
+|----------------------------------------------------------------|
+|----------------------------------------------------------------|
+| terminal controllers | device controllers | memory controllers |
+| terminals            | disks and tapes    | physical memory    |
+|----------------------------------------------------------------|
+```
+
+### Layered Approach
+
+With hardware support, operating systems can be broken into pieces
+that are smaller and more appropriate than those allowed by the
+original MS-DOW and UNIX systems.
+
+The layered approach breaks up the operating system into multiple layers.
+The bottom layer (level 0) is the hardware; the highest layer (layer N) is
+the user interface.
+
+```plaintext
+| layer N (UI)     |
+| ...              |
+| layer 1          |
+| layer 0 hardware |
+```
+
+### Microkernels
+
+As UNIX expanded, the kernel became large and difficult to manage.
+In the mid-1980's, researchers at Carnegie Mellon University developed
+an operating system called 'Mach' that modularized the kernel using
+the microkernel approach. This method structures the operating system by
+removing all nonessential components from the kernel and implementing
+them as system and user-level programs.
+
+The result is a smaller kernel but there is little consensus on which services
+should remain in the kernel and which should be implemented in user space.
+
+microkernels provide minimal process and memory management, in addition to
+communication facility.
+
+Communication is provided through message passing.
+
+Microkernels make it easier to extend the operating system.
+It's easier to port from one hardware design to another.
+It provides more security and reliability.
+
+The macOS kernel (aka Darwin) is also partly based on the Mach microkernel.
+
+Windows NT 4.0 was a microkernel but was slow. By the time it got to
+Windows XP it had become a monolithic kernel.
+
+### Modules
+
+The kernel has a set of core components and links in additional services via modules,
+either at boot time or during run time. aka loadable kernel modules.
+
+This design is implemented in Solaris, Linux, macOS and Windows.
+
+The kernel provides core services while other services are implemented dynamically,
+as the kernel is running. Linking services dynamically is preferable to adding
+new features directly to the kernel, which would require recompiling the kernel
+every time a change was made.
+
+The Solaris operating system structure is organized around a core kernel with
+seven types of loadable kernel modules:
+
+1. Scheduling classes
+1. File systems
+1. Loadable system calls
+1. Executable formats
+1. STREAMS modules
+1. Miscellaneous
+1. Device and bus drivers
+
+### Hybrid Systems
+
+Few operating systems adopt a single, strictly defined structure.
+Instead, they combine different structures, resulting in hybrid
+systems that address performance, security and usability issues.
+Linux and Solaris are monolithic, because having the operating system
+in a single address space provides very efficient performance.
+However they are also modular, so new functionality can be dynamically
+added to the kernel.
+
+#### Apple macOS X
+
+Apple macOS uses a hybrid structure.
+The top layers include the Aqua user interface and a set of application
+environments and services.
+Cocoa environment specifies an API for the Objective-C programming
+language, which is used for writing macOS applications.
+
+Below these layers is the kernel environment, which consists primarily
+of the Mach microkernel and BSD UNIX kernel.
+Mach provides memory management; support for remote procedure calls (RPCs)
+and interprocess communication (IPC) facilities, including message passing;
+and thread scheduling.
+The BSD component provides a BSD command-line interface, support for networking
+and file systems, and an implementation of POSIX APIs, including Pthreads.
+
+In addition to Mach and BSD, the kernel environment provides an I/O kit
+for development of device drivers and dynamically loadable modules (which
+macOS refers to as kernel extensions).
+The BSD application environment can make use of BSD facilities directly.
+
+```plaintext
+----------------------------------------
+| GUI (Aqua)                           |
+----------------------------------------
+| application environment and services |
+| (Java) (Cocoa) (Quicktime) (BSD)     |
+----------------------------------------
+| kernel       |                       |
+|              |          BSD          |
+|              |------------------------
+|  Mach                                |
+|                                      |
+----------------------------------------
+| I/O kit      |   kernel extensions   |
+----------------------------------------
+```
+
+#### iOS
+
+iOS is a mobile operating system designed by Apple to run its smartphone,
+the iPhone, as well as its table computer, the iPad. iOS is structured on
+the Mac OS X operating system, with added functionality pertinent to mobile
+devices, but does not directly run macOS applications.
+
+Cocoa Touch is an API for Objective-C that provides several frameworks for
+developing applications that run on iOS devices. Cocoa Touch provides
+support for hardware features unique to mobile devices, such as touch screens.
+
+The media services layer provides services for graphics, audio and video.
+The core services layer provides features like support for cloud computing
+and databases. The bottom layer represents the core operating ssytem which
+is based on the kernel environment.
+
+```plaintext
+------------------
+| Cocoa Touch    |
+------------------
+| Media Services |
+------------------
+| Core Services  |
+------------------
+| Core OS        |
+------------------
+```
+
+#### Android
+
+The Android operating system was designed by the Open Handset Alliance
+(led primarily by Google) and was developed for Android smartphones and
+tablet computers.
+
+Android runs on a variety of mobile platforms and is open-source.
+
+```plaintext
+----------------------------------------------------
+|                 Applications                     |
+----------------------------------------------------
+----------------------------------------------------
+|            Application Framework                 |
+----------------------------------------------------
+-----------------------------  --------------------
+|   Libraries               | |  Android runtime   |
+| ---------   ----------    | | ------------------ |
+| | SQLite |  | openGL |    | | | Core libraries | |
+| ---------   ----------    | | ------------------ |
+| ----------- ------------- | |  ----------        |
+| | surface | | media     | | |  | Dalvik |        |
+| | manager | | framework | | |  |   VM   |        |
+| ----------- ------------- | |  ----------        |
+| ----------  --------      | |                    |
+| | webkit |  | libc |      | |                    |
+| ----------  --------      | |                    |
+----------------------------   --------------------
+----------------------------------------------------
+|                  Linux kernel                    |
+----------------------------------------------------
+```