Processes, Threads, and RAID Levels in Operating Systems
Classified in Computers
Written at on English with a size of 234.98 KB.
What is a Process?
A process is a program in execution, encompassing the current values of the program counter, registers, and variables. It's an active entity with a limited lifespan, created at execution start and terminated upon completion. Processes utilize various resources like memory, disk, and printers as needed.
Process vs. Program
Process | Program |
A program in execution. | A set of instructions. |
Active/dynamic entity. | Passive/static entity. |
Limited lifespan. | Longer lifespan (stored on disk). |
Uses various resources (memory, disk, etc.). | Stored on disk, doesn't use other resources. |
Has a memory address space. | Requires disk space for instructions. |
Multiprogramming and the Process Model
Multiprogramming involves rapidly switching the CPU between multiple processes loaded in memory, creating the illusion of parallel execution. The number of concurrently loaded processes is the degree of multiprogramming.
In the process model, all runnable software, including the operating system, is organized into sequential processes. Each process has its own virtual CPU, simplifying system understanding.
RAID Levels (Redundant Array of Independent Disks)
RAID utilizes multiple disks to improve performance and/or reliability. Data is distributed across drives for parallel operation.
RAID Level 0 (Striping)
Data is divided into strips and distributed across drives in a round-robin fashion. This improves read/write performance but offers no redundancy.
RAID Level 1 (Mirroring)
Data is duplicated on multiple disks, providing high reliability and read performance. Write performance is similar to a single disk.
RAID Level 2 (Hamming Code)
Uses Hamming code for error correction, requiring synchronized drives and a complex controller. Offers high reliability but is rarely used.
RAID Level 3 (Parity)
Similar to RAID 2 but uses a single parity bit for error correction. Requires synchronized drives and is not commonly used.
RAID Level 4 (Striping with Dedicated Parity)
Stripes data with a dedicated parity drive for error correction. Offers good read performance but suffers from write bottlenecks due to the parity drive.
RAID Level 5 (Striping with Distributed Parity)
Distributes parity across all drives, eliminating the bottleneck of RAID 4. Offers good performance and reliability.
Direct Memory Access (DMA)
DMA allows devices to transfer data directly to/from memory without CPU intervention, improving efficiency.
Disk I/O without DMA: CPU reads data from the disk controller one byte at a time, wasting time.
Disk I/O with DMA: DMA controller handles data transfer, freeing up the CPU.
DMA Modes:
- Word-at-a-time (Cycle Stealing): DMA steals occasional bus cycles from the CPU.
- Block Mode (Burst Mode): DMA acquires the bus for a series of transfers, more efficient.
Dining Philosophers Problem
A classic synchronization problem illustrating resource contention and deadlock.
Five philosophers sit at a table with five forks. Each philosopher needs two forks to eat. The problem is to design a solution that prevents deadlock and starvation.
Threads
A thread is a single sequence stream within a process, sometimes called a lightweight process. It allows multiple executions within a process.
Thread Structure
A thread has a program counter, registers, and a stack. It executes within a process but is a separate entity.
Types of Threads
-
User-Level Threads:
- Implemented in user-level libraries.
- Efficient but lack coordination with the kernel.
-
Kernel-Level Threads:
- Managed by the kernel.
- Slower but offer better coordination and scheduling.
-
Hybrid Implementations:
- Combine user-level and kernel-level threads for flexibility.