Process Scheduler
- is one of OS modules.
- selects one of the processes in memory that are ready to execute, and allocates the CPU to the selected process.
- 레디 큐에 존재하는 프로세스들을 특정 우선순위를 기반으로 CPU를 할당하게 해줌.
- 수행->대기 interrupt
- 수행->준비 time-out
- 대기->준비 wake-up
- 종료 (Terminate)
(대기->수행: dispatch)
Non-Preemptive vs Preemptive
Non-Preemptive
- 스케줄링 결정 시점 중 1, 4에서 스케줄링 발생(terminating or by switching to the waiting state)
- 이미 할당된 cpu를 다른 프로세스가 강제로 빼앗아 사용할 수 없음.
- 어떤 프로세스가 CPU를 할당 받음 -> 그 프로세스가 종료 or IO request가 발생하여 자발적으로 waiting 상태에 들어갈 때까지 계속 실행
- (ex) FCFS(FIFO), SJF, 우선순위 등
Preemptive
- 하나의 프로세스가 cpu를 할당받아 실행되고 있을 때, 우선순위 높은 다른 프로세스가 cpu를 강제로 뺏을 수 있음.
- 우선순위 높은 프로세스를 빠르게 처리 가능
- 스케줄링 결정 시점 1~4까지 모든 상황서 발생.
- 프로세스 실행 중 time slice를 모두 사용하여 time-out or IO request 발생 or event 기다리는 상황에서 다른 프로세스에게 CPU 사용 양보 (프로세스를 쫓아내고 CPU 자원 선점 가능(우선순위 따라서))
- (ex) RR(Round Robin), SRT 등
Dispatcher
- Dispatcher: CPU 스케줄러 내부에 포함. 단기 스케줄러가 선택한 프로세스에 실질적으로 프로세서를 할당
- context switching, 운영체제 모드(Kernel mode)-> 사용자 모드(user mode)로 전환 O, 프로세스가 재시작 할 때, 유저 프로그램이 올바른 위치를 찾아주게 함.
- Dispatch latency = context switching delay
Optimization Criteria
Process Scheduling Algorithms (매우 중요)
- non-preemptive scheduling 종류: FCFS, non-preemptive SJF,Priority Scheduling,
- preemptive scheduling 종류: preemptive SJF, RR (라운드 로빈)
FCFS scheduling
SJF Scheduling
Round Robin(RR) Scheduling
Priority Scheduling