[CS] 사용자 수준 스레드 vs 커널 수준 스레드 차이는?

2024. 2. 27. 20:57CS

사용자 수준 스레드

유저 라이브러리나 애플리케이션 수준에서 사용되는 스레드이다. 

커널은 이 스레드에 대해서 알지 못한다는 특징이 있다.

장점

- 스레드 간 컨텍스트 스위칭 비용이 없다.

- 다양한 OS에서 변경 없이 사용 가능하다.

- 쓰레드를 만들기 위해 시스템콜이 필요없기 때문에 생성하는데 커널 수준 스레드보다 시간이 더 적게 걸린다.

단점

- 멀티 코어를 활용할 수 없다.

- 하나의 스레드가 블락이 되면 다른 모든 스레드도 블락이 된다.

 

커널 수준 스레드

운영체제 커널 수준에서 관리해주는 스레드이다.

사용자 수준 스레드와 다르게 커널이 이 스레드에 대해서 알고 있다.

장점

- 멀티 코어를 통한 병렬화를 활용할 수 있다.

- 하나의 스레드가 블락이 되어도 다른 스레드가 블락이 되지 않는다. (Isolation)

단점

- 컨텍스트 스위칭 비용이 생긴다. 

- 사용자 수준 스레드와 비교할 때 스레드 관리나 스케줄링이 유연하지 못하다.

 

자바에서는 Thread Class를 사용하면 사용자 수준 스레드를 구현할 수 있다.

JVM은 이 사용자 수준 스레드를 커널 수준 스레드로 맵핑해준다. (Many-to-Many 관계로) (여러 사용자 수준 스레드 - 여러 커널 수준 스레드)

 

https://www.geeksforgeeks.org/difference-between-user-level-thread-and-kernel-level-thread/

 

Difference between User Level thread and Kernel Level thread - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

https://www.linkedin.com/pulse/user-level-vs-kernel-level-threads-comparing-thread-highlighting-n

 

User-level vs. Kernel-level Threads: Comparing user-level and kernel-level thread implementations, highlighting their advantages

User-level threads and kernel-level threads are two different approaches to implementing multithreading in an operating system. Each approach has its own advantages and disadvantages, and the choice between them depends on the specific requirements and con

www.linkedin.com

https://docs.oracle.com/cd/E19620-01/805-4031/6j3qv1oed/index.html

 

https://docs.oracle.com/cd/E19620-01/805-4031/6j3qv1oed/index.html

Chapter 2 Multithreading This chapter discusses multithreading in general, and specific MT issues related to Java on Solaris software and the native-threaded JVM. Definition Of Multithreading* A thread is a sequence of control within a process. A single-th

docs.oracle.com