diff options
| author | mo khan <mo.khan@gmail.com> | 2021-01-25 20:51:07 -0700 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2021-01-25 20:51:07 -0700 |
| commit | 36cb136cf60414dc78df180de5806509d86b6bc5 (patch) | |
| tree | 691476849bfa1802b3e2299c269901fe9619f289 | |
| parent | 41756b4424f45167d13f18dd5f86532e1bc1b67d (diff) | |
add notes from chapter 1
| -rw-r--r-- | doc/1.md | 204 |
1 files changed, 204 insertions, 0 deletions
@@ -155,3 +155,207 @@ Events are almost always signaled by the occurrence of an interrupt or a trap. A trap, or an exception, is a software generated interrupt caused either by an error or by a specific request from a user program that an operating-system service be performed. + +Terms: + +* CPU scheduling +* job scheduling +* logical memory +* physical memory +* swapping +* virtual memory + + +For each type of interrupt, separate segments of code in the operating system +determine what action should be taken. An interrupt service routing +is provided that is responsible for dealing with the interrupt. + +## Dual Mode Operation + +Must distinguish between operating system code and user-defined code. + +* user mode +* kernel mode (supervisor mode, system mode, priviliged mode) + +The `mode bit` is added to hardware to indicate the current mode: kernel (0), user (1) +The hardware allows privileged instructions to be executed only in kernel mode. + +System calls provide the means for a user program to ask the operating system to perform +tasks reserved for hte operating system on the user program's behalf. + +A system call usually takes the form of a trap to a specific location in the interrupt vector. +This trap can be executed by a generic trap instruction, although some systems have a specific +syscall instruction. + +### Timer + +We must ensure that the operating system maintains control over the CPU. +We cannot allow a user program to get stuck in an infinite loop or to fail +to call system services and never return control to the operating system. + +To accomplish this, we can use a `timer`. A timer can be set to interrupt +the computer after a specified period. + +## Process Management + +A programs instructions are executed by a CPU. +A program in execuation is a `process`. +A time-shared user program is a `process`. + +A process needs: + +* CPU time +* memory +* files +* I/O devices + +A single-threaded process has one `program counter` +specifying the next instruction to execute. +The execution of such a process must be sequential. + +Although more than one process may be associated with +the same program, they are considered two separate execution +sequences. + +The operating system is responsible for: + +* scheduling processes and threads on the CPU +* creating and deleting both user and system processes +* suspending and resuming processes +* providing mechanisms for process synchronization +* providing mechanisms for process communication + +## Memory Management + +Main memory is a large array of words or bytes, ranging +in size from hundreds of thousands to billions. + +Each word or byte has it's own address. +Main memory is a pool of quickly accessible data shared by +the CPU and I/O devices. + +On a von Neuman architecture, the central processor reads +instructions from main memory during the instruction-fetch +cycle and both reads and writes data from main memory during the +data-fetch cycle. + +The main memory is generally the only large storage device +that the CPU is able to address and access directly. + +For example, for the CPU to process data from disk, those data +must first be transferred to main memory by CPU-generated I/O calls. + +For a program to be executed, it must be mapped to absolute +addresses and loaded into memory. As the program executes, it +accesses program instructions and data from memory by generating +these absolute addresses. + +The operating system is responsible for the following: + +* keeping track of which parts of memory are currently being used and by whom +* deciding which processes (or parts thereof) and data to move into and out of memory +* allocating and deallocating memory space as needed. + +## Storage Management + +The OS provides uniform, logical view of information storage. +The OS abstracts from the physical properties of its storage +devices to define a logical storage unit, the `file`. +The OS maps files onto physical media and accesses these files +via the storage devices. + +### File-System Management + +File management is one of the most visible components of an operating system. +Computers can store information on several different types of physical media. +Magnetic disk, optical disk, and magnetic tape are th emost common. +Each of these media has its own characteristics and physical organization. +Each medium is controlled by a device, such as a disk drive or tape drive, +that also has its own unique characteristics. These properties include +access speed, capacity, data-transfer rate, and access method (sequential or random). + + +A `file` is a collection of related information defined by it's creator. +Files represent programs and data. Data files may be numeric, alphabetic, +alphanumeric or binary. File may be free-from or they may be formatted rigidly. + +The OS is responsible for: + +* creating and deleting files +* creating and deleting directories to organize files +* supporting primitives for manipulating files and directories +* mapping files onto secondary storage +* backing up files on stable (nonvolatile) storage media + +### Mass-Storage Managment + +OS is responsible for + +* free space management +* storage allocation +* disk scheduling + +### Caching + +| Level | 1 | 2 | 3 | 4 | +| ----- | - | - | - | - | +| Name | registers | cache | main memory | disk storage | +| Size | < 1 KB | < 16 MB | < 64 GB | > 100 GB | +| Access time (ns) | 0.25 - 0.5 | 0.5 - 25 | 80 - 250 | 5,000.000 | +| Bandwith (MB/sec) | 20,000 - 100,000 | 5,000 - 10,000 | 1,000 - 5,000 | 20 - 150 | +| Managed by | compiler | hardware | operating system | operating system | +| Backed by | cache | main memory | disk | CD or tape | + +### I/O Systems + +OS's hide the pecularities of specific hardware devices from the user. +The I/O subsystem consists of: + +* memory management component that includes buffering, caching, and spooling +* general device-driver interface +* drivers for specific hardware devices + +Only the device driver knows the peculiarities of the specific device to +which it is assigned. + +## Protection and Security + +Memory-addressing hardware ensures that a process can execute only within its own address space. +The timer ensures that no process can gain control of the CPU without eventually relinquishing control. +Device-control registers are not accessible to users, so the integrity of the various peripheral devices is protected. + +`Protection` is any mechanism for controlling the access of processes or users to the resources defined by a computer system. +It is the job of `security` to defend a system from external and internal attacks. + +Operating systems maintain a list of user names and associated user identifiers (user IDs aka SIDs). + +The GNU General Public License (GPL) codifies copylefting and is a common license under +which free software is released. Fundamentally, GPL requires that the source code be +distributed with any binaries and that any changes made to the source code be released +under the same GPL license. + +## BSD Unix + +BSD Unix has a longer and more complicated history than Linux. +It started in 1978 as a derivative of AT&T's UNIX. + +Releases from the University of California at Berkeley came in source and binary +form, but they were not open-source because a license form AT&T was required. +BSD UNIX's development was slowed by a lawsuit by AT&T, but eventually a fully +functional open-source version, 4.4BSD-lite, was released in 1994. + +There are many distributions of UNIX, including FreeBSD, NetBSD, OpenBSD and DragonflyBSD. +The source code for FreeBSD can be found in `/usr/src/`. Ther kernel source code +is in `/usr/src/sys`. + +Darwin, the core kernel component of macOS is based on BSD UNIX and is open-sourced as well. + +## Summary + +An operating system is software that manages the computer hardware, as well as providing +an environment for application programs to run. + +For a computer to do its job of executing programs, the programs must be in main memory. +Main memory is the only large storage area that the processor can access directly. +It is an array of words or bytes, ranging in size from millions to billions. Each +word in memory has its own address. |
