Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SIMPLE_TEST(FutexCountAfterHeavyRound) {
- twist::sim::sched::FairScheduler scheduler;
- twist::sim::Simulator simulator{&scheduler};
- auto result = simulator.Run([&] {
- WaitGroup wg;
- static const size_t kWork = 64;
- // Round 1
- for (size_t i = 0; i < kWork; ++i) {
- wg.Add(1);
- }
- // Forcing waitgroup to set internal <need to wake> flag
- twist::ed::std::thread t([&] {
- wg.Wait();
- });
- for (size_t i = 0; i < kWork; ++i) {
- wg.Done();
- }
- wg.Wait();
- t.join();
- const auto after_first_round = simulator.FutexCount();
- // Round 2 (flag must be reset, but it isn't)
- for (size_t i = 0; i < kWork; ++i) {
- wg.Add(1);
- }
- for (size_t i = 0; i < kWork; ++i) {
- wg.Done();
- }
- wg.Wait();
- const auto after_second_round = simulator.FutexCount();
- const auto second_round_only = after_second_round - after_first_round;
- ASSERT_EQ(second_round_only, 0);
- });
- ASSERT_TRUE(result.Ok());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement