All Study Guides Operating Systems Unit 1
🖲️ Operating Systems Unit 1 – Introduction to Operating SystemsOperating systems are the backbone of modern computing, acting as intermediaries between hardware and software. They manage resources, provide user interfaces, and enable applications to run smoothly. This unit explores the core components, functions, and types of operating systems.
From process management to file systems, operating systems handle complex tasks behind the scenes. Understanding their architecture, memory management, and user interfaces is crucial for grasping how computers function and how to optimize their performance.
What's an Operating System Anyway?
Serves as an interface between computer hardware and software applications
Manages and coordinates computer resources (CPU, memory, storage, I/O devices)
Provides a platform for running applications and executing user commands
Ensures efficient utilization of system resources by allocating them to processes
Handles low-level tasks (memory management, process scheduling, file system operations)
Provides a layer of abstraction, hiding hardware complexities from users and developers
Enables multiple applications to run concurrently on a single computer system
Maintains system stability, security, and performance through various mechanisms
Key Components of an OS
Kernel: Core component that manages system resources and facilitates communication between hardware and software
Runs in privileged mode with full access to hardware
Handles process scheduling, memory management, and I/O operations
Device Drivers: Software modules that enable the OS to communicate with and control hardware devices
Provide a standardized interface for accessing devices (keyboards, mice, printers, network adapters)
Translate OS commands into device-specific instructions
File System: Component responsible for organizing, storing, and retrieving data on storage devices
Defines a logical structure for storing files and directories
Handles file creation, deletion, reading, and writing operations
User Interface: Provides a means for users to interact with the OS and applications
Can be a command-line interface (CLI) or graphical user interface (GUI)
Accepts user input and displays output from the system and applications
System Libraries: Collection of pre-compiled code modules that provide common functions to applications
Offer a consistent API for developers to utilize OS features and services
Shell: Interprets user commands and executes corresponding system functions or applications
Can be a command-line shell (Bash, PowerShell) or graphical shell (Windows Explorer, macOS Finder)
How Operating Systems Manage Resources
Process Management: OS allocates CPU time to processes using scheduling algorithms
Creates and terminates processes as needed
Assigns priorities to processes based on their importance and resource requirements
Memory Management: OS controls the allocation and deallocation of main memory (RAM) to processes
Employs techniques like paging and segmentation to optimize memory usage
Implements virtual memory to extend the available memory beyond physical RAM
I/O Management: OS manages input/output operations between processes and devices
Schedules and prioritizes I/O requests to ensure fair access to shared resources
Buffers data to minimize the impact of slow I/O devices on system performance
File System Management: OS organizes and manages files and directories on storage devices
Allocates disk space to files and keeps track of their locations
Enforces file access permissions and handles file sharing among processes
Network Management: OS facilitates communication between processes on different computers over a network
Implements network protocols (TCP/IP) and manages network connections
Provides APIs for developers to create network-aware applications
Types of Operating Systems
Batch Operating Systems: Designed to process a series of jobs (batches) without user interaction
Jobs are submitted to a queue and executed sequentially by the OS
Suitable for tasks that do not require real-time user input (data processing, scientific simulations)
Time-Sharing Operating Systems: Allow multiple users to share computer resources simultaneously
Allocate CPU time to each user in small time slices, creating the illusion of concurrent execution
Enable interactive computing and remote access to shared resources
Distributed Operating Systems: Manage resources across multiple interconnected computers
Provide a unified view of distributed resources, making them appear as a single system
Facilitate resource sharing, load balancing, and fault tolerance across nodes
Real-Time Operating Systems (RTOS): Designed to meet strict deadlines for time-critical applications
Prioritize tasks based on their timing constraints and deterministic behavior
Used in embedded systems (automobiles, industrial control, medical devices)
Mobile Operating Systems: Optimized for mobile devices (smartphones, tablets)
Designed to be energy-efficient and adapt to limited screen sizes and input methods
Provide a touch-friendly user interface and support mobile-specific features (GPS, accelerometer)
OS Architecture and Design
Monolithic Architecture: All OS components are tightly integrated into a single large program
Kernel, device drivers, and system services run in the same memory space
Offers performance benefits due to direct communication between components
Difficult to maintain and modify due to high complexity and interdependencies
Microkernel Architecture: Minimal kernel that provides only essential services (IPC, memory management)
Other OS components (device drivers, file systems) run as separate user-space processes
Enhances modularity, flexibility, and fault isolation at the cost of increased IPC overhead
Layered Architecture: OS is divided into hierarchical layers, each with a well-defined interface
Lower layers provide services to upper layers, abstracting hardware details
Promotes modularity and simplifies development, but can impact performance due to layer boundaries
Exokernel Architecture: Minimal kernel that provides low-level resource multiplexing
Exposes hardware resources directly to user-space applications through library operating systems (libOSes)
Allows applications to customize OS services based on their specific needs
Increases flexibility and performance but requires careful resource management by applications
Processes and Threads
Process: An instance of a program in execution, with its own memory space and resources
Consists of code, data, and execution context (registers, stack, program counter)
Processes are isolated from each other to ensure system stability and security
Thread: A lightweight unit of execution within a process, sharing the same memory space
Multiple threads can exist within a single process, executing concurrently
Threads share process resources (code, data, files) but have their own execution context
Process States: A process can be in one of several states during its lifetime
New: Process is being created and initialized
Ready: Process is waiting to be assigned to a CPU for execution
Running: Process is currently executing on a CPU
Waiting (Blocked): Process is waiting for an event (I/O, synchronization) to occur
Terminated: Process has finished execution or has been forcefully terminated
Context Switching: The act of saving the execution context of a process and loading another
Occurs when the OS decides to preempt a running process to allow another process to execute
Involves saving registers, stack pointer, and program counter of the current process
Restores the execution context of the next process to be run
Inter-Process Communication (IPC): Mechanisms for processes to exchange data and synchronize their execution
Shared Memory: Processes access a common memory region to read and write data
Message Passing: Processes send and receive messages through OS-provided communication channels
Pipes: Unidirectional data channels that allow processes to stream data between them
Sockets: Bidirectional communication endpoints used for inter-process and network communication
Memory Management Basics
Memory Hierarchy: Computer systems employ a hierarchy of memory devices with varying speeds and capacities
Registers: Fastest and most expensive memory, located within the CPU
Cache: Fast memory between the CPU and main memory, used to store frequently accessed data
Main Memory (RAM): Volatile memory that stores currently executing programs and data
Secondary Storage: Non-volatile storage devices (hard disks, SSDs) that store persistent data
Memory Allocation: The process of assigning memory to processes as they require it
Static Allocation: Memory is allocated to processes at compile-time, before execution begins
Dynamic Allocation: Memory is allocated to processes during runtime, as needed
Memory Partitioning: Techniques for dividing main memory into smaller, manageable units
Fixed Partitioning: Memory is divided into fixed-size partitions, each assigned to a single process
Variable Partitioning: Memory is divided into variable-size partitions based on process requirements
Paging: A memory management scheme that divides physical memory into fixed-size pages
Logical memory (used by processes) is divided into pages, mapped to physical memory frames
Allows non-contiguous memory allocation and efficient memory utilization
Segmentation: A memory management scheme that divides memory into variable-size segments
Each segment corresponds to a logical unit of a program (code, data, stack)
Provides a more natural and flexible memory model compared to paging
Virtual Memory: A technique that allows processes to use more memory than physically available
Portions of a process's memory are swapped between main memory and secondary storage
Enables the execution of large programs and efficient memory utilization
Memory Protection: Mechanisms to prevent processes from accessing unauthorized memory regions
Base and Limit Registers: Define the valid memory range for a process
Memory Management Unit (MMU): Hardware component that translates logical addresses to physical addresses
Access Control: Enforces read, write, and execute permissions for memory regions
File Systems and Storage
File: A named collection of related data stored on a storage device
Identified by a unique name and file extension (document.txt, image.jpg)
Organized in a hierarchical directory structure for easy navigation and management
Directory: A special type of file that contains information about other files and directories
Provides a logical structure for organizing and accessing files
Can contain subdirectories, forming a tree-like hierarchy
File Metadata: Additional information about a file, stored alongside its data
Includes file name, size, creation/modification timestamps, access permissions, and file type
Used by the OS to manage and organize files efficiently
File Operations: Basic operations supported by file systems for manipulating files and directories
Create: Create a new file or directory
Open: Open an existing file for reading, writing, or both
Read: Read data from an opened file
Write: Write data to an opened file
Close: Close an opened file, releasing associated resources
Delete: Remove a file or directory from the file system
File Access Methods: Different ways in which data can be accessed and read from a file
Sequential Access: Data is accessed in a sequential manner, from beginning to end
Random Access: Data can be accessed in any order, by specifying an offset from the beginning of the file
File Allocation Methods: Techniques used by file systems to allocate storage space for files
Contiguous Allocation: Each file occupies a contiguous block of storage, simplifying sequential access
Linked Allocation: Each file is stored as a linked list of disk blocks, allowing flexible space management
Indexed Allocation: An index table is used to store the addresses of disk blocks allocated to a file
Directory Structures: Different ways of organizing directories in a file system
Single-Level Directory: All files are stored in a single directory, without any subdirectories
Two-Level Directory: Each user has their own directory, containing their files and subdirectories
Tree-Structured Directory: Directories are organized in a hierarchical tree structure, allowing nested subdirectories
Disk Scheduling: Algorithms used by the OS to optimize disk I/O performance
First-Come, First-Served (FCFS): Requests are serviced in the order they arrive
Shortest Seek Time First (SSTF): Requests with the shortest seek time from the current head position are serviced first
SCAN (Elevator): The disk head moves in one direction, servicing requests along the way, then reverses direction
C-SCAN (Circular SCAN): Similar to SCAN, but the disk head moves in only one direction, then returns to the beginning
User Interface and Experience
Command-Line Interface (CLI): A text-based interface where users interact with the OS using commands and parameters
Users type commands and receive text output from the OS
Provides direct control over the system and is often used by advanced users and system administrators
Graphical User Interface (GUI): A visual interface that allows users to interact with the OS using graphical elements
Uses windows, icons, menus, and pointers (WIMP) to represent and manipulate system objects
Provides a more intuitive and user-friendly experience, suitable for novice and casual users
Shell: A program that provides the user interface for interacting with the OS
Command-Line Shell: Interprets user commands and executes corresponding system functions or applications
Graphical Shell: Provides a visual interface for managing files, launching applications, and configuring system settings
Window Manager: A component of the GUI that controls the placement and appearance of windows
Handles window creation, movement, resizing, and decoration (title bars, borders)
Coordinates the interaction between windows and the underlying OS
Desktop Environment: A collection of software components that provide a complete GUI experience
Includes a window manager, file manager, application launcher, and system utilities
Examples include GNOME, KDE, and Microsoft Windows Desktop
User Account Management: Mechanisms for creating, modifying, and deleting user accounts
Each user is assigned a unique identifier (username) and authenticates using a password
User accounts have associated permissions and resource limits, enforced by the OS
Access Control: Methods for restricting access to system resources based on user identity and permissions
Discretionary Access Control (DAC): Resource owners determine access permissions for other users
Mandatory Access Control (MAC): The OS enforces access policies based on predefined security labels
Role-Based Access Control (RBAC): Users are assigned roles, which determine their access rights to resources
User Experience Design: The process of designing OS interfaces to be intuitive, efficient, and visually appealing
Involves user research, interaction design, and usability testing
Aims to create interfaces that are easy to learn, navigate, and use, reducing cognitive load and increasing productivity