[c++] CAS 구현 및 ABA 문제 해결 :: mutex(spin lock)와의 비교
컴퓨터과학 (CS)/Algorithm 2020. 7. 2. 19:52

Mutex와의 비교 코드 #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_distribution dis(0, 10); //출력을 위한 mutex mutex mut; class LFStack { private: Node * head; public: void ..

[c++] CAS 구현 및 ABA 문제 해결 :: ABA 해결_3. Counter 구현
컴퓨터과학 (CS)/Operating System 2020. 7. 2. 19:43

목차 문제 정의 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..

[c++] CAS 구현 및 ABA 문제 해결 :: ABA 해결_1. int형 구현
컴퓨터과학 (CS)/Operating System 2020. 7. 2. 19:37

목차 문제 정의 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..