On Fri, 23 Apr 2021 22:25:07 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:

>> test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp
>>  line 33:
>> 
>>> 31: static jthread* threads = NULL;
>>> 32: static jsize threads_count = 0;
>>> 33: static std::atomic<bool> is_exited_from_suspend;
>> 
>> Is use of `std::atomic` permitted in tests?
>
> I've never seen any such restrictions in our development guidelines.
> In general, there are cases where using atomic vs raw monitors is desirable 
> to avoid over sync in tests when there is a need to stress multi-threading.

I don't know anything about such restrictions also. The atomics are required in 
this test because the thread actually managed to process the suspend request 
during RawMonitorEnter if it is used and just suspend right before entering the 
critical section. So RawMonitorEnter/RawMonitorExitt might not show the 
problem. Also, as Serguei mentioned atomics synchronization might help us in 
stress tests.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3665

Reply via email to