This set of notes is about the concepts and implementation details of operating system. This set of notes mainly cope with the course COMP3111 in HKUST. The main sections are:
- Operating System Structure
- Process Concept
- Threads Concept
- Process Scheduling
- Synchronization
- Deadlocks
Computer System Structure
- Hardware
- Operating System
- System and Application Programs
- Users
Computer Startup
Bootstrap program stored in firmware (ROM or EEPROM)
- Initializes all aspect of the system
- Loads operating system kernel
- Load system processes or system daemon
UNIX's first process is "init"
Computer Organization and Operation
Concurrent execution of CPUs and device controller, completing for the memory access
Each device controller has local buffer
CPU moves data across memory and local buffers
I/O is from device to local buffer
Device controller generate interrupt when operation finished
Interrupt
Interrupt transfer control to interrupt service routine, through interrupt vector
Interrupt vector contains addresses of different interrupt service routine for different interrupts
Trap/Exception
Software-generated interrupt
Direct Memory Access
Device controller can access main memory directly without CPU intervention
Storage Hierarchy
- Cache
- Main Memory
- Secondary Storage
- Magnetic Disks
- Optical Disks
- Magnetic Tapes
Caching
Improve CPU performance by reducing memory access time
Main Function of OS
Resource Allocator
User Convenience
OS Structure
Multiprogramming (job scheduling)
Timeshare Multitasking
Dual-Mode
Kernel mode for privileged instruction
User mode for normal execution
Determined by mode bit
Timer
Generate interrupt over time
Ensure OS can get control over CPU back
Multiprocessor System
Two processors share same computer bus, main memory, devices
Advantages:
- Increased Throughput
- Economy of Scale
- Increased Reliability
Asymmetric Multiprocessing
One master CPU distribute jobs to slave CPUs
Symmetric Multiprocessing (SMP)
Each CPU ahs own set of registers and cache, sharing the same main memory
Uniform Memory Access (UMA)
Memory access time of CPUs are same
Non-uniform Memory Access (NUMA)
Memory access time of CPUs can be different
Multicore
Multiple computing core in a single chip
Faster in terms of communication and less power consumption
Clustered System
Compute nodes are loosely coupled
Share storage via Storage-area Network
Provide high-availability
Asymmetric Clustering: One machine on hot-standby mode
Symmetric Clustering: Multiple nodes running applications, monitoring each other
High-performance computing: parallelization of running of some applications
Distributed Lock Manager (DLM): Deal with synchronization problem in clustering
Protection
Access control of users and processes to resources
Security
Defend against internal or external attacks
Computing Environment
- Traditional
- Mobile
- Distributed
- Client-Server
- Peer-to-Peer
- Virtualization
- Cloud Computing
- Real-Time Embedded System
Open Source OS
- Darwin (kernel of MacOS)
- Linux
- BSD UNIX
- Sun Solaris