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

๐Ÿ’ป

(31)
Simple Diary - (1) ์ค‘๋ณต ์ œ๊ฑฐ (state, onChange ํ•ฉ์น˜๊ธฐ) ๋™์ž‘์ด ๋น„์Šทํ•œ state ํ•˜๋‚˜๋กœ ๋ฌถ๊ธฐ before const [author, setAuthor] = useState(""); const [content, setContent] = useState(""); return ( ์˜ค๋Š˜์˜ ์ผ๊ธฐ์žฅ { setAuthor(event.target.value); }} > { setContent(event.target.value); }} > ); after - ๊ฐ์ฒด๋กœ ๋งŒ๋“ค์–ด ์ƒˆ๋กœ์šด ๊ฐ์ฒด๋ฅผ setState๋กœ ์ „๋‹ฌ const [state, setState] = useState({ author: "", content: "", }); return ( ์˜ค๋Š˜์˜ ์ผ๊ธฐ์žฅ { setState({ author: event.target.value, content: state.content, })..
[์šด์˜์ฒด์ œ] Synchronization - 3. Spin lock๊ณผ Mutex lock, Mutex์™€ Semaphore mutex lock - lock์„ ์žก๊ธฐ ์œ„ํ•ด ์˜ค๋žœ ์‹œ๊ฐ„์„ ๊ธฐ๋‹ค๋ ค์•ผ ํ•  ๊ฒƒ ๊ฐ™์œผ๋ฉด ๋‹ค๋ฅธ ์ž‘์—…์„ ๋™์‹œ์— ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. - busy waiting ํ•˜์ง€ ๋ง๊ณ , blocking ๋˜์–ด ๊ธฐ๋‹ค๋ฆฌ์ž. - ์ž์›์„ ๋‹จ์‹œ๊ฐ„์— ์–ป์„ ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ ์ฐจ๋ผ๋ฆฌ spin lock์ด ํšจ๊ณผ์ ์ด๋‹ค. context switching์— ๋” ํฐ ์ž์›์„ ๋‚ญ๋น„ํ•˜๊ฒŒ ๋  ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ๋ฅผ ์ดˆ๋ž˜ํ•œ๋‹ค. spin lock - ๋ฌธ๋งฅ ๊ตํ™˜(context switching)์ด ์ผ์–ด๋‚˜์ง€ ์•Š๋Š”๋‹ค. - ๋‹ค๋ฅธ ์ž‘์—…์„ ๋™์‹œ์— ์ง„ํ–‰ํ•˜์ง€ ๋ชปํ•˜๊ณ  ์ง„์ž… ๊ฐ€๋Šฅํ•  ๋•Œ ๊นŒ์ง€ ๊ณ„์† ๊ธฐ๋‹ค๋ฆฌ๋Š” busy waiting ๋ฐฉ์‹์ด๋‹ค. - lock์„ ์žก์„ ๋•Œ ๊นŒ์ง€ ๋Š์ž„์—†๋Š” ๋ฌดํ•œ ๋ฃจํ”„๋ฅผ ํ†ตํ•ด critical section์— ์ง„์ž…์„ ์žฌ์‹œ๋„ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๊ฐ€ ๊ณ„์† CPU๋ฅผ ์ ์œ ํ•˜๊ณ  ์žˆ..
[์šด์˜์ฒด์ œ] Synchronization - 2 Spinlock : ์žก์œผ๋ ค๋Š” lock์ด avaliable ํ•ด ์งˆ ๋•Œ ๊นŒ์ง€ ๊ณ„์† ๋ฃจํ”„๋ฅผ ๋Œ๋ฉฐ ์ง„์ž…์„ ์žฌ์‹œ๋„ํ•œ๋‹ค. ์ด๋ฅธ๋ฐ” ๋ฐ”์˜๊ฒŒ ๊ธฐ๋‹ค๋ฆฌ๋Š” busy waiting์˜ ํ•œ ์ข…๋ฅ˜์ด๋‹ค. Busy waiting : lock์„ ์žก๊ธฐ ์œ„ํ•ด ๋‹ค๋ฅธ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š๊ณ  ๊ณ„์†ํ•ด์„œ ๊ธฐ๋‹ค๋ฆฌ๋Š” ๊ฒฝ์šฐ. Sofrware-only Algorithm Peterson's Algorithm ๋™๊ธฐํ™” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์ฒ˜์Œ์œผ๋กœ ๊ณ ์•ˆ๋œ ๋ฐฉ๋ฒ• ์˜ค์ง ๋‘๊ฐœ์˜ context๋งŒ์ด ์กด์žฌํ•˜๋Š” ์ƒํ™ฉ์„ ๊ฐ€์ •ํ•œ๋‹ค. ์ „์—ญ๋ณ€์ˆ˜ flag, turn ์„ ์–ธ flag: critical section์— ๋“ค์–ด๊ฐˆ ์ค€๋น„๊ฐ€ ๋˜์—ˆ๋Š”์ง€, flag[0] = true; turn: ๋ˆ„๊ฐ€ critical section์— ๋“ค์–ด๊ฐˆ ์ฐจ๋ก€์ธ์ง€ ๋ฌธ์ œ์  ๋‘๊ฐœ์˜ context๋งŒ ์กด์žฌํ•˜๋Š” ์ƒํ™ฉ์—์„œ๋งŒ ๊ฐ€๋Šฅ ..
[์šด์˜์ฒด์ œ] Synchronization - 1 ํ•˜๋‚˜์˜ address space์— ์„œ๋กœ ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ๋“ค์ด ๋™์‹œ์— ์ ‘๊ทผํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. Race Condition ๋‘ ๊ฐœ ์ด์ƒ ํ”„๋กœ์„ธ์Šค/์Šค๋ ˆ๋“œ๊ฐ€ shared resource์— ๋™์‹œ์— concurrentํ•˜๊ฒŒ ์ ‘๊ทผํ•จ์œผ๋กœ์จ ๊ฒฐ๊ณผ ๊ฐ’์ด ํ™•์ • ๋˜์ง€๊ฐ€ ์•Š๊ณ , ๊ทธ๋•Œ ๊ทธ๋•Œ ์‹คํ–‰ํ•  ๋•Œ๋งˆ๋‹ค ์กฐ๊ธˆ์”ฉ ๋ฐ”๋€Œ๋Š” ํ˜„์ƒ ๋‘ ๊ฐœ ์ด์ƒ์˜ concurrent ํ•œ ํ”„๋กœ์„ธ์Šค, ์Šค๋ ˆ๋“œ๋“ค์ด ๊ณต์œ  ์ž์›์— ์ ‘๊ทผ ํ•  ๋•Œ ๋™๊ธฐํ™” ํ•ด๊ฒฐ ๊ณผ์ •์—†์ด ์ˆ˜ํ–‰ํ•˜๋Š” ์ƒํ™ฉ race condition์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ๋ฒ• → synchronization Critical Section ์ฝ”๋“œ์—์„œ ๋‘๊ฐœ ์ด์ƒ์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋™์‹œ์— ๋ฆฌ์†Œ์Šค๋ฅผ ์—…๋ฐ์ดํŠธ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ตฌ๊ฐ„. ๊ฐ ํ”„๋กœ์„ธ์Šค์—์„œ ๊ณต์œ  ๋ฐ์ดํ„ฐ์— ์ ‘๊ทผํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ ์ฝ”๋“œ ๋ถ€๋ถ„. ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์Šค๋ ˆ๋“œ๊ฐ€ ์ˆ˜ํ–‰๋˜๋Š” ํ”„๋กœ๊ทธ๋žจ์—์„œ ๊ฐ ํ”„๋กœ..
[์šด์˜์ฒด์ œ] Real-time System์ด๋ž€? Real-time Task : ์‹œ์Šคํ…œ์ด ์ฒ˜๋ฆฌํ•˜๋Š” ์ผ์ด deadline์ด ์กด์žฌํ•˜๊ฑฐ๋‚˜ ์‹œ๊ฐ„์— ๋Œ€ํ•ด์„œ ์–ด๋Š ์‹œ๊ฐ„ ๋‚ด๋กœ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•˜๋Š” ๊ทธ๋Ÿฐ ๋ฅ˜์˜ specification์ด ์ •ํ•ด์ง€๋Š” ์ผ๋“ค. Real-time Task๋“ค์ด ์žˆ๋Š” System => Real-time System Soft real-time systems ex) linux real-time task ์™€ Non-real-time task๋“ค์ด ํ˜ผ์žฌ๋˜์–ด ์žˆ๋Š” ์ƒํ™ฉ์—์„œ, ์‹œ์Šคํ…œ์ด real-time task๋ฅผ ์กฐ๊ธˆ ๋” ์‹ ๊ฒฝ์จ์„œ ์ฒ˜๋ฆฌํ•ด ์ฃผ๊ธฐ๋Š” ํ•˜์ง€๋งŒ, ๋ฌด์กฐ๊ฑด deadline์— ๋งž์ถฐ์„œ ๋๋‚ด์ค„๊ฑฐ๋ผ๋Š” ๋ณด์žฅ์ด ์—†๋Š” ์‹œ์Šคํ…œ. real-time task๋ฅผ ์กฐ๊ธˆ ๋” ๊ณ ๋ ค ํ•˜๊ฒ ์œผ๋‚˜, 100ํผ ๋ณด์žฅ ๋ชปํ•จ. real-time์„ ์•„์˜ˆ ์ œ๊ณตํ•˜์ง€ ์•Š์ง„ ์•Š์Œ. Hard real-time s..
[ERROR] - git push ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ error: failed to push some refs to / fatal: refusing to merge unrelated histories ๋ณ‘ํ•ฉ -> git push origin ๋ธŒ๋Ÿฐ์น˜๋ช… git pull origin ๋ธŒ๋Ÿฐ์น˜๋ช… --allow-unrelated-histories
ํž™(Heap) ์™„์ „ ์ด์ง„ ํŠธ๋ฆฌ์˜ ์ผ์ข…์œผ๋กœ ์šฐ์„ ์ˆœ์œ„ ํ๋ฅผ ์œ„ํ•˜์—ฌ ๋งŒ๋“ค์–ด์ง„ ์ž๋ฃŒ๊ตฌ์กฐ ์ตœ๋Œ€๊ฐ’๊ณผ ์ตœ์†Œ๊ฐ’์„ ์‰ฝ๊ฒŒ ์ถ”์ถœํ•  ์ˆ˜ ์žˆ๋Š” ๊ตฌ์กฐ ์ตœ๋Œ€ํž™๊ณผ ์ตœ์†Œํž™
์†Œ์ˆ˜_์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜ ์ฒด ์†Œ์ˆ˜๋“ค์„ ๋Œ€๋Ÿ‰์œผ๋กœ ๋น ๋ฅด๊ณ  ์ •ํ™•ํ•˜๊ฒŒ ๊ตฌํ•˜๋Š” ๋ฐฉ๋ฒ• for(int i = 2; i