다양한 스레드의 종류

강민승·2023년 4월 13일
0

A hardware thread is a separate physical core in a processor that can execute its own set of instructions simultaneously with other threads. This allows for parallel processing and improved performance in multi-threaded applications.

코어의 고민 - 메모리에서 데이터를 기다리는 시간이 꽤 오래 걸린다.

→ 메모리를 기다리는 동안 다른 스레드를 실행하는 건 어떨까?

두 개의 서로다른 쓰레드, 각각 실행되는 쓰레드를 h/w thread

Hardware thread

OS관점에서는 가상의 (logical) 코어

OS thread

OS 스레드는 CPU에서 실제로 실행되는 단위, CPU 스케쥴링의 단위

OS 스레드의 컨텍스트 스위칭은 커널이 개입 → 비용 발생

사용자 코드와 커널 코드 모두 OS 스레드에서 실행된다.

가상의 코어마다 두개의 스레드를 배치

User Thread

스레드 개념을 프로그래밍 레벨에서 추상화 한 것.

유저 스레드와 OS스레드를 연결 시켜야하는데 어떻게 연결시키는데?

  1. One to One model

  1. many to one model

  1. many to many model

User thread

기술 문서에 따라서는 OS와는 독립적으로 유저 레벨에서 스케줄링되는 스레드

, many to one, many to many 에 있는 유저쓰레드들을 한정해서 유저스레드라고 지칭하기도 함.

Green thread

java 초창기 버전은 many to one 스레딩 모델을 사용,.

이 때 이 유저 스레드들은 그린 스레드라고 호칭

그린 스레드의 의미가 계속 확장이 돼

→ OS와는 독립적으로 유저 레벨에서 스케줄링되는 스레드

조금 다른 맥락에서 Kenel thread

  • OS 커널의 역할을 수행하는 스레드

출처 | 쉬운코드 유튜브

profile
Step by Step goes a long way. 꾸준하게 성장하는 개발자 강민승입니다.

0개의 댓글