Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static const size_t kFibers = 2;
- static const size_t kIterations = 100;
- size_t cs_count = 0;
- size_t thread_count = 0;
- auto routine = [&]() {
- for (size_t i = 0; i < kIterations; ++i) {
- while (thread_count++ > 0) {
- Yield();
- --thread_count;
- }
- Yield();
- ++cs_count;
- ASSERT_TRUE_M(cs_count < 3, "Too many critical sections");
- --thread_count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement