Process2 - hochan222/Everything-in-JavaScript GitHub Wiki

๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ”๋กœ๊ฐ€๊ธฐ2

Thread

  • A thread (or lightweight process) is a basic unit of CPU utilization
  • ํ”„๋กœ์„ธ์Šค ๋‚ด๋ถ€์— CPU ์ˆ˜ํ–‰ ๋‹จ์œ„๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ ์žˆ๋Š”๊ฒƒ
  • PCB์—์„œ Program Count๋ฅผ ์—ฌ๋Ÿฌ๊ฐœ๋‘ 
  • Thread์˜ ๊ตฌ์„ฑ
    • program counter
    • register set
    • stack space
  • Thread๊ฐ€ ๋™๋ฃŒ thread์™€ ๊ณต์œ ํ•˜๋Š” ๋ถ€๋ถ„(=task)
    • code section
    • data section
    • OS resources

์ „ํ†ต์ ์ธ ๊ฐœ๋…์˜ heavyweight process๋Š” ํ•˜๋‚˜์˜ thread๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” task๋กœ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

  • ๋‹ค์ค‘ ์Šค๋ ˆ๋“œ๋กœ ๊ตฌ์„ฑ๋œ ํƒœ์Šคํฌ ๊ตฌ์กฐ์—์„œ๋Š” ํ•˜๋‚˜์˜ ์„œ๋ฒ„ ์Šค๋ ˆ๋“œ๊ฐ€ blocked(waiting) ์ƒํƒœ์ธ ๋™์•ˆ์—๋„ ๋™์ผํ•œ ํƒœ์Šคํฌ ๋‚ด์˜ ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ๊ฐ€ ์‹คํ–‰(running) ๋˜์–ด ๋น ๋ฅธ ์ฒ˜๋ฆฌ๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ๋™์ผํ•œ ์ผ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋‹ค์ค‘ ์Šค๋ ˆ๋“œ๊ฐ€ ํ˜‘๋ ฅํ•˜์—ฌ ๋†’์€ ์ฒ˜๋ฆฌ์œจ(throughput)๊ณผ ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.
  • ์Šค๋ ˆ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ณ‘๋ ฌ์„ฑ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค.

Benefits of Threads

  • Responsiveness (์‘๋‹ต์„ฑ)
    • eg) multi-threaded Web (์›น๋ธŒ๋ผ์šฐ์ €) - if one thread is blocked(eg network) another thread continues(eg display)
  • Resource Sharing
  • Economy
    • creating & CPU switching thread (rather than a process)
    • solaris์˜ ๊ฒฝ์šฐ ์œ„ ๋‘๊ฐ€์ง€ overhead๊ฐ€ ๊ฐ๊ฐ 30๋ฐฐ 5๋ฐฐ
  • Utilization of MP(multi processor) Architectures