Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. static const size_t kFibers = 2;
  2. static const size_t kIterations = 100;
  3.  
  4. size_t cs_count = 0;
  5.  
  6. size_t thread_count = 0;
  7.  
  8. auto routine = [&]() {
  9. for (size_t i = 0; i < kIterations; ++i) {
  10. while (thread_count++ > 0) {
  11. Yield();
  12. --thread_count;
  13.  
  14.  
  15. }
  16. Yield();
  17. ++cs_count;
  18. ASSERT_TRUE_M(cs_count < 3, "Too many critical sections");
  19.  
  20. --thread_count;
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement