Beispiel #1
0
void
runtime·notewakeup(Note *n)
{
	if(runtime·xchg(&n->key, 1))
		runtime·throw("notewakeup - double wakeup");
	runtime·futexwakeup(&n->key, 1);
}
Beispiel #2
0
static void
futexunlock(Lock *l)
{
	uint32 v;

	v = runtime·xchg(&l->key, MUTEX_UNLOCKED);
	if(v == MUTEX_UNLOCKED)
		runtime·throw("unlock of unlocked lock");
	if(v == MUTEX_SLEEPING)
		futexwakeup(&l->key, 1);
}
Beispiel #3
0
void
runtime·unlock(Lock *l)
{
	uint32 v;

	if(--m->locks < 0)
		runtime·throw("runtime·unlock: lock count");

	v = runtime·xchg(&l->key, MUTEX_UNLOCKED);
	if(v == MUTEX_UNLOCKED)
		runtime·throw("unlock of unlocked lock");
	if(v == MUTEX_SLEEPING)
		runtime·futexwakeup(&l->key, 1);
}
Beispiel #4
0
static void
futexunlock(Lock *l)
{
	uint32 v;

	// Atomically get value and clear lock bit.
again:
	v = l->key;
	if((v&1) == 0)
		throw("unlock of unlocked lock");
	if(!cas(&l->key, v, v&~1))
		goto again;

	// If there were waiters, wake one.
	if(v & ~1)
		futexwakeup(&l->key);
}
Beispiel #5
0
void
runtime·notewakeup(Note *n)
{
	runtime·xchg(&n->key, 1);
	runtime·futexwakeup(&n->key, 1);
}
Beispiel #6
0
void
runtime·notewakeup(Note *n)
{
	runtime·xchg(&n->state, 1);
	futexwakeup(&n->state, 1<<30);
}