๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ5: ๐’ฆ๐‘œ๐“‡๐‘’๐’ถ ๐’ฐ๐“ƒ๐’พ๐“‹/์šด์˜์ฒด์ œ Operating Systems (COSE341)

[์šด์˜์ฒด์ œ] CH3. Threads & Concurrency

0. Overview

1) Thread๋ž€ : A basic unit of CPU utilization

- thread ID, a program counter (PC), a register set, and a stack ์œผ๋กœ ๊ตฌ์„ฑ๋จ

- ๊ฐ™์€ process์˜ ๋‹ค๋ฅธ ์“ฐ๋ ˆ๋“œ์™€ code section, data section, and other operating-system resources ๊ณต์œ ํ•จ

 

2) Single / Multithreaded Processes

 

๊ฒฝ์šฐ์— ๋”ฐ๋ผ ๋‹จ์ผ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์œ ์‚ฌํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์›น ์„œ๋ฒ„๋Š” ์›น ํŽ˜์ด์ง€, ์ด๋ฏธ์ง€, ์†Œ๋ฆฌ ๋“ฑ์— ๋Œ€ํ•œ ์š”์ฒญ์„ ์ˆ˜๋ฝํ•ด์•ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ํ•œ ๊ฐ€์ง€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์€ ์„œ๋ฒ„๋ฅผ ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ์„ ์ˆ˜๋ฝํ•˜๋Š” ๋‹จ์ผ ํ”„๋กœ์„ธ์Šค๋กœ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์„œ๋ฒ„๋Š” ์š”์ฒญ์„ ์ˆ˜์‹ ํ•  ๋•Œ ํ•ด๋‹น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ณ„๋„์˜ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด ์ ‘๊ทผ ๋ฐฉ์‹์—๋Š” ํ”„๋กœ์„ธ์Šค ์ƒ์„ฑ์— ๋ฆฌ์†Œ์Šค๊ฐ€ ๋งŽ์ด ์†Œ๋ชจ๋˜๊ณ  ์‹œ๊ฐ„์ด ๋งŽ์ด ์†Œ์š”๋˜๋ฏ€๋กœ ๋ช‡ ๊ฐ€์ง€ ๋‹จ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์€ ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋”ฉ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ์ ‘๊ทผ ๋ฐฉ์‹์—์„œ ์›น ์„œ๋ฒ„ ํ”„๋กœ์„ธ์Šค๋Š” ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ์„ ์ˆ˜์‹ ํ•˜๊ธฐ ์œ„ํ•ด ๋ณ„๋„์˜ ์Šค๋ ˆ๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์š”์ฒญ์ด ์žˆ์„ ๋•Œ ์„œ๋ฒ„๋Š” ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๋Œ€์‹  ์ถ”๊ฐ€ ์š”์ฒญ์„ ๊ณ„์† ์ˆ˜์‹ ํ•˜๋Š” ๋™์•ˆ ํ•ด๋‹น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•  ์ƒˆ ์Šค๋ ˆ๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์€ ๊ฐ ์š”์ฒญ์— ๋Œ€ํ•ด ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ๋ณด๋‹ค ๋” ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค. ๋ฆฌ์†Œ์Šค ๋ฐ ์‹œ๊ฐ„ ์ธก๋ฉด์—์„œ ์Šค๋ ˆ๋“œ ์ƒ์„ฑ ๋น„์šฉ์ด ๋œ ๋“ค๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋˜ํ•œ ์Šค๋ ˆ๋“œ๋Š” ๋™์ผํ•œ ํ”„๋กœ์„ธ์Šค ๋‚ด์—์„œ ๋ฉ”๋ชจ๋ฆฌ์™€ ๋ฆฌ์†Œ์Šค๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋Œ€๋ถ€๋ถ„์˜ os system kernel์€ ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ์ž„

 

๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ์˜ ์žฅ์ 

  • Responsiveness : ์ผ๋ถ€๊ฐ€ ๋ง‰ํžˆ๊ฑฐ๋‚˜ ๋„ˆ๋ฌด ์˜ค๋žœ ์‹œ๊ฐ„ ์ˆ˜ํ–‰ํ•˜๋”๋ผ๋„ ๊ณ„์† ์‹คํ–‰์ด ๊ฐ€๋Šฅํ•จ
  • Resource Sharing : ํ”„๋กœ์„ธ์Šค๋Š” shared memory์™€ message passing๊ณผ ๊ฐ™์€ ๊ธฐ์ˆ ์„ ํ†ตํ•ด ๋ฆฌ์†Œ์Šค๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ์Œ
  • Economy : threads๊ฐ€ resource๋ฅผ ๊ณต์œ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, context-switch, create thread๊ฐ€ ๋”์šฑ ๊ฒฝ์ œ์ ์ž„ 
  • Scalability : ์“ฐ๋ ˆ๋“œ๊ฐ€ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์‹ฑ core์—์„œ ํ‰ํ–‰ํ•˜๊ฒŒ ์‹คํ–‰๋˜๋Š” ๋ฉ€ํ‹ฐํ”„๋กœ์„ธ์„œ ์ƒ์—์„œ ๋” greater

 

