운영체제
멀티 쓰레딩 Thread and Concurrency
ted k
2022. 4. 12. 16:56
멀티 쓰레딩
- cpu를 넘나들 수 없음, 커널 support 없음
- user thread : e.g. Java
- Kerner thread
- 코어에서 직접 쓰레딩을 할 수 있게 관리 한다.
- 운영체제가 직접 manage
다중 쓰레드 Multithreading models
- many to one : 가장 기본, 여러 유저 쓰레드 대 하나의 커널 쓰레드
- one to one
- many to many
스레드 라이브러리 Threads Library
- 스레드 create manage하는 API 제공
- POSIX Pthreads
- Windows thread
- Java thread : 운영체제에 따라 POSIX Pthread or Windows thread, 운영체제에 종속적이다.
암묵적 스레딩 implitcit threading
- 병행, 병렬한 디자인은 멀티 코어 시스템에서 멀티스레딩을 하는 것과 같다.
- 그리하여 컴파일러(open mp)나 라이브러리(java)가 대신 스레딩 생성, 관리책임을 지게 된다.
스레드 풀 thread pool
- 여러개 스레드를 pool에 저장해 놓고 대기하여 필요할 때 마다 사용한다.
fork, join
- fork는 java에서 쓰는 new Thread();
- join은 wait
- 명시적 스레딩이다!