src/hotspot/share/runtime/os.cpp
changeset 59252 623722a6aeb9
parent 59249 29b0d0b61615
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
   853 int os::random() {
   853 int os::random() {
   854   // Make updating the random seed thread safe.
   854   // Make updating the random seed thread safe.
   855   while (true) {
   855   while (true) {
   856     unsigned int seed = _rand_seed;
   856     unsigned int seed = _rand_seed;
   857     unsigned int rand = random_helper(seed);
   857     unsigned int rand = random_helper(seed);
   858     if (Atomic::cmpxchg(rand, &_rand_seed, seed) == seed) {
   858     if (Atomic::cmpxchg(&_rand_seed, seed, rand) == seed) {
   859       return static_cast<int>(rand);
   859       return static_cast<int>(rand);
   860     }
   860     }
   861   }
   861   }
   862 }
   862 }
   863 
   863 
  1802  * returns the state set after the method is complete
  1802  * returns the state set after the method is complete
  1803  */
  1803  */
  1804 os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::State from,
  1804 os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::State from,
  1805                                                          os::SuspendResume::State to)
  1805                                                          os::SuspendResume::State to)
  1806 {
  1806 {
  1807   os::SuspendResume::State result = Atomic::cmpxchg(to, &_state, from);
  1807   os::SuspendResume::State result = Atomic::cmpxchg(&_state, from, to);
  1808   if (result == from) {
  1808   if (result == from) {
  1809     // success
  1809     // success
  1810     return to;
  1810     return to;
  1811   }
  1811   }
  1812   return result;
  1812   return result;