race-condition

  • race?

    • ๊ฒฝ์Ÿ.

  • race condition?

    • ๊ฒฝ์Ÿ ์ƒํƒœ

a race condition is a condition of a program where its behavior depends on relative timing or interleaving of multiple threads or processes

  • ์–ด๋–ค ํ”„๋กœ๊ทธ๋žจ์˜ ๋™์ž‘์ด, ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ๋‚˜ ํ”„๋กœ์„ธ์Šค์˜ ์ƒํ˜ธ ๋ฐฐ์น˜์ ์ด ๊ฑฐ๋‚˜ ์ƒ๋Œ€์ ์ธ ํƒ€์ด๋ฐ ๋•Œ๋ฌธ์— ๋‹ฌ๋ผ์ง€๋Š” ๊ฑธ ์˜๋ฏธ.

  • ์ฆ‰ ๊ฒฐ๊ณผ๊ฐ€ ์˜ˆ์ธกํ•œ๋Œ€๋กœ ๋‚˜์˜ค์ง€ ์•Š์Œ (๋ฒ„๊ทธ์ž„)

  • [[thread-safe]] ํ•˜๋‹ค๋Š” ๋ง์€ [[race-condition]] ์˜ ์ƒํƒœ์—์„œ ์ž์œ ๋กญ๋‹ค๋Š” ์˜๋ฏธ๋กœ ๋ด๋„ ๋˜๋Š”๋“ฏ.

Elimination

  • 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•์œผ๋กœ race condition์„ ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ์Œ.

    1. [[avoiding-shared-state]]

    2. Using Synchronizations and Atomic Operations

Conclusion

  • ์ „๋ฐ˜์ ์œผ๋กœ 2๊ฐœ์˜ ํƒ€์ž… ๋ชจ๋‘ ๊ณต์œ  ์ž์›์— ๋Œ€ํ•ด ๋ฐฐ์ œ๊ฐ€ ํ•„์š”ํ•œ ๋ถ€๋ถ„์ด๋ผ ์ƒ๊ฐ๋จ.

  • ์ฝ๊ธฐ๋ฅผ ํ•  ๋•Œ๋Š” ์ด๋Ÿฌํ•œ ๋ฐฐ์ œ๋ฅผ ํ•˜์ง€ ์•Š์•„๋„ ๋˜์ง€๋งŒ, ์“ฐ๊ธฐ๋ฅผ ํ•  ๋•Œ๋Š” ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์—์„œ ์นจ๋ฒ”ํ•˜์ง€ ๋ชปํ•˜๋„๋ก ๋ฐฐ์ œ ์‹œํ‚ค๋Š”๊ฒŒ ํ•„์š”ํ•  ์ง€๋„.

์ฐธ๊ณ 

Last updated