Introduction 1
Overview
- “Defining“ operating systems
- What is multi-programming
- Kernel-user mode
Defining Operating Systems
In the early days, programmers had to deal directly with hardware
- Real computer hardware is urgly
- Hardware is extremely difficult to program
An operating system is a layer[层] of indirection[间接] on top of the hardware:
- It provide abstractions for application programs
- it provide a cleaner and easier interface to the hardware
Multi-programming
- Morden OS use multi-programming to improve user experience and maximise the use of resource
- Disk is slow. CPU is faster than disk.
- Without multi-programming, CPU time is waste while wating for I/O requests.
- Multi-programming has important consequences[结果] for operating system design
- The operating system must allocate[分配]/share resources (CPU, memory, I/O devices) fairly and safely between competing processes:
- In time, e.g. CPUs and printers
- In space, e.g., memory and disks
- The execution of multiple programs (processes) needs to be interleaved[交错] with one another. This requires:
- This requires context switches and process scheduling ⇒ mutual exclusion[相互排斥], deadlock avoidance, protection, . . .
Kernel-user mode
- Modern operating systems have multiple modes:
- The operating system runs in kernel mode and has access to all instructions
- Applications run in user mode and have access to a subset of instructions
- Transitions from user mode to kernel mode happen in a controlled manner (interrupts, exceptions, system calls) and are mirrored in hardware
Summary
- Some properties:
- Sits directly on top of the hardware
- Has access to the full capabilities of the hardware
- Provides abstractions for the user/programmer
- Makes sure that everything is organised and runs in order
- Improve the hardware interface