OS_Chapter_5.1

ssonjh·2021년 4월 5일
0

OS

목록 보기
12/17

👀 Basic Concepts

  • Objective of multiprogramming: Maximum CPU utilization

CPU Scheduling은 multiprogramming의 기본이다.

기본 개념

Single-Processor Systems에서는?
1. 한번에 하나씩의 process만이 실행될 수있다.
2. 나머지 process는 CPU가 자유 상태가 되어 다시 Scheduling할 수 있을 때까지 기다려야 한다.

그렇다면, multiprogramming에서는?
multiprogramming의 목적 : CPU의 이용률을 최대화하기 위해 항상 실행 중인 process를 가지게 하는 데 있다!!!

📕 CPU burst & I/O burst


Process execution consists of a cycle of CPU execution and I/O wait

  • CPU burst followed by I/O burst
  • CPU burst distribution is of main concern

I/O-bounded program

I/O-bounded program has large number of short bursts

  • I/O-bounded process spends more of its time doing I/O

CPU-bounded program

has small number of longer bursts

  • CPU-bounded process spends more of its time doing
    computations

Summary

  • Process의 실행은 CPU 실행I/O 대기의 사이클로 구성된다. Process는 이 두 상태 사이를 교대로 왔다갔다 한다.
  • Process의 실행의 시작은 CPU burst의 발생이다. 그 뒤를 이어 I/O burst가 발생된다.
  • 그 후로 또다른 CPU burst와 I/O burst가 번갈아가며 발생되고, 마지막에는 실행을 종료하기 위한 시스템 요청과 함께 끝난다.

I/O-bounded program (입출력 중심의 프로그램)

  • 주로 I/O장치에 접근하여 작업을 수행하는 process로 많은 양의 짧은 burst를 가진다

CPU-bounded program (CPU 중심의 프로그램)

  • 주로 복잡한 연산과 같은 CPU를 많이 사용하는 프로세스로 적은 양의 긴 버스트를 가진다

I/O-bounded와 CPU bound가 적절한 조화를 이루어야 최고의 시스템 성능이 나온다.

📙 CPU Scheduler

  • The CPU scheduler selects from processes in ready queue, and allocates a CPU core to one of them
  • Queue may be ordered in various ways

In a single-processor system

  • Only one process can run at a time
  • Any others must wait until the CPU is free and can be rescheduled.
  • When the running process goes to the waiting state,
    -> the OS may select another process to assign CPU to improve CPU utilization.
  • Every time one process must wait, another process can take over the use of CPU

Summary

  • CPU scheduler는 준비된 queue로부터 process를 선택하고, CPU core를 할당해 준다.
  • Queue는 많은 방법으로 구현될 수 있다.

single-processor system에서는..

  • 오직 하나의 process만 돌아갈 수 있다!
  • 다른 process들은 CPU에 자리가 날때까지 기다려야 하고, 다시 schedule될 수 있다.
  • 실행중인 process가 waiting 상태로 바뀌면,
    -> OS는 CPU 사용률을 높이기 위해 다른 process를 선택한다.

Diagram of Process State

  • Many processes may be ready and waiting states.
  • 많은 process들이 ready나 waiting 상태에 머물러 있다.

Process Scheduling

  • Four conditions when a process leaves CPU
  • process가 CPU를 빠져나올때 4가지의 상태가 될 수 있다.

CPU Scheduler

  • CPU scheduling decisions may take place when a process:
  1. Switches from running to waiting state (I/O or event wait)
  2. Switches from running to ready state (interrupt)
  3. Switches from waiting to ready (I/O or event completion)
  4. Terminates (exit)
  • Scheduling under 1 and 4 is non-preemptive (비선점)
    • A running process can use CPU and return CPU after its use
    • A process CANNOT take away the current running process’s
    scheduling
  • Scheduling under 2 and 3 is preemptive (선점)
    • A running process may lose CPU use by other process
    • A process CAN take away the current running process’s scheduling
    • ex) real-time system

Summary

  • CPU scheduling이 process를 바꿀 경우:
  1. running -> waiting (I/O or event 대기일 때)
  2. running -> ready (interrupt일 때)
  3. waiting -> ready (I/O or event가 해결될 때)
  4. Terminates (끝날 때)
  • 1번과 4번일 때는 non-preemptive(비선점) 방식으로 Scheduling을 한다.
    -> CPU가 한 process에 할당되면, process가 종료하든지 또는 대기 상태로 전환해 CPU를 반납할 때 까지 CPU를 점유한다.
  • 2번과 2번일 때는 preemptive(선점) 방식으로 Scheduling을 한다.
    -> 여러 process가 CPU를 서로 선점하여 CPU를 뺏어 올 수 있다.

Dispatcher

  • Dispatcher module gives control of the CPU to the process selected by the CPU scheduler
    • switching context
    • switching to user mode
    • jumping to the proper location in the user program
    to restart that program
    • switching context

Dispatcher latency

  • time it takes for the dispatcher to stop one process and start another running

Summary

  • Dispatcher module은 CPU의 제어를 CPU scheduler가 선택한 process에게 주는 module이다.

Dispatcher의 역할은
1. context를 교환하는 일
2. user mode로 전환하는 일
3. program을 다시 시작하기 위해 user program의 적절한 위치로 이동하는 일

Dispatcher latency (지연)

  • Dispatcher가 하나의 process를 정지하고 다른 process의 수행을 시작하는 데까지 소요되는 시간을 말한다.

dictionary
decision 결정
preemptive 선점
latency 지연

idle(유휴) : 어떠한 프로그램에 의해서도 사용되지 않는 상태

0개의 댓글