http://www.csie.ntnu.edu.tw/~swanky/os/chap4.htm
http://www.csie.ntnu.edu.tw/~swanky/os/chap10.htm -> IPC
http://en.wikipedia.org/wiki/Process_(computing)
http://en.wikipedia.org/wiki/Scheduling_(computing):第一段
Process: the unit of work in most systems
包含:code section, data section, program counter, registers, stack, etc.
Program is a passive entity(是死的); Process is an active entity(是活的)
Processes of the same program: same text section, different data sections
Thread: a basic unit of CPU utilization
Threads of the same process: same code & data section, other resources.
<對照習題4.5, Fig.4.11,fork出child process時是複製data,
而產生新thread時是共享data。>
Process state: new, waiting, ready, running, terminated
Process control block (PCB) -- information representing a process:
1. Process state
2. Program counter
3. CPU registers
4. CPU-scheduling information
5. Memory-management information
6. Accounting information
7. I/O status information
Scheduling queues:
1. Job queue -- containing all processes in the system.
2. Ready queue -- those in memory that are ready to be executed.
3. Device queue -- processes waiting for that device.
<對照Fig.3.6看架構>
Schedulers:
1. Long-term scheduler (Job scheduler, Admission scheduler):
從Job Queue中挑選合適的Jobs,將其載入到Memory中(放進ready Q)準備執行。
a. 執行的頻率不高
b. 可控制degree of Multiprogramming
c. 可調和I/O Bound與CPU Bound Job比例混合
d. 適用於batch system,不適用於time-sharing, real-time systems。
2. Short-term scheduler:
從Ready Queue中挑選priority較高之process,使其獲得CPU的控制權。
a. 執行頻率很高
b. 必須非常快,否則浪費CPU time
c. 適用於所有系統
3. Medium-term scheduler:
當記憶體空間不足,且有高優先權之process需要memory時,
挑選某些process做"swapping"。
a. swap out: remove processes from memory to "reduce the
the degree of multiprogramming"
b. swap in: reintroduce the swapped-out processes
into memory
c. 可調和I/O bound與CPU bound Job比例
d. 適用Time sharing system
Context switch:
Save the state of old process and load the state of new process.
fork() system call: creates a new process
exec() system call: load a binary file into memory and execute
wait() system call: wait for child process to complete
exit() system call: process terminates
abort() system call: terminate execution of child process
Inter-Process Communication
Independent process -- can't affect or be affected by others
Cooperating process -- can affect or be affected by others
Advantages:
1. Information sharing
2. Computation speedup
3. Modularity
4. Convenience
Cooperating processes require an IPC mechanism:
1. Shared memory
2. Message passing
<對照study guide: ch10的補充>
Client-Server Communication
1. Remote procedure calls (RPC)
Client's Stub locates the server and packs parameters
Server's Skeleton unpacks parameters and performs procedures
<對照Fig3.28的流程>
2. Remote method invocation (RMI)
Java mechanism similar to RPC, except:
a. Invoking a method directly without a matchmaker.
b. Ordinary data structures without packaging(marshalling).
沒有留言:
張貼留言