Overview Flashcards
Introduction, Virtual Machines, Systems programming languages
Operating System
An operating system is a program that controls execution of application programs and acts as an interface between applications and computer hardware.
“The one program running at all times on the computer” is the kernel, core component of the operating system.
Everything else is either
- A system program, or
- An application program
An operating system is interrupt driven.
Aims of an Operating System
- Execute user programs and make solving user problems easier
- Make the computer system convenient to use
- Use the computer hardware in an efficient manner
Abstract View of Components of Computer
User
↕
Application Programs
(compilers, web browsers, development kits, etc.)
↕ ↕ ↕
Operating system
↕ ↕ ↕
Computer Hardware
(CPU, memory, I/O, etc.)
System Program
A program that is associated and ships with the operating system, but not part of the kernel.
Application Program
All programs not associated with the operating system.
Interrupt Handling
The operating system preserves the state of the CPU by storing the registers and the program counter.
Determines which type of interrupt has occurred:
- Hardware interrupt by one of the devices
- Software interrupt(exception or trap):
- Software error
- Request for operating system service – system call
Separate segments of code determine what action should be taken for each
type of interrupt
Middleware
Mobile operating systems often include not only a core kernel but also middleware—a set of software frameworks that provide additional services to application developers.
Minimalist Understanding of an Operating System
OS software is the minimum amount of software required to allow the computer to function.
kernel – usually in memory always
* process/thread management
* communications
* memory management
* file management
* security model
* device management
This is the understanding used in the course.
Maximalist Understanding of an Operating System
- All the software which comes with a standard release of the OS.
- many utilities and programs
This is the understanding that most people have about an OS.
Bus
Provides access between components and shared memory
Device Controller
Controller in charge of a specific type of device.
Depending on the controller, more than one device may be attached. A device controller maintains some local buffer storage and a set of special-purpose registers.
The device controller is responsible for moving the data between the peripheral devices that it controls and its local buffer storage.
Device Driver
Typically, operating systems have a device driver for each device controller. This device driver understands the device controller and provides the rest of the operating system with a uniform interface to the device.
The CPU and the device controllers can execute in parallel, competing for memory cycles. To ensure orderly access to the shared memory, a memory controller synchronizes access to the memory.
Multiprogramming (Batch System)
- Single program cannot always keep CPU and I/O devices busy
- Multiprogramming organizes jobs (code and data), so CPU always has one to execute
- A subset of total jobs in system is kept in memory
- One job selected and run via job scheduling
- When job has to wait (for I/O for example), OS switches to another job.
Multitasking (Timesharing)
- A logical extension of Batch systems – the CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing.
- Response time should be < 1 second
- Each user has at least one program executing in memory → process
- If several jobs ready to run at the same time → CPU scheduling
- If processes don’t fit in memory, swapping moves them in and out to run
- Virtual memory allows execution of processes not completely in memory
Dual-Mode Operation
Dual-mode operation allows OS to protect itself and other system components
* User mode and kernel mode
* Mode bit provided by hardware
* Provides ability to distinguish when system is running user code or kernel code.
* When a user is running → mode bit is “user”
* When kernel code is executing → mode bit is “kernel”
* System call changes mode to kernel, return from call resets it to user
* Some instructions designated as privileged, only executable in kernel mode.
Transition from User to Kernel Mode
User Process
|User mode (mode bit = 1)|
User process executing
↓
Calls System Call
↓ trap mode bit = 0
|Kernel mode (mode bit = 0)|
Execute the System Call
↓ return mode bit = 1
|User mode (mode bit = 1)|
Return from System Call
Interrupt
A hardware mechanism that enables a device to notify the CPU that it needs attention.
Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system bus.
MS-DOS
An operating system structure written to provide the most functionality in the least space
* not divided into modules
* Although MS-DOS had some structure, its interfaces and levels of
functionality were not well separated
MS-DOS Structure
Application Program
↓
Resident System Program
↓
MS-DOS Device Drivers
↓
ROM Device Drivers
Monolithic Structure - Original UNIX
UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring.
* The UNIX OS consists of two separable parts
* Systems programs
* The kernel
* Consists of everything below the system-call interface and above the physical hardware
* Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level
* Monolithic kernel - Pros/Cons
* little overhead in the system-call interface
* communication within the kernel is fast
* tightly coupled system – difficult to implement and extend.
Traditional UNIX System Structure
Shells and Commands
Compliers and Interpreters
System Libraries
—
System-Call Interface to the Kernel
—
Signals Terminal Handling, Character I/O System, Terminal Drivers, File System, Swapping Block I/O System, Disk and Tape Drivers, CPU Scheduling, Page Replacement, Demand Paging, Virtual Memory.
—
Kernel Interface to Hardware
—
Terminal Controllers | Device Controllers | Memory Controllers
—
Terminals | Disks and Tapes | Physical Memory
Layered Approach Operating System
A number of layers (levels) with specific and limited functionality, each built on top of lower layers.
* With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers
* Pros/Cons
* Simplifies verification and debugging
* Very hard to get the design correct
* Can be inefficient – lots of layers to go through to get work done.
Layered Approach Structure
- A layered design was first used in the “THE” operating system.
- Its six layers were:
Layer 5: User Programs
Layer 4: Buffering for I/O
Layer 3: Operator Console Device Driver
Layer 2: Memory Management
Layer 1: CPU Scheduling
Layer 0: Hardware
Microkernel
- Move as much from the kernel into user space
- Mach is an example of microkernel
- macOS and iOS kernel (Darwin) partly based on Mach
- Communication takes place between user modules using message passing
- Pros:
- Easier to extend a microkernel
- Easier to port the operating system to new architectures
- More reliable (less code is running in kernel mode)
- More secure
- Cons:
- Performance overhead of user space to kernel space communication
Microkernel Structure
Application Program | File System | Device Driver
↑ ↑ ↑
—
messages
↔ ⟷
Inter-process communication | Memory Management | CPU Scheduling
Microkernel
— ↕
Hardware
Windows NT Client / Server
- Windows NT provided environmental subsystems to run code written to different OS APIs.
- Windows NT (and successors) is a hybrid system.
- Parts are layered but some of the layers have been merged to improve performance.
- Many OS services are provided by user-level servers
- e.g. the environmental subsystems.
- Now in Windows 10/11 there is the Windows subsystem for Linux.
Windows NT Client / Server Structure
Win32 Application | Win32 Server | OS/2 Application | OS/2 Server | Posix Application|| Posix Application
—↑ ↑ ↑ ↑ ↑ ↑
↔ ↔ ↔
Kernel
(where each application server pair connects through the kernel)
Modules
- Many modern operating systems implement loadable kernel modules (LKMs)
- Uses object-oriented approach
- Each core component is separate
- Each talks to the others over known interfaces
- Each is loadable as needed within the kernel
- Overall, similar to layers but more flexible
- Linux, Solaris, etc.