90 // Invariants which should hold after a TaskQueue has been emptied and is
91 // quiescent; they do not hold at arbitrary times.
92 void TaskQueueStats::verify() const
93 {
94 assert(get(push) == get(pop) + get(steal),
95 err_msg("push=" SIZE_FORMAT " pop=" SIZE_FORMAT " steal=" SIZE_FORMAT,
96 get(push), get(pop), get(steal)));
97 assert(get(pop_slow) <= get(pop),
98 err_msg("pop_slow=" SIZE_FORMAT " pop=" SIZE_FORMAT,
99 get(pop_slow), get(pop)));
100 assert(get(steal) <= get(steal_attempt),
101 err_msg("steal=" SIZE_FORMAT " steal_attempt=" SIZE_FORMAT,
102 get(steal), get(steal_attempt)));
103 assert(get(overflow) == 0 || get(push) != 0,
104 err_msg("overflow=" SIZE_FORMAT " push=" SIZE_FORMAT,
105 get(overflow), get(push)));
106 assert(get(overflow_max_len) == 0 || get(overflow) != 0,
107 err_msg("overflow_max_len=" SIZE_FORMAT " overflow=" SIZE_FORMAT,
108 get(overflow_max_len), get(overflow)));
109 }
110 #endif // ASSERT
111 #endif // TASKQUEUE_STATS
112
113 int TaskQueueSetSuper::randomParkAndMiller(int *seed0) {
114 const int a = 16807;
115 const int m = 2147483647;
116 const int q = 127773; /* m div a */
117 const int r = 2836; /* m mod a */
118 assert(sizeof(int) == 4, "I think this relies on that");
119 int seed = *seed0;
120 int hi = seed / q;
121 int lo = seed % q;
122 int test = a * lo - r * hi;
123 if (test > 0)
124 seed = test;
125 else
126 seed = test + m;
127 *seed0 = seed;
128 return seed;
129 }
|
90 // Invariants which should hold after a TaskQueue has been emptied and is
91 // quiescent; they do not hold at arbitrary times.
92 void TaskQueueStats::verify() const
93 {
94 assert(get(push) == get(pop) + get(steal),
95 err_msg("push=" SIZE_FORMAT " pop=" SIZE_FORMAT " steal=" SIZE_FORMAT,
96 get(push), get(pop), get(steal)));
97 assert(get(pop_slow) <= get(pop),
98 err_msg("pop_slow=" SIZE_FORMAT " pop=" SIZE_FORMAT,
99 get(pop_slow), get(pop)));
100 assert(get(steal) <= get(steal_attempt),
101 err_msg("steal=" SIZE_FORMAT " steal_attempt=" SIZE_FORMAT,
102 get(steal), get(steal_attempt)));
103 assert(get(overflow) == 0 || get(push) != 0,
104 err_msg("overflow=" SIZE_FORMAT " push=" SIZE_FORMAT,
105 get(overflow), get(push)));
106 assert(get(overflow_max_len) == 0 || get(overflow) != 0,
107 err_msg("overflow_max_len=" SIZE_FORMAT " overflow=" SIZE_FORMAT,
108 get(overflow_max_len), get(overflow)));
109 }
110
111 #endif // ASSERT
112 #endif // TASKQUEUE_STATS
113
114 int TaskQueueSetSuper::randomParkAndMiller(int *seed0) {
115 const int a = 16807;
116 const int m = 2147483647;
117 const int q = 127773; /* m div a */
118 const int r = 2836; /* m mod a */
119 assert(sizeof(int) == 4, "I think this relies on that");
120 int seed = *seed0;
121 int hi = seed / q;
122 int lo = seed % q;
123 int test = a * lo - r * hi;
124 if (test > 0)
125 seed = test;
126 else
127 seed = test + m;
128 *seed0 = seed;
129 return seed;
130 }
|