CS/Operating System

[์šด์˜์ฒด์ œ] ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ, Blocking๊ณผ Non-Blocking

๊ฐœ๋ฐœ๊ฐœ๊ตด๐Ÿธ 2022. 10. 19. 18:21


๋™๊ธฐ VS ๋น„๋™๊ธฐ

๋™๊ธฐ๋Š” ์ˆœ์ฐจ์ , ์ง๋ ฌ์ ์œผ๋กœ ํ…Œ์Šคํฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜์ง€๋งŒ ๋น„๋™๊ธฐ๋Š” ๋ณ‘๋ ฌ์ ์œผ๋กœ ํ…Œ์Šคํฌ๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

 

๋™๊ธฐ(Synchronous)๋ž€? 

๋™๊ธฐ๋Š” ์š”์ฒญ์„ ๋ณด๋‚ธ ํ›„ ์‘๋‹ต(๊ฒฐ๊ณผ๋ฌผ)์„ ๋ฐ›์•„์•ผ์ง€๋งŒ ๋‹ค์Œ ๋™์ž‘์ด ์ด๋ฃจ์–ด์ง€๋Š” ๋ฐฉ์‹์„ ๋งํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ๋ชจ๋“  ์ผ์€ ์ˆœ์ฐจ์ ์œผ๋กœ ์‹คํ–‰๋˜๋ฉฐ ์–ด๋–ค ์ž‘์—…์ด ์ˆ˜ํ–‰์ค‘์ด๋ผ๋ฉด ๋‹ค์Œ ์ž‘์—…์€ ๋Œ€๊ธฐํ•ฉ๋‹ˆ๋‹ค.

  • ์žฅ์ : ์„ค๊ณ„๊ฐ€ ๊ฐ„๋‹จํ•˜๊ณ  ์ง๊ด€์ 
  • ๋‹จ์ : ๊ฒฐ๊ณผ๋ฅผ ๋ณผ๋•Œ ๊นŒ์ง€ ์•„๋ฌด๊ฒƒ๋„ ๋ชปํ•˜๊ณ  ๋Œ€๊ธฐ

 

๋น„๋™๊ธฐ(Asynchronous)๋ž€? 

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

  • ์žฅ์ : ๊ฒฐ๊ณผ๊ฐ€ ์ฃผ์–ด์ง€๋Š” ๋ฐ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฌ๋”๋ผ๋„ ๊ทธ๋™์•ˆ ๋‹ค๋ฅธ ์ž‘์—…์ด ๊ฐ€๋Šฅํ•ด ์ž์›์„ ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉ
  • ๋‹จ์ : ์„ค๊ณ„๊ฐ€ ๋™๊ธฐ๋ณด๋‹ค ๋ณต์žกํ•จ

 


Blocking VS Non-Blocking

Blocking/Non-Blocking์€ ๋™๊ธฐ/๋น„๋™๊ธฐ์™€ ๋‹ค๋ฅธ ๊ด€์ ์œผ๋กœ, ๋‚ด๊ฐ€ ์ง์ ‘ ์ œ์–ดํ•  ์ˆ˜ ์—†๋Š” ๋Œ€์ƒ(IO, ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ)์„ ์ƒ๋Œ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๋ถ„๋ฅ˜์ž…๋‹ˆ๋‹ค. Blocking์€ ๋Œ€์ƒ์˜ ์ž‘์—…์ด ๋๋‚  ๋•Œ๊นŒ์ง€ ์ œ์–ด๊ถŒ์„ ๋Œ€์ƒ์ด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•˜๋ฉฐ Non-Blocking์€ ๋Œ€์ƒ์˜ ์ž‘์—… ์™„๋ฃŒ์—ฌ๋ถ€์™€ ์ƒ๊ด€์—†์ด ์ƒˆ๋กœ์šด ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

 

Blocking์ด๋ž€? 

์ง์ ‘ ์ œ์–ดํ•  ์ˆ˜ ์—†๋Š” ๋Œ€์ƒ์˜ ์ž‘์—…์ด ๋๋‚  ๋•Œ๊นŒ์ง€ ์ œ์–ด๊ถŒ์„ ๋„˜๊ฒจ์ฃผ์ง€ ์•Š๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

์˜ˆ๋ฅผ ๋“ค์–ด ์•„๋ž˜์™€ ๊ฐ™์ด ํ˜ธ์ถœํ•˜๋Š” ํ•จ์ˆ˜๊ฐ€ I/O ์ž‘์—…์„ ์š”์ฒญํ•  ๋•Œ I/O ์ฒ˜๋ฆฌ๊ฐ€ ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ์•„๋ฌด ์ผ๋„ ํ•˜์ง€ ๋ชปํ•˜๊ณ  ๊ธฐ๋‹ค๋ฆฌ๋Š” ๊ฒƒ์„ ๋งํ•ฉ๋‹ˆ๋‹ค.

 

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

 