1. Multicore Programming

1) Multicore Programming์ด๋ž€

: ์—ฌ๋Ÿฌ computing cores๋ฅผ ๋ณด๋‹ค ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ณ  concurrency(๋™์‹œ์„ฑ)์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ๋งค์ปค๋‹ˆ์ฆ˜

  • single computing core
    • ์‹œ๊ฐ„๋‹น ์“ฐ๋ ˆ๋“œ 1๊ฐœ ์ˆ˜ํ–‰. ํ”„๋กœ์„ธ์‹ฑ ์ฝ”์–ด๊ฐ€ ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์“ฐ๋ ˆ๋“œ ์‹คํ–‰์ด interleaved ๋จ (์—ฌ๋Ÿฌ๊ฐœ ๋Œ์•„๊ฐ€๋Š” ์ฒ™!!!)
  • multiple cores
    • ์“ฐ๋ ˆ๋“œ n๊ฐœ ๋™์‹œ ์ˆ˜ํ–‰. ์‹œ์Šคํ…œ์ด ๊ฐ ์ฝ”์–ด์— ๋ณ„๋„์˜ ์Šค๋ ˆ๋“œ๋ฅผ ํ• ๋‹นํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ผ๋ถ€ ์Šค๋ ˆ๋“œ๊ฐ€ ๋ณ‘๋ ฌ์ ์œผ๋กœ ์‹คํ–‰๋  ์ˆ˜ ์žˆ์Œ
  • Parallelism : ์‹œ์Šคํ…œ์ด ๋‘ ๊ฐœ ์ด์ƒ์˜ ์ž‘์—…์„ ๋™์‹œ์— ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Œ
  • Concurrency : ๋ชจ๋“  ์ž‘์—…์ด ์ง„ํ–‰๋˜๋„๋ก ํ—ˆ์šฉํ•˜์—ฌ ๋™์‹œ์— ๋‘˜ ์ด์ƒ์˜ ์ž‘์—…์„ ์ง€์›ํ•จ

multicore system์„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ•  ๋•Œ ํ•ด๊ฒฐํ•ด์•ผ ํ•˜๋Š” 5๊ฐ€์ง€ ์˜์—ญ

1. Identifying tasks

โœ“ To find areas that can be divided into separate, concurrent tasks

2. Balance

โœ“ Ensure that the tasks perform equal work of equal value

3. Data splitting

โœ“ The data accessed and manipulated by the tasks must be divided to run on separate cores

4. Data dependency

โœ“ The data accessed by the tasks must be examined for dependencies between two or more tasks

5. Testing and debugging

โœ“ Testing and debugging such concurrent programs is inherently more difficult than testing and debugging single-threaded applications

 

 

Parallelism์˜ ์ข…๋ฅ˜

  • Data parallelism
    • ๊ฐ™์€ ๋ฐ์ดํ„ฐ๋ฅผ multiple computing core๋กœ ๋‚˜๋ˆ ์„œ ๊ฐ core๊ฐ€ ๊ฐ™์€ operation์„ ์ˆ˜ํ–‰ํ•จ
  • Task parallelism
    • data๋ฅผ ๋‚˜๋ˆ„์ง€ ์•Š๊ณ , task๋ฅผ ๊ฐ core๊ฐ€ ๋‚˜๋ˆ ๊ฐ€์ง (๋™์ผ ๋ฐ์ดํ„ฐ ๋‹ค๋ฅธ operation)

 

 

2) Amdahl's Law 

: ์ถ”๊ฐ€์ ์œผ๋กœ computing core๋ฅผ ์ถ”๊ฐ€ํ–ˆ์„ ๋•Œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” performance(์†๋„ ํ–ฅ์ƒ) ๊ณ„์‚ฐํ•˜๋Š” ๊ณต์‹

