CS330 - Operating Systems
Complete Edition with All Topics
An Operating System (OS) is a program that acts as an intermediary between computer users and computer hardware. It provides an environment in which a user can execute programs conveniently and efficiently.
The Kernel is "the one program running at all times on the computer"
The operating system's goals depend on the point of view:
Dual-mode operation allows OS to protect itself and other system components:
User Process (mode bit = 1)
Kernel (mode bit = 0)
Execute system call
The Operating System must protect the CPU from being taken over by a user program (e.g. in an infinite loop) using a Timer:
Question: If the kernel is single threaded, then any user level thread performing a blocking system call will:
The Von Neumann architecture consists of:
A general computer system consists of a group of modules (CPU, device controllers, memory & I/O devices) interconnected by a system bus.
Each device controller is in charge of a specific I/O device type
| Component | Function | Examples |
|---|---|---|
| CPU | Executes instructions | Intel Core i7, AMD Ryzen |
| Memory | Stores data and programs | RAM, Cache, Registers |
| I/O Devices | Interface with external world | Keyboard, Monitor, Disk |
| System Bus | Communication pathway | Address, Data, Control buses |
| Device Controllers | Manage specific device types | USB controller, Disk controller |
Multiprocessor systems (also known as parallel systems or tightly-coupled systems) are growing in use and importance.
Within the past several years, multiprocessor systems (also known as parallel systems or multicore systems) have begun to dominate the landscape of computing.
Like multiprocessor systems, but multiple systems working together
Has one machine in hot-standby mode monitoring the active server while the other is running the applications
Has multiple nodes running applications, monitoring each other
The bootstrap program is loaded at power-up or reboot:
Key Points about Interrupts:
Question: A table that points to routines that handle interrupts is called:
Slow devices like keyboards will generate an interrupt to the main CPU after each byte is transferred. If a fast device such as a disk generated an interrupt for each byte, the operating system would spend most of its time handling these interrupts. So a typical computer uses direct memory access (DMA) hardware to reduce this overhead.
Data Bus connects all components
| I/O Type | CPU Involvement | Interrupts | Best For |
|---|---|---|---|
| Programmed I/O | High (continuous) | None | Very slow devices |
| Interrupt-driven I/O | Medium | One per byte | Slow devices (keyboard) |
| DMA | Low (start/end only) | One per block | Fast devices (disk, network) |
| Storage Type | Capacity | Access Time | Cost/GB | Volatile? |
|---|---|---|---|---|
| Registers | < 1 KB | < 1 ns | Highest | Yes |
| Cache | 1-32 MB | 1-10 ns | Very High | Yes |
| RAM | 4-64 GB | 10-100 ns | High | Yes |
| SSD | 256 GB - 4 TB | 10-100 μs | Medium | No |
| HDD | 1-20 TB | 5-10 ms | Low | No |
Different OSs vary greatly internally but have many common features. The evolution of operating systems shows progression from simple batch systems to complex modern systems.
Multiprogramming needed for efficiency:
Timesharing (multitasking) is logical extension of multiprogramming:
Remember the key differences:
| Type | Characteristics | Examples | Use Cases |
|---|---|---|---|
| Batch OS | Groups similar jobs, No user interaction | IBM OS/360 | Payroll, Bank statements |
| Time-Sharing OS | Multiple users, Quick response time | Unix, Linux | General computing |
| Real-Time OS | Fixed time constraints, Predictable | VxWorks, RTLinux | Medical devices, Robotics |
| Distributed OS | Multiple CPUs, Resource sharing | Google's OS, Amoeba | Cloud computing |
| Mobile OS | Power efficient, Touch interface | Android, iOS | Smartphones, Tablets |
Question: A process cannot keep both CPU and I/O busy all time. The technique which is used to efficiently use CPU is:
Computing environments have evolved from traditional stand-alone systems to complex distributed and cloud-based systems.
Question: The controller uses _____ to help with the transfers when handling network interfaces.
System calls provide an interface between running program and the operating system. They are generally available as assembly language instructions.
Q1. Because of virtual memory, the memory can be shared among:
Q2. The bootstrap program is stored in:
Q3. Which of the following is NOT a goal of an operating system?
Q4. In symmetric multiprocessing:
Q5. Explain the difference between a program and a process. (5 marks)
Q6. List and briefly describe the four main components of Von Neumann architecture. (8 marks)
Q7. What are the advantages of multiprocessor systems? List at least three. (6 marks)
Q8. Explain the difference between symmetric and asymmetric multiprocessing. (6 marks)
Q9. A paging system with 32-bit logical addresses, 1 GB (2^30) main memory, and a 1 megabyte (20-bit) page size will have a page table that contains how many entries?
Page size = 2^20 bytes
Logical address space = 2^32 bytes
Number of pages = 2^32 / 2^20 = 2^12 = 4096 entries
Answer: 4,096 entries
| Term | Definition |
|---|---|
| Kernel | The one program running at all times on the computer; core part of the OS that runs in privileged mode and manages system resources |
| Shell | User interface to the operating system (can be CLI or GUI) |
| System Call | Programming interface to the services provided by the OS |
| Interrupt | Signal to the processor that an event needs immediate attention |
| Trap/Exception | Software-generated interrupt caused either by an error or a user request |
| Context Switch | Storing and restoring the state of a process so execution can resume later |
| Bootstrap Loader | Initial program stored in ROM/EPROM that loads the OS kernel into memory |
| Firmware | Software stored in ROM or EPROM, includes bootstrap program |
| Device Controller | Hardware that manages a specific type of device |
| Device Driver | Software that provides interface between OS and device controller |
| DMA | Direct Memory Access - allows devices to transfer data directly to memory without CPU intervention |
| Dual-mode Operation | Hardware support for differentiating between user mode and kernel mode execution |
| Mode Bit | Hardware bit that indicates current mode: kernel (0) or user (1) |
| Privileged Instructions | Instructions that can only be executed in kernel mode |
| Multiprogramming | Technique to maximize CPU utilization by keeping multiple programs in memory |
| Time-sharing | Logical extension of multiprogramming where CPU switches rapidly between users |
| SMP | Symmetric Multiprocessing - all processors are peers and perform all OS tasks |
| Clustered System | Multiple systems working together, usually sharing storage via SAN |