๋ชฉ์ฐจ ๋ฌธ์ ์ ์ lock free ๊ตฌํ ABA ํด๊ฒฐ intํ ๊ตฌํ(+ Hazard pointer) Counter ๊ทธ ์ธ์ ๋ฐฉ๋ฒ๋ค mutex lock(spin lock)๊ณผ์ ๋น๊ต ๊ทธ ์ธ์ ๋ฐฉ๋ฒ๋ค DCAS _InterlockedCompareExchange128 ์ฌ์ฉ ์์ Counter ๊ธฐ๋ฒ๊ณผ ๋น์ทํ๋ค. 64bit๋ฅผ ๋ชจ๋ ์ด์ฉํ์ฌ ์ฃผ์๋ฅผ ํํํ๋ CPU์์๋ ์์ Counter ๊ธฐ๋ฒ์ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก c++์ _InterlockedCompareExchange128 ์ฐ์ฐ์ ์ด์ฉํ์ฌ ์ด๋ฅผ ๋์ ํ ์ ์๋ค. ์ด ์ฐ์ฐ์ 64bit ์๋ฃํ 2๊ฐ๋ฅผ ๋ฌถ์ด์ 128bit๋ก CAS ์ฐ์ฐ์ ์ํํ ์ ์๋ค. ์ด ๋ 64bit ์ฉ ๋ถ๋ฆฌํ์ฌ ์๋ก์ด ๊ฐ์ผ๋ก ๋ฐ๊พธ์ด์ค ์ ์๋ค. lock ๋ณ์ ์ด์ฉ ์ด์ ๋ธ๋ฆฌ์ด๊น์ง ๋ณด๋ฉด lock-fr..
๋ชฉ์ฐจ ๋ฌธ์ ์ ์ lock free ๊ตฌํ ABA ํด๊ฒฐ intํ ๊ตฌํ(+ Hazard pointer) Counter ๊ทธ ์ธ์ ๋ฐฉ๋ฒ๋ค mutex lock(spin lock)๊ณผ์ ๋น๊ต Counter #include #include #include #include #include #include using namespace std; class Node { public: int value; Node* next; Node() : value(0) { next = NULL; } Node(int k_value) { next = NULL; value = k_value; } }; int node_n; //random ๊ตฌํ random_device rd; mt19937 gen(rd()); uniform_int_distribut..
๋ชฉ์ฐจ ๋ฌธ์ ์ ์ lock free ๊ตฌํ ABA ํด๊ฒฐ intํ ๊ตฌํ(+ Hazard pointer) Counter ๊ทธ ์ธ์ ๋ฐฉ๋ฒ๋ค mutex lock(spin lock)๊ณผ์ ๋น๊ต ABA ํด๊ฒฐ intํ ๊ตฌํ ABA ๋ฌธ์ ๋ ๋งค๊ฐ๋ณ์๋ฅผ intํ์ผ๋ก ๊ตฌํํ๋ฉด ์ฝ๊ฒ ํด๊ฒฐํ ์ ์๋ค. ํ์ง๋ง ๋ฌธ์ ์ ์ ์กด์ฌํ๋ค(๋ท๋ถ๋ถ์ ์ธ๊ธ). ์ฝ๋ #define _CRT_SECURE_NO_WARNINGS #define NULL_INT -1 // NULL ๊ฐ #include #include #include #include #include // #include #include using namespace std; struct Node { int data; Node* next_node; }; int node_n; atomic free_l..
Comment