S : portion of the application that must be performed serially on a system (๋ฌด์กฐ๊ฑด ์‹œํ€€์…œํ•˜๊ฒŒ ์ˆ˜ํ–‰๋˜์–ด์•ผํ•˜๋Š” ๊ฒƒ์˜ ์ˆ˜)

N : processing core ์ˆ˜ 

 

ํ”„๋กœ๊ทธ๋žจ์ด ๋‘ ๋ถ€๋ถ„์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋Š”๋ฐ ๊ทธ ์ค‘ ํ•˜๋‚˜๋Š” ๋ณ‘๋ ฌํ™”ํ•  ์ˆ˜ ์žˆ๊ณ  ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” ๋ณ‘๋ ฌํ™”ํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ์ž„. ์ตœ๋Œ€ ์†๋„ ํ–ฅ์ƒ์€ ๋ณ‘๋ ฌํ™”ํ•  ์ˆ˜ ์—†๋Š” ๋ถ€๋ถ„์— ์˜ํ•ด ๊ฒฐ์ •๋จ. 

 

N์ด ๋ฌดํ•œ๋Œ€๋กœ ๊ฐ€๋ฉด, speed up coverge๋Š” 1 / S๋กœ ์ˆ˜๋ ดํ•จ. 

์ผ๋ถ€๋Š” Amdahl's Law๊ฐ€ ํ•˜๋“œ์›จ์–ด์˜ ํ–ฅ์ƒ์„ ๊ณ ๋ คํ•˜์ง€ ์•Š์•˜๋‹ค๊ณ  ๋งํ•˜๊ธฐ๋„...

S๊ฐ€ ํด ์ˆ˜๋ก, ์ฆ‰ ๋ณ‘๋ ฌํ™” ๋ถˆ๊ฐ€๋Šฅํ•œ ๊ฒƒ์ด 50%๋ฉด ์ตœ๋Œ€ 2๋ฐฐ๊นŒ์ง€๋งŒ ์ฆ๊ฐ€ํ•  ์ˆ˜ ์žˆ์Œ

 

2. Multithreading Models

 

User Threads : ์ปค๋„ ์œ„์—์„œ ์ง€์›๋˜๋ฉฐ ์ปค๋„ ์ง€์› ์—†์ด ๊ด€๋ฆฌ๋จ

 

kernal space: core์™€ ์—ฐ๊ฒฐํ•˜๋Š” bridge ์—ญํ• ์„ ํ•จ. ์ด ์•ˆ์— ์ปค๋„ ๋ ˆ๋ฒจ ์Šค๋ ˆ๋“œ๊ฐ€ ์กด์žฌํ•จ

์ด ์œ„์— ์žˆ๋Š” user space์— ์žˆ๋Š” ๊ฒƒ์ด ์œ ์ € ๋ ˆ๋ฒจ ์Šค๋ ˆ๋“œ!

 

Thread library๋Š” thread๋ฅผ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ์—†์• ๋Š” ์ฝ”๋“œ, threads๊ฐ„ ๋ฐ์ดํ„ฐ์™€ ๋ฉ”์‹œ์ง€๋ฅผ ๋„˜๊ฒจ์ฃผ๋Š” ์ฝ”๋“œ, thread execution์„ ์Šค์ผ€์ค„๋งํ•˜๋Š” ์ฝ”๋“œ, thread context๋ฅผ ์ €์žฅํ•˜๊ฑฐ๋‚˜ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ฝ”๋“œ๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์Œ

 

์žฅ์  

  • Thread switching ํ•  ๋•Œ kernel mode ๊ถŒํ•œ์„ ํ•„์š”๋กœ ํ•˜์ง€ ์•Š๋Š”๋‹ค
  • ์œ ์ € ์Šค๋ ˆ๋“œ๋Š” ์–ด๋Š os์—์„œ๋‚˜ ์‹คํ–‰๋œ๋‹ค
  • ์œ ์„œ ์Šค๋ ˆ๋“œ๋Š” ๋งŒ๋“ค๊ณ  ๊ด€๋ฆฌํ•˜๋Š”๊ฒŒ ๋น ๋ฅด๋‹ค

๋‹จ์ 

  • ํ•œ ์œ ์ € ์Šค๋ ˆ๋“œ๊ฐ€ blocking operation์„ ์ˆ˜ํ–‰ํ•˜๋ฉด ๋ชจ๋“  ํ”„๋กœ์„ธ์Šค๊ฐ€ blocked ๋œ๋‹ค
  • ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ application์€ multiprocessing์˜ ์ด์ ์„ ๊ฐ–์ง€ ๋ชปํ•œ๋‹ค.
    • user thread๋Š” user level์—์„œ ๊ด€๋ฆฌ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์šด์˜ ์ฒด์ œ๊ฐ€ multiple process๋ฅผ ๋„˜์–ด์„œ scheduling thread ํ•  ์ˆ˜ ์—†์Œ. ๋”ฐ๋ผ์„œ user thread๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์€ ๋ฉ€ํ‹ฐํ”„๋กœ์„ธ์‹ฑ์„ ํ™œ์šฉํ•˜๊ธฐ ์–ด๋ ค์›€

 

