[OS] Thread

동동·2022년 4월 8일
post-thumbnail

스레드(Thread)란?

"A Thread(or lightweight process) is a basic unit of CPU utilization"
프로세스 내부에 CPU 수행 단위

  • Thread의 구성

    • program counter
    • register set
    • stack space
  • Thread가 동료 thread와 공유하는 부분(=task)

    • code section
    • data section
    • OS resources
  • 전통적인 개념의 heavyweught process는 하나의 thread를 가지고 있는 task로 볼 수 있음

  • 다중 스레드로 구성된 task 구조에서는 하나의 서버 스레드가 blocked(waiting) 상태인 동안에도 동일한 task 내의 다른 스레드가 running되어 빠른 처리를 할 수 있음

  • 동일한 일을 수행하는 다중 스레드가 협력하여 높은 처리율(throughput)과 성능 향상을 얻을 수 있음

  • 스레드를 사용하면 병렬성을 높일 수 있음(멀티 CPU에서만 해당)


Benefits of Threads

Responsiveness

  • eg) multi-threaded Web if one thread is blocked(eg network) another thread continues(eg display)

Resource Sharing

  • n threads can share binary code, data, resource of the process

Economy

  • creating & CPU switching thread (rather than a process)
  • Solaris의 경우 위 두 가지 overhead가 각 각 30배, 5배

Utilization of MP Architectures

  • each thread may be running in parallel on a different processor

Implementation of Threads

Kernel Threads는 운영체제가 스레드가 여러개 있다는 것을 알고 있음

User Theads는 운영체제가 스레드가 여러개 있는 것을 알 수 없음.
사용자 프로세스가 자체적으로 멀티 스레드를 사용함

profile
괴발개발

0개의 댓글