2 ms·
Here's a copy of the functions in question so that it's easier to see what people are talking about: void spin_lock(struct spin_lock_state *state, int loc
by nkurz 13y ago
Here's a copy of the functions in question so that it's easier to see what people are talking about:
void
spin_lock(struct spin_lock_state *state, int locker_id,
void (*spin_wait_callback)()) {
for (;;) {
if (state->g2 == locker_id) {
return;
}
while (state->g2 != SPIN_LOCK_NO_LOCKER) {
if (spin_wait_callback != NULL) {
spin_wait_callback();
}
continue;
}
state->g1 = locker_id;
if (state->g2 == SPIN_LOCK_NO_LOCKER) {
state->g2 = state->g1;
if (state->g1 == locker_id) {
if (state->g2 == locker_id) {
return;
}
}
}
}
}
void
spin_unlock(struct spin_lock_state *state, int locker_id)
{
state->g2 = SPIN_LOCK_NO_LOCKER;
}