Principles of Operating Systems: Introduction & Background (Part 02)
Welcome to the second Part on the Principles of Operating Systems! In this comprehensive article, we delve deeper into the fundamental concepts that define operating systems, their functions, services, and the various types that power our digital world. Building upon our previous discussion, we’ll explore the intricate relationship between hardware and software, the role of the operating system as a resource manager, and the essential services that make modern computing possible.
Topics Covered in This Lecture
- What is an Operating System?
- Functions and Services of OS
- Types of Operating Systems
- Computing Environments
- Kernel Data Structures
- Computer System Organization
- Storage Hierarchy
- User Interfaces (CLI, GUI, Touchscreen)
- Process Management
- Memory Management
- File System Management
- Mass-Storage Management
- Protection and Security
What is an Operating System? – A Deeper Look
No Universally Accepted Definition
The concept of an operating system is fluid and varies depending on who you ask. Here are some perspectives:
| Perspective | Definition |
|---|---|
| Vendor’s View | “Everything a vendor ships when you order an operating system” – but this varies wildly between vendors |
| Kernel View | “The one program running at all times on the computer” – the kernel, which is part of the operating system |
| System Program View | System programs that ship with the OS but are not part of the kernel |
| Application Program View | All programs not associated with the operating system |
Modern OS Components
Today’s operating systems for general-purpose and mobile computing also include middleware – a set of software frameworks that provide additional services to application developers, such as:
- Databases
- Multimedia frameworks
- Graphics libraries
- Networking protocols
The Digital Control Room: OS as Conductor
The Hardware Baseline
The computer system consists of:
- One or more CPUs
- Device controllers
- Common bus providing access to shared memory
- Concurrent execution of CPUs and devices competing for memory cycles
The Inherent Tension
When multiple components are simultaneously fighting for the same memory and computing power, the question arises: Who orchestrates the chaos?
Answer: The Operating System acts as the conductor. Without a conductor, the instruments simply make noise.
Functions of the Operating System
1. Resource Manager
The OS manages hardware and software resources including:
- CPU and memory
- I/O devices
- Registers
- Device drivers
- Semaphores
- Mutexes
2. Control Program
The OS controls the execution of programs to prevent errors and improper use of the computer.
3. Set of Utilities
The OS provides tools to simplify application development.
4. Government Metaphor
The OS acts like a government, managing resources, resolving conflicts, and providing services.
Computer System Organization
System Operation Components
| Component | Description |
|---|---|
| CPU | Central Processing Unit – executes instructions |
| Device Controllers | Manage specific devices (disk, network, etc.) |
| Common Bus | Provides shared memory access |
| Registers | Small, fast storage locations within the CPU |
Block Diagram of the Control Unit
The Control Unit coordinates the sequence of data movements and performs several critical functions:
Functions of the Control Unit
- Coordinates sequence of data movements into, out of, and between a processor’s sub-units
- Interprets instructions
- Controls data flow inside the processor
- Receives external instructions and converts them to control signals
- Controls execution units (ALU, data buffers, registers)
- Handles multiple tasks: fetching, decoding, execution handling, and storing results
Types of Control Units
| Type | Description |
|---|---|
| Hardwired Control Unit | Uses fixed hardware circuits for control signals |
| Microprogrammable Control Unit | Uses microprogramming to generate control signals |
Storage Hierarchy
Characteristics of Various Types of Storage
| Level | Name | Typical Size | Implementation Technology | Access Time (ns) | Bandwidth (MB/sec) | Managed By | Backed By |
|---|---|---|---|---|---|---|---|
| 1 | Registers | < 1 KB | Custom memory with multiple ports | 0.25-0.50 | 20,000-100,000 | Compiler | Cache |
| 2 | Cache | < 16 MB | CMOS on-chip or off-chip SRAM | 0.5-25 | 5,000-10,000 | Hardware | Main Memory |
| 3 | Main Memory | < 64 GB | CMOS SRAM | 80-250 | 1,000-5,000 | Operating System | Disk |
| 4 | Solid-State Disk | < 1 TB | Flash Memory | 25,000-50,000 | 500 | Operating System | Disk |
| 5 | Magnetic Disk | < 10 TB | Magnetic Disk | 5,000,000 | 20-150 | Operating System | Disk or Tape |
Note: Movement between levels of storage hierarchy can be explicit or implicit.
What Operating Systems Do – Different Perspectives
User Perspective
| User Type | Expectations |
|---|---|
| General Users | Convenience, ease of use, good performance |
| Shared Computer Users | Fair resource allocation, responsiveness |
| Dedicated System Users | Dedicated resources, but may use shared resources |
| Mobile Device Users | Optimized for usability and battery life |
| Embedded Systems | Run primarily without user intervention |
System Perspective
- Resource Allocator: Efficient use of hardware resources
- Control Program: Managing execution of user programs
- Efficiency: Optimal resource utilization
- Convenience: User-friendly interfaces
- Robustness: System stability and fault tolerance
- Reliability: Consistent and dependable operation
- Scalability: Ability to grow with demands
- Portability: Working across different hardware platforms
Operating System Services
User-Oriented Services
| Service | Description |
|---|---|
| User Interface | CLI, GUI, touch-screen, or batch interface |
| Program Execution | Load programs into memory and execute them |
| I/O Operations | Handle input/output operations for running programs |
| File-System Manipulation | Read, write, create, delete files and directories |
| Communications | Exchange information between processes (shared memory or message passing) |
| Error Detection | Constant awareness of errors and appropriate handling |
System-Oriented Services
| Service | Description |
|---|---|
| Resource Allocation | Allocate CPU cycles, memory, file storage, I/O devices |
| Logging | Track user resource usage |
| Protection | Control access to system resources |
| Security | User authentication, defense against external attacks |
User Operating System Interfaces
1. Command Line Interface (CLI)
| Feature | Description |
|---|---|
| Direct Command Entry | Users type commands directly |
| Implementation | Sometimes in kernel, sometimes as system program |
| Flavors | Multiple shells available |
| Function | Fetches and executes user commands |
| Extensibility | Adding new features doesn’t require shell modification |
Example CLI Session:
text
[root@r6181-d5-us01 ~]# uptime 06:57:48 up 16 days, 10:52, 3 users, load average: 129.52, 80.33, 56.55 [root@r6181-d5-us01 ~]# df -kh Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_ks-1v_root 50G 19G 28G 41% / tmpfs 127G 520K 127G 1% /dev/shm /dev/sda1 477M 71M 381M 16% /boot
2. Graphical User Interface (GUI)
| Feature | Description |
|---|---|
| Metaphor | User-friendly desktop metaphor |
| Interaction | Mouse, keyboard, and monitor |
| Icons | Represent files, programs, actions |
| Origins | Invented at Xerox PARC |
| Examples | Microsoft Windows, Mac OS X, Linux (CDE, KDE, GNOME) |
3. Touchscreen Interfaces
| Feature | Description |
|---|---|
| Gesture-Based | Actions and selection based on gestures |
| Virtual Keyboard | Text entry via on-screen keyboard |
| Voice Commands | Speech recognition for commands |
Process Management
The operating system is responsible for the following activities in connection with process management:
| Activity | Description |
|---|---|
| Creating Processes | Creating and deleting both user and system processes |
| Suspending/Resuming | Suspending and resuming processes |
| Synchronization | Providing mechanisms for process synchronization |
| Communication | Providing mechanisms for process communication |
| Deadlock Handling | Providing mechanisms for deadlock handling |
Memory Management
Purpose of Memory Management
- To execute a program, all (or part) of the instructions must be in memory
- All (or part) of the data needed by the program must be in memory
- Optimizing CPU utilization and computer response to users
Memory Management Activities
| Activity | Description |
|---|---|
| Tracking | Keeping track of which parts of memory are currently being used and by whom |
| Decision Making | Deciding which processes (or parts thereof) and data to move into and out of memory |
| Allocation | Allocating and deallocating memory space as needed |
File-System Management
Logical View of Storage
The OS provides a uniform, logical view of information storage by abstracting physical properties to a logical storage unit called a file.
Medium Characteristics
| Property | Examples |
|---|---|
| Access Speed | Varies by medium |
| Capacity | Varies by medium |
| Data-Transfer Rate | Varies by medium |
| Access Method | Sequential or random |
File-System Management Activities
| Activity | Description |
|---|---|
| Creating/Deleting | Creating and deleting files and directories |
| Manipulation | Primitives to manipulate files and directories |
| Mapping | Mapping files onto secondary storage |
| Backup | Backup files onto stable storage media |
| Access Control | Determining who can access what |
Mass-Storage Management
Importance
- Disks store data that doesn’t fit in main memory or must be kept for extended periods
- Entire speed of computer operation hinges on disk subsystem and its algorithms
OS Activities for Mass-Storage Management
| Activity | Description |
|---|---|
| Mounting/Unmounting | Managing file system mounting |
| Free-Space Management | Tracking and managing free space on storage devices |
| Storage Allocation | Allocating storage space to files |
| Disk Scheduling | Optimizing disk access requests |
| Partitioning | Dividing disks into logical partitions |
| Protection | Controlling access to storage devices |
Protection and Security
Protection
Definition: Any mechanism for controlling access of processes or users to resources defined by the OS.
Security
Definition: Defense of the system against internal and external attacks.
Security Threats
| Threat Type | Examples |
|---|---|
| Denial-of-Service | Overwhelming system resources |
| Malware | Worms, viruses |
| Identity Theft | Stealing user credentials |
| Theft of Service | Unauthorized use of system resources |
User Identification
| Concept | Description |
|---|---|
| User ID | User identity includes name and associated number, one per user |
| Group ID | Allows set of users to be defined and controls managed |
| Privilege Escalation | Allows user to change to effective ID with more rights |