티스토리 뷰

운영체제/이론

(21) CPU scheduling

geonwoopaeng@gmail.com 2020. 9. 19. 21:55

### CPU scheduling이 필요한 이유 ###

: multiple process, limited resources에서 cpu 자원을 잘 할당 하여 시스템 수준을 끌어 올리기 위해서 (cpu 코어에서 한 번에 하나의 프로세스만 실행 할 수 있습니다.)

<CPU scheduler>

: cpu가 idle이 될 때 마다 ready queue에서 프로세스 중 하나를 선택합니다.

: ready queue의 프로세스 중 어떤 프로세스를 running queue로 만들 것인가(cpu를 할당 할 것인가)

=> i/o등과 같은 자원을 사용할 수 없어 다른 process의 실행이 ready 상태인 동안 한 process가 cpu를 사용할 수 있게 하는 프로세스로 cpu를 최대한 활용하게 하는 것

<Scheduling을 선택하는 points>

1. When a process switches from running to waiting state.

: 프로세스가 실행 중에서 대기 상태로 전환되는 경우

ex) 입/출력, parent,child fork()

2. When a process switches from running to ready state.

: 프로세스가 실행 중에서 준비 상태로 전환 되는 경우

ex) systemcall, interrupt(device control, timer)

3. When a process switches from waiting to ready state.

: 프로세스가 대기 상태에서 준비 상태로 전환 될 때

ex) running to waiting일 때와 연결, ready일 때 다시 cpu자원을 할당 시켜준다.

4. When a process terminates.

: 프로세스가 종료 될 때

<CPU를 넘겨주는 시점>

1. <Nonpreemptive scheduling(비선점형)>

: 우직하게 작업을 처리하고 있는 process에게 cpu자원을 고정적으로 할당해주는 형태

: Is non-flexible

<발생 상황>

1. Triggers when a process switches from running to waiting state.

2. when a process terminates.

 

 

 

2. <Preemptive scheduling(선점형)>

: process가 cpu자원 할당 받아 실행하고 있더라도 os가 판단해서 다른 process에게 cpu를 할당 해 줄 수 있는 형태

: Is used in modern operating systems (Windows, MacOS, Linux, and Unix)

: Is complicated to design.

 

<발생 상황>

1. when a process switches from running to waiting state.

2. when a process switches from running to ready state.

3. when a process switches from waiting to ready state.

4. when a process terminates.

반응형

'운영체제 > 이론' 카테고리의 다른 글

(23) CPU Scheduling Algorithm  (0) 2020.09.20
(22) Dispatcher  (0) 2020.09.19
(20) Multithreading Models  (0) 2020.09.19
(19) Thread  (0) 2020.09.19
(18) Process Management(Process termination)  (0) 2020.09.17
공지사항
최근에 올라온 글