본문 바로가기
Study/운영체제

5.CPU Scheduling - Thread scheduling

by 이미뇨 2023. 4. 10.

1.Thread Scheduling

Threads

  • User thread : thread library에서 지원됨 (LWP를 통해 간접적으로 Scheduled)
  • Kernel thread : OS kernel에서 지원됨

OS에 의해 scheduled 되는것은 kernel threads 이다. (processes 가 아니고)

 

2.Contention Scope

경쟁을 하는 범위

  • Process-contention scope (PCS) : user threads간 경쟁 (프로세스 안에서 경쟁)
    • Many-to-one model or many-to-many model
  • System-contention scope (SCS) : kernel threads간 경쟁 (시스템 전체에서 경쟁)

Scheduler Activation and LWP

3.Pthread Scheduling

: Pthreads를 사용한 스레드 생성에서 PCS 또는 SCS를 지정할 수 있습니다

  • PCS(PTHREAD_SCOPE_PROCESS):
    • In many-to-one, only PCS 에서만 가능
  • SCS(PTHREAD_SCOPE_SYSTEM):
    •  In one-to-one model, only SCS 에서만 가능

Related functions

  • pthread_attr_setscope(pthread_attr_t *attr, int scope)
  • pthread_attr_getscope(pthread_attr_t *attr, int *scope)

pthread_create -> kernel thread 생성 (SCS)