Week 1 Flashcards
OS Definition and Functions:
Purpose: The operating system (OS) manages hardware resources and simplifies complex hardware interactions by providing abstractions, making it easier for applications to work without needing to understand underlying hardware intricacies.
Two Main Functions: Resource management and abstraction of hardware complexity.
OS Role and Customers:
Hiding Hardware Complexities: The OS abstracts hardware, presenting simplified interfaces.
Primary Users: Application programs, not end users, are the OS’s main clients. The user interface (e.g., desktop, command prompt) caters to end users.
OS as Resource Manager:
Concurrent Program Management: Handles multiple programs, ensuring smooth output and efficient resource allocation.
Multi-User Environments: Prevents user interference, tracks resource usage, and mediates resource conflicts.
Multiplexing: Time multiplexing allows resources to be shared over time (e.g., CPU scheduling), while space multiplexing divides resources (e.g., memory) among programs.
Computer Hardware Overview:
CPU: Performs fetch, decode, and execute cycles. It uses registers like the Program Counter, Stack Pointer, and PSW (Program Status Word) for execution management.
Mode Operations: Supports kernel mode (full hardware access) and user mode (restricted).
Memory Hierarchy: Includes registers (fastest), cache, RAM (main memory), and SSD (nonvolatile).
I/O and Device Drivers: Consist of controllers and devices, with drivers running in kernel mode to manage each controller type.
Interrupts: Devices signal the CPU with interrupts, prompting the OS to execute handler code from the interrupt vector table.
Busses: Connect components, with specialized options like PCIe for high-speed point-to-point connections.
Multithreading and Multicore:
Multithreading: Allows the CPU to switch between threads for fast task-switching.
Multicore Chips: Processors with multiple independent cores that the OS treats as separate CPUs.
Operating System Key Concepts:
Processes: Independent execution units.
Address Space: Memory assigned to processes.
Files and I/O: Managed by the OS for efficient access and device control.
Protection and Shell: Safeguard resources, and the shell provides a command-line interface to interact with the OS.
Protections
- User, Group, Other
rwx - Read, Write, Execute
System Calls:
Mechanics: System calls run under a single-CPU constraint, using a trap instruction to switch from user to kernel mode, allowing access to privileged operations.
Execution Steps: Involve preparing parameters, library calls, trap execution, system-call handling, and returning control to the user with results or errors.
Process Management Calls: fork() duplicates processes, and waitpid() allows parent processes to await specific child termination. The shell utilizes execve() for command execution.
Process Model:
Sequential Processes: Each process, a standalone program instance, maintains its own execution state. Virtual CPUs are created by rapid context switching, supporting pseudo-parallelism.
Process Table: Stores critical process information such as program counters, memory usage, and file status in structured entries.
a
Threads
Basic Concept: Threads enable concurrent execution within a shared address space, offering faster creation/destruction than processes.
Multithreaded Web Server: Threads boost performance by enabling simultaneous I/O and computation.
Data Processing Model: Tasks like input, processing, and output are organized into separate threads, improving resource utilization.
Thread Model:
Processes as Resource Groups: Processes group resources, while threads are execution entities within a process.
Shared Address Space: Threads share memory and resources but lack strict protection, requiring careful coordination.
Thread Stacks: Each thread has an independent stack for local variables and history, with complexities around synchronization.
POSIX Threads:
Functions for thread creation (thread_create), termination (thread_exit), and joining (thread_join) facilitate multithreaded programming.
Process and Thread Tables:
User-Level Threads: Managed in user space, offering efficient switching but may block entire processes during page faults.
Kernel Threads: Tracked globally by the kernel, handling page faults effectively but at a higher creation cost.