kernel threads : OS์— ์˜ํ•ด ์ง์ ‘์ ์œผ๋กœ ์ง€์›๋˜๊ณ  ๊ด€๋ฆฌ๋˜๋Š” ์Šค๋ ˆ๋“œ

 

์žฅ์ 

  • ์ปค๋„ ์Šค๋ ˆ๋“œ์˜ ์„œ๋กœ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์„œ์—์„œ ๋™์ผํ•œ ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ๋ฅผ ์Šค์ผ€์ค„๋ง ํ•  ์ˆ˜ ์žˆ์Œ
  • ํ•œ ํ”„๋กœ์„ธ์Šค๊ฐ€ blocked ๋˜์–ด๋„, ์ปค๋„์ด ๊ฐ™์€ ํ”„๋กœ์„ธ์Šค์˜ ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ๋กœ ์Šค์ผ€์ค„๋ง ํ•  ์ˆ˜ ์žˆ์Œ

๋‹จ์ 

  • ํ•œ ์Šค๋ ˆ๋“œ์—์„œ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋กœ ์ „์†กํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ปค๋„ ๋ชจ๋“œ๋กœ switch ํ•ด์•ผํ•จ
  • ์Šค๋ ˆ๋“œ operation์ด user thread์— ๋น„ํ•ด 100๋ฐฐ ์ด์ƒ ๋Š๋ฆผ

์ปค๋„์ด ์‚ฌ์šฉ์ž ์ˆ˜์ค€ ์Šค๋ ˆ๋“œ์˜ ์กด์žฌ๋ฅผ ์ธ์‹ํ•˜์ง€ ๋ชปํ•˜๊ณ  ์Šค๋ ˆ๋“œ๊ฐ€ ์•„๋‹Œ ํ”„๋กœ์„ธ์Šค๋ฅผ ์˜ˆ์•ฝํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ์ž ์Šค๋ ˆ๋“œ๊ฐ€ ์žˆ๋Š” ๋‹ค์ค‘ ์Šค๋ ˆ๋“œ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์—์„œ ๋‹ค์ค‘ ์ฒ˜๋ฆฌ๋ฅผ ์ตœ๋Œ€ํ•œ ํ™œ์šฉํ•˜๊ธฐ ์–ด๋ ต์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ปค๋„์ด ํ”„๋กœ์„ธ์Šค ๋‚ด์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์Šค๋ ˆ๋“œ ์ˆ˜์— ๊ด€๊ณ„์—†์ด ํ”„๋กœ์„ธ์Šค์—์„œ ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ ์˜ˆ์•ฝํ•  ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๊ฒฐ๊ณผ์ ์œผ๋กœ ์‹œ์Šคํ…œ์— ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํ”„๋กœ์„ธ์„œ๊ฐ€ ์žˆ๋”๋ผ๋„ ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ณ  ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์„œ๋Š” ์œ ํœด ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฐ˜๋Œ€๋กœ ์ปค๋„ ์ˆ˜์ค€ ์Šค๋ ˆ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ปค๋„์ด ํ”„๋กœ์„ธ์Šค์˜ ๋ชจ๋“  ์Šค๋ ˆ๋“œ๋ฅผ ์ธ์‹ํ•˜๊ณ  ์—ฌ๋Ÿฌ ํ”„๋กœ์„ธ์„œ์—์„œ ์Šค๋ ˆ๋“œ๋ฅผ ๋ณด๋‹ค ํšจ์œจ์ ์œผ๋กœ ์˜ˆ์•ฝํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์Šค๋ ˆ๋“œ๊ฐ€ ๋™์‹œ์— ์‹คํ–‰๋˜๊ณ  ๋‹ค์ค‘ ์ฒ˜๋ฆฌ๋ฅผ ์ตœ๋Œ€ํ•œ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ์ปค๋„ ์ˆ˜์ค€ ์Šค๋ ˆ๋“œ๋Š” ์‚ฌ์šฉ์ž ์ˆ˜์ค€ ์Šค๋ ˆ๋“œ์—์„œ๋Š” ๋ถˆ๊ฐ€๋Šฅํ•œ ์ „์ฒด ํ”„๋กœ์„ธ์Šค๋ฅผ ์ฐจ๋‹จํ•˜์ง€ ์•Š๊ณ  ์ฐจ๋‹จ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

