2015年12月9日 星期三

Operating System - CH3 Process

Process: a program in execution
  • program counter 
  • stack : temporary data
  • data section: global var
  • heap: containing memory allocated dynamicalling during run time

Process Control Block(PCB): kernel 為管理眾多processes, 會在kernel memory area中,針對每個process各自建立PCB, 紀錄process之related info.



Process Scheduling: 最大化CPU的使用,quickly switch process onto CPU from time sharing
  • job queue: all processes in system
  • ready queue: process in main memory, ready to execute
  • device queue: process waiting for an I/O devices

Process scheduler
  • long-term: 從 job queue 挑出進入ready queue
    • control the degree of multiprogramming
  • short-term: 從 ready queue挑出 準備進入CPU執行
  • medium term: 適合time-sharing, 可以調解CPU-bound and I/O-bound( spending more time doing I/O than computations, many short CPU bursts)

  • 當記憶體空間不足時,此時又有較高priority的process需要記憶體,scheduler就會將某些process swap out,等記憶體空間足夠時,才將之swap in 到ready queue



Context Switch
當CPU 轉換process時,他會將之前的process的(context)狀態存起,load state(context) of new process 
  • context switch 沒有生產力,時間的長短取決於hardware
  • OS and PCB越複雜,context switch需要時間就越長



Process type
  • cooperating: process間會互相影響
    • reason:
      • information sharing
      • computation speedup
      • modularity
      • convenience
    • need interprocess communication(IPC)
      • shared memory
      • message passing
        • 建立communication link
        • exchange messages via send/receive
        • release the link
  • independent

indirect communication: messages are directed and received from mailboxes

message passing may be either blocking or non-blocking
  • blocking send/receive: the sender/receiver block until the message is received/available
  • non-blocking send/receive







沒有留言:

張貼留言