Example #1
0
File: sem.c Project: spinlock/ucore
void
exit_sem_queue(sem_queue_t *sem_queue) {
    assert(sem_queue != NULL && sem_queue_count(sem_queue) == 0);
    list_entry_t *list = &(sem_queue->semu_list), *le = list;
    while ((le = list_next(list)) != list) {
        list_del(le);
        semu_destroy(le2semu(le, semu_link));
    }
}
Example #2
0
File: sem.c Project: TySag/project
static sem_undo_t *semu_list_search(list_entry_t * list, sem_t sem_id)
{
	if (VALID_SEMID(sem_id)) {
		semaphore_t *sem = semid2sem(sem_id);
		list_entry_t *le = list;
		while ((le = list_next(le)) != list) {
			sem_undo_t *semu = le2semu(le, semu_link);
			if (semu->sem == sem) {
				list_del(le);
				if (sem->valid) {
					list_add_after(list, le);
					return semu;
				} else {
					semu_destroy(semu);
					return NULL;
				}
			}
		}
	}
	return NULL;
}