02. Process Management
Process Management
1. Processes and Threads
- Process: the execution of a program, the basic unit of resource allocation and scheduling
- Process states: ready, running, blocked, and their transitions
- Process control: creation, termination, switching
- Process organization: PCB (Process Control Block)
- Process communication: shared memory, message passing, pipes
- Thread: execution unit within a process, shares resources, lightweight
- Multithreading models: user-level threads, kernel-level threads
2. Processor Scheduling
- Basic concepts: scheduling objects, timing, switching
- Scheduling criteria: CPU utilization, turnaround time, response time, etc.
- Scheduling types: preemptive, non-preemptive
- Typical algorithms: First-Come-First-Served (FCFS), Shortest Job First (SJF), Round Robin (RR), Priority Scheduling, Multilevel Feedback Queue
3. Synchronization and Mutual Exclusion
- Critical section, mutual exclusion, synchronization
- Software methods: Peterson’s algorithm, etc.
- Hardware methods: interrupt disabling, Test-and-Set, etc.
- Semaphore (P/V operations), monitors
- Classic synchronization problems: producer-consumer, readers-writers, dining philosophers
4. Deadlock
- Deadlock concept: processes are permanently blocked due to resource competition
- Deadlock handling strategies: prevention, avoidance, detection and recovery
- Deadlock prevention: break the four necessary conditions
- Deadlock avoidance: Banker’s algorithm
- Deadlock detection and recovery
Exercises
- Briefly describe the difference between a process and a thread.
- What are the three basic states of a process and their transition conditions?
- What are the characteristics of FCFS, SJF, and RR scheduling algorithms?
- What is a semaphore? What do P/V operations mean?
- What are the four necessary conditions for deadlock? How can deadlock be avoided?
Reference Answers
1. Difference between process and thread
A process is a unit of resource allocation, a thread is a unit of scheduling, and threads share process resources.
2. Three process states and transitions
Ready (waiting for CPU), running (using CPU), blocked (waiting for resources); transitions are caused by scheduling, I/O, events, etc.
3. Scheduling algorithm characteristics
FCFS: simple, easy to implement, long jobs may starve; SJF: shortest average turnaround time, hard to predict job length; RR: fair, fast response, suitable for time-sharing systems
4. Semaphore and P/V operations
Semaphore is used for synchronization and mutual exclusion; P operation requests a resource, V operation releases a resource
5. Deadlock conditions and avoidance
Mutual exclusion, no preemption, hold and wait, circular wait; avoidance methods: break conditions, Banker’s algorithm
上一章节
01. Operating System Overview Understand the basic concepts, characteristics, functions, and history of operating systems, as well as their runtime environment and architecture.
下一章节
03. Memory Management Master the basic principles of memory management, contiguous and non-contiguous allocation, virtual memory, and page replacement algorithms.