< prev index next >

test/hotspot/gtest/gc/g1/test_g1FreeIdSet.cpp

Print this page




 128   Semaphore post;
 129   volatile size_t total_allocations = 0;
 130   volatile bool continue_running = true;
 131 
 132   G1FreeIdSet set(start, size);
 133 
 134   TestG1FreeIdSetThread* threads[nthreads] = {};
 135   for (uint i = 0; i < nthreads; ++i) {
 136     threads[i] = new TestG1FreeIdSetThread(i,
 137                                            &post,
 138                                            &set,
 139                                            &total_allocations,
 140                                            &continue_running);
 141     threads[i]->doit();
 142   }
 143 
 144   JavaThread* this_thread = JavaThread::current();
 145   tty->print_cr("Stressing G1FreeIdSet for %u ms", milliseconds_to_run);
 146   {
 147     ThreadInVMfromNative invm(this_thread);
 148     os::sleep(this_thread, milliseconds_to_run, true);
 149   }
 150   OrderAccess::release_store(&continue_running, false);
 151   for (uint i = 0; i < nthreads; ++i) {
 152     ThreadInVMfromNative invm(this_thread);
 153     post.wait_with_safepoint_check(this_thread);
 154   }
 155   tty->print_cr("total allocations: " SIZE_FORMAT, total_allocations);
 156   tty->print_cr("final free list: ");
 157   uint ids[size] = {};
 158   for (uint i = 0; i < size; ++i) {
 159     uint id = set.claim_par_id();
 160     uint index = id - TestSupport::start(set);
 161     ASSERT_LT(index, TestSupport::size(set));
 162     tty->print_cr("  %u: %u", i, index);
 163   }
 164   ASSERT_EQ(size, TestSupport::head_index(set, TestSupport::head(set)));
 165 }


 128   Semaphore post;
 129   volatile size_t total_allocations = 0;
 130   volatile bool continue_running = true;
 131 
 132   G1FreeIdSet set(start, size);
 133 
 134   TestG1FreeIdSetThread* threads[nthreads] = {};
 135   for (uint i = 0; i < nthreads; ++i) {
 136     threads[i] = new TestG1FreeIdSetThread(i,
 137                                            &post,
 138                                            &set,
 139                                            &total_allocations,
 140                                            &continue_running);
 141     threads[i]->doit();
 142   }
 143 
 144   JavaThread* this_thread = JavaThread::current();
 145   tty->print_cr("Stressing G1FreeIdSet for %u ms", milliseconds_to_run);
 146   {
 147     ThreadInVMfromNative invm(this_thread);
 148     os::sleep(this_thread, milliseconds_to_run);
 149   }
 150   OrderAccess::release_store(&continue_running, false);
 151   for (uint i = 0; i < nthreads; ++i) {
 152     ThreadInVMfromNative invm(this_thread);
 153     post.wait_with_safepoint_check(this_thread);
 154   }
 155   tty->print_cr("total allocations: " SIZE_FORMAT, total_allocations);
 156   tty->print_cr("final free list: ");
 157   uint ids[size] = {};
 158   for (uint i = 0; i < size; ++i) {
 159     uint id = set.claim_par_id();
 160     uint index = id - TestSupport::start(set);
 161     ASSERT_LT(index, TestSupport::size(set));
 162     tty->print_cr("  %u: %u", i, index);
 163   }
 164   ASSERT_EQ(size, TestSupport::head_index(set, TestSupport::head(set)));
 165 }
< prev index next >