- Authors

- Name
- Youngju Kim
- @fjvbn20031
What is an Operating System
An operating system (OS) is software that manages computer hardware and provides an execution environment for application programs. It acts as an intermediary between the user and the hardware.
Four Components of a Computer System
A computer system consists of four major components.
- Hardware: Provides basic resources such as CPU, memory, and I/O devices
- Operating System: Controls hardware and coordinates resources among application programs
- Application Programs: Word processors, compilers, web browsers, etc., that solve user problems
- Users: People, other machines, or other computers
Roles of the Operating System
An operating system can be defined from two perspectives.
- Resource Allocator: Manager of all resources including CPU time, memory space, storage devices, and I/O devices
- Control Program: Controls program execution to prevent errors and improper use
In a more universal definition, the operating system is the one program running at all times on the computer, called the kernel.
Computer System Organization
Interrupts
An interrupt is a mechanism for hardware to notify the CPU that an event has occurred. When an I/O device completes an operation, it sends a signal to the CPU through an interrupt.
[Interrupt Handling Process]
1. I/O device completes operation
2. Device controller raises interrupt signal
|
v
3. CPU suspends current operation
4. Saves current state (PC, registers) to stack
|
v
5. Looks up ISR address through interrupt vector
6. Executes ISR (Interrupt Service Routine)
|
v
7. Restores saved state
8. Resumes interrupted operation
The types of interrupts are as follows.
- Hardware Interrupts: Triggered by I/O devices, timers, etc.
- Software Interrupts (Traps): Triggered by errors (division by zero) or system calls
// Interrupt vector table conceptual diagram
// Stores ISR addresses corresponding to each interrupt number
typedef void (*isr_handler_t)(void);
isr_handler_t interrupt_vector_table[256];
// Interrupt number 0: Division by zero exception
// Interrupt number 1: Debug exception
// Interrupt number 14: Page fault
// ...
// Interrupt numbers 32~255: User-defined (I/O devices, etc.)
void handle_interrupt(int interrupt_number) {
// Find and execute handler from interrupt vector
isr_handler_t handler = interrupt_vector_table[interrupt_number];
if (handler != NULL) {
handler();
}
}
Storage Device Hierarchy
Storage devices form a hierarchy based on speed, cost, and volatility.
[Storage Device Hierarchy]
Fast / Expensive / Small
+-----------+
| Registers | < 1ns
+-----------+
| Cache (L1) | ~1ns
+-----------+
| Cache (L2) | ~4ns
+-----------+
| Cache (L3) | ~10ns
+-----------+
| Main Memory| ~100ns (Volatile)
+-----------+
| SSD | ~100us (Non-volatile)
+-----------+
| HDD | ~10ms
+-----------+
Slow / Cheap / Large
Caching is a technique that temporarily copies data from slower storage to faster storage. When the same data is accessed again, it is read from the faster storage, improving performance.
I/O Structure
I/O operations are performed through interactions between the CPU and device controllers.
- Programmed I/O: CPU directly transfers data byte by byte (inefficient)
- Interrupt-driven I/O: Device notifies CPU via interrupt when ready
- DMA (Direct Memory Access): For bulk data transfers, device controller accesses memory directly without CPU intervention
[DMA Operation Process]
CPU DMA Controller Memory
| | |
|-- DMA transfer request -->| |
| (source, dest, size) | |
| |--- Data transfer ->|
| |--- Data transfer ->|
| |--- Data transfer ->|
|<-- Transfer complete int -| |
| | |
Computer System Architecture
Multiprocessor Systems
Most modern computers are multiprocessor systems. The advantages are as follows.
- Increased Throughput: N processors improve processing speed (but not by N times)
- Economy of Scale: More cost-effective than multiple single-processor systems
- Increased Reliability: If one fails, the overall system continues to operate (graceful degradation)
There are two types of multiprocessor systems.
- Asymmetric Multiprocessing (AMP): One master processor controls the system, and the rest follow instructions
- Symmetric Multiprocessing (SMP): Each processor performs OS functions on an equal basis
[SMP Architecture]
CPU 0 CPU 1 CPU 2
[Registers] [Registers] [Registers]
[Cache] [Cache] [Cache]
| | |
+------+------+------+------+
| |
[Shared Memory] [I/O System]
Multicore Systems
A multicore processor contains multiple cores on a single chip. Since they communicate within the same chip, it is faster than communication between separate processors and consumes less power.
[Multicore Processor Structure]
+--------------------------------------+
| Single CPU Chip |
| +--------+ +--------+ +--------+ |
| | Core 0 | | Core 1 | | Core 2 | |
| |[L1Cache]| |[L1Cache]| |[L1Cache]| |
| +--------+ +--------+ +--------+ |
| +----------+ |
| | L2 Cache | |
| +----------+ |
+--------------------------------------+
|
[Main Memory]
NUMA (Non-Uniform Memory Access)
When the number of CPUs increases, the system bus becomes a bottleneck. NUMA solves this problem by providing each CPU with its own local memory.
[NUMA Architecture]
+------------------+ Interconnect +------------------+
| Node 0 |<================>| Node 1 |
| CPU 0 CPU 1 | | CPU 2 CPU 3 |
| [Local Memory 0] | | [Local Memory 1] |
+------------------+ +------------------+
Local memory access: Fast (~100ns)
Remote memory access: Slow (~300ns)
Operating System Operations
Dual-Mode Operation
The OS must protect the system from erroneous user program behavior. To this end, it provides two execution modes.
- User Mode: Application program execution. Privileged instructions cannot be executed
- Kernel Mode: OS code execution. All instructions can be executed
[Mode Transition Process]
User Mode Kernel Mode
| |
|-- System call invocation -------->|
| (trap occurs, mode bit 0) |
| |-- System call processing
| |
|<-- System call return ------------|
| (mode bit restored to 1) |
| |
// System call example: File read
// Calling read() from a user program
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main() {
char buffer[1024];
// open() transitions to kernel mode via system call
int fd = open("data.txt", O_RDONLY);
// read() is also a system call - kernel performs I/O
ssize_t bytes = read(fd, buffer, sizeof(buffer));
printf("Bytes read: %zd\n", bytes);
close(fd);
return 0;
}
Timer
A timer prevents a program from monopolizing the CPU. After a set period, it generates an interrupt to return control to the OS.
- Fixed timer: Generates interrupts at regular intervals
- Variable timer: Implemented with a fixed clock + counter. Generates an interrupt when the counter reaches 0
Resource Management
Process Management
A process is a program in execution. The OS performs the following tasks.
- Process creation and deletion
- Process suspension and resumption
- Providing process synchronization mechanisms
- Providing inter-process communication (IPC) mechanisms
- Providing deadlock handling mechanisms
Memory Management
Main memory is the only large storage directly accessible by the CPU. The OS manages the following.
- Tracks which parts of memory are in use and by whom
- Decides which processes and data to load into and remove from memory
- Allocates and deallocates memory space as needed
Storage Management
The OS abstracts the physical characteristics of storage devices to provide the logical concept of files.
- File System Management: File creation/deletion, directory management, access control
- Mass Storage Management: Disk scheduling, free space management, storage allocation
- Caching: Keeping frequently accessed data in faster storage
I/O Subsystem
The OS I/O subsystem hides the differences between hardware devices.
- Buffering: Temporarily stores data during transfer
- Caching: Maintains copies of frequently used data
- Spooling: Stores output for devices like printers in a queue
Protection and Security
- Protection: Mechanisms for controlling process/user access to resources defined by the OS
- Security: Defense against external or internal attacks. Includes authentication, authorization, auditing, etc.
Each user is assigned a unique ID (UID), and group-level access control is also possible through group IDs (GID). Privilege escalation is a mechanism for temporarily gaining higher privileges, implemented in Unix through the setuid bit.
Summary
[Operating System Key Concepts Summary]
+------------------------------------------+
| Application Programs |
+------------------------------------------+
| Operating System (Kernel) |
| +------+ +--------+ +--------+ +------+ |
| |Process| |Memory | |File | |I/O | |
| |Mgmt | |Mgmt | |System | |Mgmt | |
| +------+ +--------+ +--------+ +------+ |
+------------------------------------------+
| Hardware |
| CPU / Memory / Disk / I/O Devices |
+------------------------------------------+
The operating system is essential software that manages resources between hardware and users, provides a program execution environment, and protects the system. It leverages hardware support such as dual-mode operation, interrupts, and timers to ensure safe and efficient system operation.