โ๏ธ์ด ๊ธ์ ์ ๋ณด๋ ์ ํํ์ง ์์ ์ ์์ต๋๋ค. ๋ณด๋ค ์ ํํ ์ ๋ณด๋ฅผ ์ํ๋ฉด ๊ธ ํ๋จ์ ์๋ ์ถ์ฒ๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.
๋คํธ์ํฌ, ํ์ผ ๋ฑ ๊ฐ์ข I/O ์์ ์๋ง๋ค ์ฌ์ฉํ๋ async. async ๋์ UI thread๋ ๋ฉ์ถ์ง ์๊ณ , ์ฌ์ฉ์๋ ์ข์ ๊ฒฝํ์ ๊ฐ๋๋ค.
async๋ฅผ ์ฌ์ฉํ๋ฉด ์ด๋๊ฐ์ I/O task๊ฐ ์ ์ฅ๋๊ณ , I/O task๊ฐ ์๋ฃ๋๋ฉด ํ๋ก๊ทธ๋จ์ ์์ฒญํ์ฌ ์คํ๋๋ ๋ฏ์ด ๋ณด์ธ๋ค. ์ด ์ผ๋ จ์ ๊ณผ์ ์ด ์ด๋ป๊ฒ ์ฒ๋ฆฌ๋๋ ๊ฒ์ผ๊น? OS layer์์ thread๋ฅผ ํ์ฉํ์ฌ I/O task์ ์๋ฃ ์ฌ๋ถ๋ฅผ ๊ณ์ ํ์ธํ๋ ๊ฒ์ผ๊น?
Thread๋ ์๋ค.
ํ๋ก๊ทธ๋จ ์ฝ๋์์ ์์ฒญํ I/O ์์ ์ OS๋ฅผ ๊ฑฐ์ณ device driver์ ์ ๋ฌ๋๋ค. ์ด๋ OS์์ device driver๋ก ์ ๋ฌํ๋ ์์ฒญ์ด I/O Request Packet(IRP)๋ค. IRP๋ฅผ ๋ฐ์ device driver๋ device์ ์์ ์ ๋ช ๋ นํ๋ค. ์ฌ๊ธฐ์ async๊ฐ ๋ฐ์ํ๋ค. device driver๋ device์ ์์ ์๋ฃ ์ ๋ฌด์ ์๊ด์์ด IRP๋ฅผ pending ์ํ๋ก ์ฒ๋ฆฌํ๊ณ OS์ ์๋ตํ๋ค.
device๋ ๋ ๋ฆฝ์ ์ผ๋ก ์์ ์ ์ฒ๋ฆฌํ๋ค. ์์ ์ ์๋ฃํ๋ฉด CPU์๊ฒ interrupt๋ก ์๋ฆฐ๋ค. device๊ฐ ์์ฒด์ ์ผ๋ก processor๋ฅผ ๊ฐ๊ณ ์์ด ๊ฐ๋ฅํ๋ค. CPU๊ฐ ๋ฐ์ ์์ ์๋ฃ ๋ฉ์์ง๋ ํ๋ก๊ทธ๋จ ์ฝ๋๋ก ์ ๋ฌ๋๋ค. UI thread๋ pending ์ํ์ธ task๋ฅผ ์ ์ง ์์น๋ถํฐ ์คํํ๋ค.
์ถ์ฒ
https://blog.stephencleary.com/2013/11/there-is-no-thread.html
https://superuser.com/questions/800329/why-are-they-putting-processors-on-hard-drives
'Dev' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| React + MVVM (0) | 2023.01.11 |
|---|---|
| Implementing Async/Await From Scratch (0) | 2022.11.29 |
| Redux ๋์ getServerSideProps + SWR (0) | 2022.11.26 |
| ์ ์ฉํ ์ ๊ท์(RegExp) ๋ชจ์ (1) | 2022.11.24 |
| ์น ์ดํ๋ฆฌ์ผ์ด์ itch.io์ ์ ๋ก๋ํ๊ธฐ (0) | 2022.11.24 |