#define lock(lkp) do{ \
while(!__sync_bool_compare_and_swap(lkp, 0, 1)) \
sched_yield(); \
} while(0)
#define unlock(lkp) do{ \
*(lkp) = 0; \
} while(0)
CAS锁c源码实现
最新推荐文章于 2024-08-02 11:24:06 发布
#define lock(lkp) do{ \
while(!__sync_bool_compare_and_swap(lkp, 0, 1)) \
sched_yield(); \
} while(0)
#define unlock(lkp) do{ \
*(lkp) = 0; \
} while(0)