本文主要摘自Operating System Concepts By ABraham Silberschatz
Process and Thread Management
The creation and deletion of both user and system processes. The scheduling of processes. The provision of mechanisms for synchronization, communication, and deadlock handling for processes.
Process state:
New: is being created.
Running: Instructions are being exectuted
Waiting: The process is waiting for some events to occur. I/O completion or reception of a signal
Ready: The process is waiting to be assigned to a processor.
Terminated: finished executing.PCB:
Contains some information of a specific process:
Process State; Program Counter; CPU Register; CPU-Scheduling information; Memory management informationProcess Schedule:
processes enter the system —— job queue;
Residing in the main memory and are ready ———- ready queue
Waiting for device ——- device queueLong-term Scheduler (Job scheduler): may be absent. simply put every new process into memory. The balance between IO bounds and CPU bounds Process.
Short-term Scheduler (CPU shceduler) FREQUENTLY:
Medium-term Scheduler: To remove a process from memory to reduce the degree of multiprogramming. Called SWAPING!
二者最大的不同是:执行的频率上的不同!
Threads:
Motivition: Web browser, word processor, manyu similar tasks
Benifits: Responsiveness; Resource Sharing; Ecnomy; Scalability;
User Threads and Kernel Threads:
Many to many model: 避免了1to1的用户在一个应用程序内创建很多线程的问题!
Process Synchronization:
Critical section is a segment of code and allow only one process executing.
Critical section problem: design a protocol that the processes can use to cooperate
mutex lock: a process must acquire the lock before entering a critical section
Semaphore: wait() and signal()
CPU Scheduling:
Shecduling criteria:
CPU utilization; Throughput; Turnaround Time; Waiting time; Response Time;
Algorithms:
First Come First Served
Shoutest Job First
Priority
Round-Robin
Deadllock
A process waiting for a resources which was held by another process.
- Necessary Conditions:
- Mutual exclusion: only one process at a time use the resource
- Hold and wait:
- No preemption: Resouces can not be preempted
- Circular wait: a set of waiting processes.
Resource-Allocation Graph.