1 introduction

1.1 overview

Operating system (OP) is something that:

1.1.1 structure

  1. computer hardware: CPU, memory, IO devices
  2. operating system: see above
  3. program: instructions defining the way in which the system resources are used to solve the computing problems of the users
  4. users: people, other computers

1.1.2 multiprogramming

OP has to schedule jobs to evenly distribute work across CPU cores:

1.1.3 timesharing (multitasking)

When the CPU switches the jobs very frequently making it feel like multiple jobs are running simultaneously. If processes use more memory than available, swapping moves them in and out between memory and swap memory (swap file/swap partition).

1.1.4 real-time (RT) systems

Systems with a rigid time requirement

1.1.4.1 hard RT systems

1.1.4.2 soft RT systems

1.1.5 interface

1.1.6 concurrent resource usage

Jobs have access to shared resources only indirectly - through system calls (syscall). Often implemented through some system function to form an interface between OP and user programs.

Multiprogramming and timesharing. Concurrent resource use is implemented with:

1.1.6.1 symmetric multiprocessing (SMP)

CPUs share the whole system

1.1.6.2 asymmetric multiprocessing (SMP)

One master and many slave (workers) CPUs

1.1.7 syscall API

Example scenario with C’s printf() (POSIX environment)

1.1.8 structure

1.1.8.1 simple system: MS-DOS

1.1.8.2 monolithic system

1.1.8.3 microkernel system

pros cons
easier to extend with new functionality performance overhead because of kernel-user space communication
easier to port to new architectures
less code runs in kernel mode thus more secure and reliable

1.1.8.4 hybrid system

One that uses approaches from different system structures to address the specific problems it is trying to solve.

For example:

1.1.9 kernel modules

Each core component is separate and loadable.

1.2 operation

1.2.1 interrupts

Interrupts inform the OS that attention is needed and something has to be immediately executed. Interrupts can be cause by hardware (IO devices), software, or CPU traps (like error).

Interrupts are disabled when a different interrupt is being processed to prevent lost interrupts.

Operating systems are interrupt driven

1.2.1.1 handling

1.2.2 IO

1.2.3 direct memory access (DMA)

Device transfers its buffer straight to memory without CPU intervention.

1.2.4 storage

disk storage (ROM) \implies main memory (RAM) \implies cache \implies registers

registers cache RAM ROM
size < 1 KB > 16 MB > 16 GB > 100 GB
access time [ns] 0.25-0.5 0.5-25 80-250 5,000,000
bandwidth [MB/s] 20,000-100,000 5,000-10,000 1,000-5,000 20-150

1.2.5 modes