[OS] Scheduling Algorithms (Priority, Round-Robin)

Ko Hyejung·2021년 10월 16일
0

Operating Systems

목록 보기
17/26

Priority Scheduling

A priority number (integer) is associated with each process.
우선 순위 번호(정수)는 각 프로세스와 연결됩니다.

The CPU is allocated to the process with the highest priority (smallest integer = highest priority).
CPU는 가장 높은 우선순위(숫자 정수 = 가장 높은 우선순위)로 프로세스에 할당

  • Preemptive
  • Non-preemptive

SJF is a priority scheduling where priority is the predicted next CPU
burst time.

  • Problem : starvation – low priority processes may never execute.
    우선순위가 낮은 프로세스는 실행되지 않을 수도
  • Solution : aging – as time progresses increase the priority of the process.
    시간이 지남에 따라 프로세스의 우선순위가 증가

Example of Priority Scheduling

Round Robin (RR) Scheduling

Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds.

각 프로세스에는 작은 단위의 CPU 시간(time quantum)이 할당되며 일반적으로 10-100밀리초입니다.

After this time has elapsed, the process is preempted and added to the end of the ready queue.

이 시간이 지나면 프로세스가 먼저 실행되어 준비 대기열의 끝에 추가됩니다.

If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once.

준비 대기열에 프로세스가 n개 있고 퀀텀 시간이 q이면 각 프로세스는 CPU 시간의 1/n을 최대 q 시간 단위로 한 번에 가져옵니다.

No process waits more than (n-1)q time units.

(n-1)q 시간 단위를 초과하는 대기 프로세스가 없습니다.

Performance

  • q large -> FCFS
  • q small -> q must be large with respect to context switch.

If q is extremely small, it is called processor sharing – each of n processes has its own processor running at 1/n the speed of the real processor.

q가 매우 작으면 프로세서 공유라고 합니다. 각 n개의 프로세스에는 실제 프로세서의 1/n 속도로 실행되는 자체 프로세서가 있습니다.

RR with Time Quantum = 20

Time Quantum vs Context Switch Time


Typically, higher average turnaround than SJF, but better response.

Time Quantum vs Turnaround Time


Average turnaround time does not necessarily improve as the time- quantum size increases.
평균 반환 시간은 시간이 증가함에 따라 반드시 개선되는 것은 아니다.

If time quantum is too large, RR scheduling becomes FCFS policy.
시간 퀀텀이 너무 크면 RR 스케줄링이 FCFS 정책이 됩니다.

80 percent of the CPU bursts should be shorter than the time quantum.
CPU 버스트의 80%는 time quantum보다 짧아야 합니다.

0개의 댓글