2024. 2. 27. 20:57ㆍCS
사용자 수준 스레드
유저 라이브러리나 애플리케이션 수준에서 사용되는 스레드이다.
커널은 이 스레드에 대해서 알지 못한다는 특징이 있다.
장점
- 스레드 간 컨텍스트 스위칭 비용이 없다.
- 다양한 OS에서 변경 없이 사용 가능하다.
- 쓰레드를 만들기 위해 시스템콜이 필요없기 때문에 생성하는데 커널 수준 스레드보다 시간이 더 적게 걸린다.
단점
- 멀티 코어를 활용할 수 없다.
- 하나의 스레드가 블락이 되면 다른 모든 스레드도 블락이 된다.
커널 수준 스레드
운영체제 커널 수준에서 관리해주는 스레드이다.
사용자 수준 스레드와 다르게 커널이 이 스레드에 대해서 알고 있다.
장점
- 멀티 코어를 통한 병렬화를 활용할 수 있다.
- 하나의 스레드가 블락이 되어도 다른 스레드가 블락이 되지 않는다. (Isolation)
단점
- 컨텍스트 스위칭 비용이 생긴다.
- 사용자 수준 스레드와 비교할 때 스레드 관리나 스케줄링이 유연하지 못하다.
자바에서는 Thread Class를 사용하면 사용자 수준 스레드를 구현할 수 있다.
JVM은 이 사용자 수준 스레드를 커널 수준 스레드로 맵핑해준다. (Many-to-Many 관계로) (여러 사용자 수준 스레드 - 여러 커널 수준 스레드)
https://www.geeksforgeeks.org/difference-between-user-level-thread-and-kernel-level-thread/
https://www.linkedin.com/pulse/user-level-vs-kernel-level-threads-comparing-thread-highlighting-n
https://docs.oracle.com/cd/E19620-01/805-4031/6j3qv1oed/index.html
'CS' 카테고리의 다른 글
[CS] 인덱스에 관한 좋은 레퍼런스 (0) | 2024.04.08 |
---|---|
[CS] DB 정리 (0) | 2024.04.08 |
[CS] 핀토스 환경 쉽게 구축할 수 있는 레퍼런스 (0) | 2024.02.11 |
[CS] Hashing에 대한 나름의 이해 (1) | 2024.01.10 |
[CS] producer-consumer pattern (0) | 2024.01.07 |