Пример #1
0
void
thread_wakeup_one(const void *addr)
{
	int result;
	
	// meant to be called with interrupts off
	assert(curspl>0);
	if (thread_hassleepers(addr)!=0){	
	struct thread *t = array_getguy(sleepers, 1);
	if (t->t_sleepaddr == addr) {
			
			// Remove from list
	array_remove(sleepers, 1);
			
			

			/*
			 * Because we preallocate during thread_fork,
			 * this should never fail.
			 */
	result = make_runnable(t);
    assert(result==0);
		}
		}
}
Пример #2
0
void
lock_destroy(struct lock *lock)
{
#if OPT_A1
    assert(lock != NULL);

    int spl;
    spl = splhigh();
    assert(thread_hassleepers(lock)==0);
    splx(spl);
#endif

    kfree(lock->name);
    kfree(lock);
}
Пример #3
0
void
sem_destroy(struct semaphore *sem)
{
	int spl;
	assert(sem != NULL);

	spl = splhigh();
	assert(thread_hassleepers(sem)==0);
	splx(spl);

	/*
	 * Note: while someone could theoretically start sleeping on
	 * the semaphore after the above test but before we free it,
	 * if they're going to do that, they can just as easily wait
	 * a bit and start sleeping on the semaphore after it's been
	 * freed. Consequently, there's not a whole lot of point in 
	 * including the kfrees in the splhigh block, so we don't.
	 */

	kfree(sem->name);
	kfree(sem);
}