4 min read

<운영체제> Process 2

<운영체제> Process 2

본 게시물은 영남대학교 곽종욱 교수님의 강의를 기반으로 작성되었습니다.


<CPU Switch From Process to Process>

  • Context Switching : process가 전환되는 과정
  • 예를 들어 time-sharing을 위한 Timer-Interrupt 발생
  • 현재 실행중인 P0의 PCB를 저장,P1의 PCB를 Reload
  • 이제부터 P1 실행
  • 이러한 과정을 context-switch라고하며, 프로세스가 바뀌는 과정이다.
Context-Switching 1
Context-Switching 2

<PCB In UNIX>

  • PCB 구성요소 : PID, Priority, Waiting Event, State, Location of image in disk...etc
  • PCB의 수많은 구성요소들 + 동시에 실행되는 수많은 Process의 수 => PCB의 용량이 kernel영역을 넘어서 user영역까지 넘어가는 문제점이 발생!
  • 그래서 모든 PCB를 Memory에서 Disk로 swap-out(쫒아내자!)하려고 시도
  • 그러면 해당 process의 상태 및 저장공간을 몰라서 다시 process를 실행 시키지 못한다...
  • 그래서 PCB를 두 영역으로 나누는 해결방법 고안! -> proc과 user로 나눠보자
  • 쉽게 말해 proc에는 해당 process를 다시 실행시키기 위한 중요한 정보들이 포함!
  • user에는 disk로 swap-out해도 되는 내용들을 포함
  • sturct proc :
    • 1.PID, 2.Priority, 3.Waiting Event, 4.State, 5.Location of image in disk
    • one per process
    • data needed even when process is not active
  • struct user :
    • data needed only when process is active
    • called 'u block'
Per Process Data

<Process Scheduling Queues>

  • Job queue : set of all processes in the system -> 시스템의 모든 process가 존재
    • Swap out되어서 disk 상에 있을 수도, main memory상에 남아 있을 수도 있다.
  • Ready queue : set of all processes residing in main memory, ready and waiting to execute -> CPU로 Dispatch되기전의 ready상태에 있는 모든 process 존재
  • Device queues : set of processes waiting for an I/O device -> 디바이스마다 해당 큐 존재
  • Processes migrate among the various queues

<Schedulers>

  • Long-term scheduler(job-scheduler)
    • Ready queue contains all processes which redise in main memory
    • 간단하게 Job큐에서 Ready큐로 보내는 일을 진행
  • Short-term scheduler(CPU-scheduler)
    • Ready큐에서 CPU로 보내는 일을 진행
  • Medium-term scheduler(Swapper)
    • Key idea : someeetimes, it can be advantageous to remove processes from memory and thus reduce the degree of multiprogramming(멀티 프로그래밍의 정도)
    • 왜 멀티 프로그래밍의 정도를 낮춰야 하는가? -> Thrashing!
    • This scheme is also called as Swapping
  • Short-term scheduler is invoked very frequently(굉장히 자주 사용됨,milliseconds)
  • Long-term scheduler is in invoked very infrequently -> 가끔식 사용됨
  • Process can be described as either :
    • I/O-bound process -> spends more time doing I/O than computation, many short CPU bursts(여러개의 짧은 CPU활용) -> 입출력을 열심히하는 프로그램
    • CPU-bound process -> spends more time doing computaions, a few very long CPU bursts(드물지만 긴 CPU활용) -> 계산을 열심히하는 프로그램
Medium Term Scheduler