Non-Blocking์ด๋ž€? 

์ง์ ‘ ์ œ์–ดํ•  ์ˆ˜ ์—†๋Š” ๋Œ€์ƒ์˜ ์ž‘์—…์ฒ˜๋ฆฌ ์—ฌ๋ถ€์™€ ์ƒ๊ด€์ด ์—†์Šต๋‹ˆ๋‹ค.

 

์˜ˆ๋ฅผ ๋“ค์–ด ์•„๋ž˜์™€ ๊ฐ™์ด ํ˜ธ์ถœํ•˜๋Š” ํ•จ์ˆ˜๊ฐ€ I/O ์ž‘์—…์„ ์š”์ฒญํ•œ ๋’ค I/O ์ž‘์—…์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ ์™„๋ฃŒ ์—ฌ๋ถ€์™€ ์ƒ๊ด€์—†์ด ๋ฐ”๋กœ ์ž์‹ ์˜ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์„ ๋งํ•ฉ๋‹ˆ๋‹ค.

 

  • ์žฅ์ : ๋ฆฌ์†Œ์Šค๊ฐ€ ๋‚ญ๋น„๋˜๋Š” ์‹œ๊ฐ„์ด ์—†๊ธฐ์—, ํ•˜๋“œ์›จ์–ด ๋ฆฌ์†Œ์Šค๋ฅผ ๊ท ์ผํ•˜๊ณ  ํšจ์œจ์ ์œผ๋กœ ์ด์šฉ ๊ฐ€๋Šฅ
  • ๋‹จ์ : ์—…๋ฌดํ๋ฆ„์ด ๋งค์šฐ ๋ณต์žกํ•ด์ง€๋Š” ๋‹จ์ ์ด ์กด์žฌ

 

 

 

[์ฐธ๊ณ ]

https://velog.io/@tess/Sync-Async-vs-Blocking-non-Blocking

 

Sync, Async vs Blocking, non-Blocking

ํ•ด๋‹น ๋ธ”๋กœ๊น…์€ \[10๋ถ„ ํ…Œ์ฝ”ํ†ก\] ๐ŸŽง ์šฐ์˜ Block vs Non-Block & Sync vs Async

velog.io

https://velog.io/@alicia-mkkim/%EB%8F%99%EA%B8%B0-%EB%B9%84%EB%8F%99%EA%B8%B0%EB%9E%80

 

๋™๊ธฐ, ๋น„๋™๊ธฐ๋ž€

๋™๊ธฐ๋Š” ์ˆœ์ฐจ์ , ์ง๋ ฅ์ ์œผ๋กœ ํ…Œ์Šคํฌ๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.๋น„๋™๊ธฐ๋Š” ๋ณ‘๋ ฌ์ ์œผ๋กœ ํ…Œ์Šคํฌ๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.๋™๊ธฐ๋Š” ์š”์ฒญ์„ ๋ณด๋‚ธ ํ›„ ์‘๋‹ต (๊ฒฐ๊ณผ๋ฌผ)์„ ๋ฐ›์•„์•ผ์ง€๋งŒ ๋‹ค์Œ ๋™์žฅ์ด ์ด๋ฃจ์–ด์ง€๋Š” ๋ฐฉ์‹์„ ๋งํ•œ๋‹ค.๋ชจ๋“  ์ผ์€

velog.io

https://iceflower.gitbooks.io/vertx-studybook/content/thread-safe.html

 

[๊ธฐ๋ณธ๊ฐœ๋…] ๋ธ”๋กœํ‚น/๋…ผ๋ธ”๋กœํ‚น, ๋™๊ธฐ/๋น„๋™๊ธฐ · vertx studybook

 

iceflower.gitbooks.io

https://velog.io/@guswns3371/%EC%9A%B4%EC%98%81%EC%B2%B4%EC%A0%9C-Synchronous%EC%99%80-Asynchronous-Blocking%EA%B3%BC-Non-Blocking

 

[์šด์˜์ฒด์ œ] Synchronous์™€ Asynchronous , Blocking๊ณผ Non-Blocking

https://velog.io/@guswns3371/Blocking-vs-Non-BlockingSynchronous-vs-Asynchronoushttps://velog.io/@codemcd/Sync-VS-Async-Blocking-VS-Non-Bloc

velog.io