1) Many-to-One Model

 

์—ฌ๋Ÿฌ๊ฐœ์˜ user thread - ํ•˜๋‚˜์˜ kernel thread

ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ ์ปค๋„์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ multicore system ์ƒ์—์„œ ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ๋ฅผ ๋ณ‘๋ ฌ๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์—†์Œ.

 

2) One-to-One Model

user thread - kernel thread 1๋Œ€1 ๋Œ€์‘

many to one ๋ณด๋‹ค concurrency ! ๋™์‹œ์— ์—ฌ๋Ÿฌ ์ž‘์—… ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ

multiprocessor ์—์„œ parallel ํ•˜๊ฒŒ ์‹คํ–‰๋จ

์ด ๋ชจ๋ธ์˜ ์œ ์ผํ•œ ๋‹จ์ ์€ ์œ ์ € ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•˜๋ ค๋ฉด ํ•ด๋‹น ์ปค๋„ ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•˜๋ฉฐ,  ์ปค๋„ ์Šค๋ ˆ๋“œ๊ฐ€ ๋งŽ์•„์ ธ ์‹œ์Šคํ…œ ์„ฑ๋Šฅ์— ๋ถ€๋‹ด์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ž„

 

3) Many-to-Many Model

 

one-to-one๊ณผ many-to-many์˜ ๋‹จ์ ์„ ํ•ด๊ฒฐํ•จ

์œ ์ € ์Šค๋ ˆ๋“œ๋Š” ๊ทธ๊ฒƒ๊ณผ ๊ฐ™๊ฑฐ๋‚˜ ์ ์€ ์ˆ˜์˜ kernel thread์™€ ์—ฐ๊ฒฐ๋จ. kernel thread์˜ ์ˆ˜๋Š” application์ด๋‚˜ machine์— ๋”ฐ๋ผ ๊ฒฐ์ •๋  ์ˆ˜ ์žˆ์Œ

 

โ—ฆ many-to-one model์€ ๊ฐœ๋ฐœ์ž๊ฐ€ ์›ํ•˜๋Š” ๋งŒํผ์˜ ์œ ์ € ์Šค๋ ˆ๋“œ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์ง€๋งŒ ์ปค๋„์ด ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์ปค๋„ ์Šค๋ ˆ๋“œ๋งŒ ์˜ˆ์•ฝํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์ง€ ์•Š์Œ
โ—ฆ one-to-one model ์€ ๋” ํฐ ๋™์‹œ์„ฑ์„ ํ—ˆ์šฉํ•˜์ง€๋งŒ ์‘์šฉํ”„๋กœ๊ทธ๋žจ ๋‚ด์— ๋„ˆ๋ฌด ๋งŽ์€ ์Šค๋ ˆ๋“œ๋ฅผ ๋งŒ๋“ค๊ฒŒ ๋  ์ˆ˜๋„ ์žˆ์Œ


• many-to-many model์€
โ—ฆ ๊ฐœ๋ฐœ์ž๋Š” ํ•„์š”ํ•œ ๋งŒํผ์˜ ์‚ฌ์šฉ์ž ์Šค๋ ˆ๋“œ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ํ•ด๋‹น ์ปค๋„ ์Šค๋ ˆ๋“œ๋Š” ๋ฉ€ํ‹ฐํ”„๋กœ์„ธ์„œ์—์„œ ๋ณ‘๋ ฌ๋กœ ์‹คํ–‰
โ—ฆ ๋˜ํ•œ ์Šค๋ ˆ๋“œ๊ฐ€ blocking system call์„ ์ˆ˜ํ–‰ํ•ด๋„ ์ปค๋„์€ ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์˜ ์‹คํ–‰์„ scheldule ํ•  ์ˆ˜ ์žˆ์Œ

 

4) Two-level Model

many-to-many model๊ณผ ๊ฑฐ์˜ ์œ ์‚ฌํ•˜์ง€๋งŒ, ํ•˜๋‚˜์˜ ์œ ์ € ์Šค๋ ˆ๋“œ๊ฐ€ ํ•˜๋‚˜์˜ ์ปค๋„ ์Šค๋ ˆ๋“œ๋ฅผ ๋‹ด๋‹นํ•  ์ˆ˜๋„ ์žˆ์Œ