Here is a summary of the provided sources on operating systems:
The sources define an operating system (OS) as the **infrastructure software**
component responsible for managing and coordinating computer activities and
resources. It acts as a **host for applications**, abstracting hardware details.
Operating systems can be viewed as **resource managers** (managing system parts
efficiently) or **extended machines** (providing a more convenient virtual
machine).
### Historical Development of Operating Systems
Operating systems have evolved through distinct phases:
- **First Generation (1940s)**: Earliest computers had **no operating systems**.
Programs were manually entered one bit at a time.
- **Second Generation (1950s)**: Improved with **punch cards**, and the **first
operating systems** were implemented by General Motors for the IBM 701. These were
**single-stream batch processing systems**, running one job at a time.
- **Third Generation (1960s)**: Introduced **multiprogramming**, allowing several
jobs to be in main memory simultaneously, sharing the CPU to keep peripheral
devices in use. Other key features included **spooling** (using a high-speed device
like a disk to buffer I/O operations, making programs run faster) and **time-
sharing** (a multiprogramming variant for numerous simultaneous interactive users,
requiring quick responses).
- **Fourth Generation**: Marked by Large Scale Integration (LSI) circuits and the
advent of personal computers. **MS-DOS** and **UNIX** became the dominant operating
systems.
### Objectives of Operating Systems
Modern OS primarily aim to:
- **Hide hardware details by creating abstraction**: This involves transforming
physical hardware into a virtual world using higher-level functions like **device
drivers**, **file abstraction**, and presenting multiple **virtual computers**
(processes). This also enables security enforcement.
- **Allocate resources to processes**: Controlling how active programs (processes)
access system resources.
- **Provide a pleasant and effective user interface**: This includes components
like the command interpreter, file system, on-line help, and increasingly
integrated graphical user interfaces (GUIs).
### How an Operating System Works
When a computer powers on, a **power-on self test (POST)** from the ROM checks
hardware. Then, a **bootstrap loader** (typically on the hard disk) loads the
operating system into memory, sets up drivers, memory divisions, and data
structures, finally handing control to the OS.
### Types of Operating Systems
Operating systems are categorized based on their control and application support:
- **Real-time operating system (RTOS)**: Used for machinery and industrial systems
where precise, consistent timing of operations is critical, often with minimal user
interfaces.
- **Single-user, single-task operating system**: Designed for one user to perform
one task at a time (e.g., Palm OS).
- **Single-user, multi-tasking operating system**: Allows a single user to run
several programs concurrently (e.g., Microsoft Windows, Apple MacOS).
- **Multi-user operating system**: Enables many different users to simultaneously
utilize computer resources, balancing their needs (e.g., Unix, VMS).
### Functions of Operating Systems
Major functions include **processor management**, **memory management**,
**input/output management**, and **file management**. Other functions involve
establishing priority systems, automating job transitions, interpreting commands,
coordinating software, and ensuring data security and integrity.
### Operating System Concerns
Errors in operating system code can lead to **system crashes and instabilities**,
**security flaws** allowing unauthorized access, and **incompatibility with
peripheral devices**.
### Processes and Threads
**Processes**
- A process is primarily defined as a **program in execution** and represents the
unit of work in a system. Conceptually, each process has its own virtual CPU, with
the actual CPU rapidly switching among processes (**multiprogramming**).
- **Process States**: A process transitions through five discrete states:
- **New**: The process is being created.
- **Ready**: The process is runnable but temporarily halted, waiting for a CPU.
- **Running**: The process is currently using the CPU.
- **Blocked (waiting)**: The process is waiting for an external event (e.g.,
I/O completion) and cannot run even if a CPU is available.
- **Terminated**: The process has finished execution.
- **Processing Modes**:
- **Batch Processing**: Jobs are grouped and run sequentially without minute-
by-minute human interaction. Benefits include **sharing computer resources**,
shifting processing to off-peak times, **avoiding human-induced delays**, and
better amortizing computer costs.
- **Time Sharing**: Developed from the realization that while individual users
have idle times, a group of users working simultaneously can keep the CPU busy. It
supports multiple interactive users by quickly switching between their programs'
states.
**Threads**
- A **thread** is a **single sequence stream within a process**, often called a
**lightweight process**. Threads allow multiple execution streams within a process,
improving parallelism.
- Threads are used to create **efficient servers** (e.g., printer servers),
facilitate **common data sharing** without interprocess communication, and leverage
**multiprocessors**.
- **Similarities and Differences between Processes and Threads**:
- **Similarities**: Both share the CPU (one active at a time), execute
sequentially within their context, can create children, and if one is blocked,
another can run.
- **Differences**: Threads are **not independent**, all threads within a task
can **access every address**, and threads are designed to **assist one another**
(unlike processes, which may originate from different users).
### Process Scheduling
- **Processor scheduling** (or CPU scheduling) involves deciding when and which
processes should be assigned the CPU. The **scheduler** in the OS uses a
**scheduling algorithm** for this task.
- **Goals of Scheduling** include **fairness**, **policy enforcement**,
**efficiency** (keeping the CPU busy), minimizing **response time** for interactive
users, minimizing **turnaround time** for batch users, and maximizing
**throughput** (jobs processed per unit time).
- **Preemptive vs. Nonpreemptive Scheduling**:
- **Nonpreemptive**: Once a process gets the CPU, it **cannot be taken away**
until it completes or blocks.
- **Preemptive**: The CPU **can be taken away** from a running process,
allowing it to be temporarily suspended.
- **Scheduling Algorithms**:
- **First-Come-First-Served (FCFS)**: The simplest, **nonpreemptive**
algorithm; processes are dispatched by arrival time and run to completion. It's
simple to implement but can lead to **long average waiting times** and poor
interactive response.
- **Shortest-Remaining-Time (SRT)**: A **preemptive** version of SJF, it runs
the process with the smallest estimated time to completion, including new arrivals.
- **Shortest-Job-First (SJF)**: A **non-preemptive** algorithm that selects the
waiting job with the smallest estimated run-time. It is optimal for minimizing
average waiting time but requires **advance knowledge of run times**, which is a
significant drawback.
- **Round Robin (RR)**: An old, widely used **preemptive** algorithm where
processes are dispatched FIFO but given a limited **time-slice (quantum)**. If a
process doesn't finish, it's preempted and moved to the back of the queue. The
**length of the quantum is crucial**: too short causes excessive context switches;
too long approximates FCFS.
- **Multilevel Feedback Queue Scheduling**: Uses multiple ready queues with
different priorities, allowing processes to move between queues. It prevents
**starvation** by aging processes (moving long-waiting processes to higher
priority).
### Interrupts, Virtual Memory, and Virtual Machine
**Interrupts**
- An **interrupt** is an **asynchronous hardware signal** or **synchronous software
event** that prompts the processor to save its state (context switch) and execute
an **interrupt handler**. This mechanism avoids polling loops and makes systems
**interrupt-driven**.
- A **precise interrupt** has well-defined properties regarding the Program Counter
(PC) and instruction execution state. An **interrupt storm** occurs when excessive
time is spent handling interrupts, hindering system performance.
- **Interrupt Handlers (ISR)** are divided into:
- **First-Level Interrupt Handler (FLIH)**: Quickly services the interrupt or
records critical information, then schedules a SLIH.
- **Second-Level Interrupt Handler (SLIH)**: Completes longer interrupt
processing tasks.
**Virtual Memory and Virtual Machine**
- **Virtual Memory**: A technique that provides application programs with the
**illusion of contiguous working memory (address space)**, even if it is physically
fragmented or extends to disk storage, simplifying programming and improving memory
efficiency.
- **Virtual Machine**: A **software implementation of a machine** that executes
programs like a real one, providing services that take the place of an OS or
hardware (e.g., Java Runtime Environment).
- **System virtual machine**: Runs a complete operating system.
- **Process virtual machine**: Runs a single program. Software within a virtual
machine is **limited to the resources and abstractions provided by the VM**.