kernel/sys/process.c
/**
 * @brief Wait until a given time.
 *
 * Suspends the current process until the given time. The process may
 * still be resumed by a signal or other mechanism, in which case the
 * sleep will not be resumed by the kernel.
 */
@brief Wait until a given time.
Suspends the current process until the given time. The process may
still be resumed by a signal or other mechanism, in which case the
sleep will not be resumed by the kernel.
@brief Wait until a given time . Suspends the current process until the given time . The process may still be resumed by a signal or other mechanism in which case the sleep will not be resumed by the kernel .
void sleep_until(process_t * process, unsigned long seconds, unsigned long subseconds) {
	spin_lock(sleep_lock);
	if (this_core->current_process->sleep_node.owner) {
		spin_unlock(sleep_lock);
		return;
	}
	process->sleep_node.owner = sleep_queue;
	node_t * before = NULL;
	foreach(node, sleep_queue) {
		sleeper_t * candidate = ((sleeper_t *)node->value);
		if (!candidate) {
			printf("null candidate?\n");
			continue;
		}
		if (candidate->end_tick > seconds || (candidate->end_tick == seconds && candidate->end_subtick > subseconds)) {
			break;
		}
		before = node;
	}
	sleeper_t * proc = malloc(sizeof(sleeper_t));
	proc->process     = process;
	proc->end_tick    = seconds;
	proc->end_subtick = subseconds;
	proc->is_fswait = 0;
	process->timed_sleep_node = list_insert_after(sleep_queue, before, proc);
	spin_unlock(sleep_lock);
}
void sleep_until ( process_t * process , unsigned long seconds , unsigned long subseconds ) { spin_lock ( sleep_lock ) ; if ( this_core -> current_process -> sleep_node . owner ) { spin_unlock ( sleep_lock ) ; return ; } process -> sleep_node . owner = sleep_queue ; node_t * before = NULL ; foreach ( node , sleep_queue ) { sleeper_t * candidate = ( ( sleeper_t * ) node -> value ) ; if ( ! candidate ) { printf ( " \n " ) ; continue ; } if ( candidate -> end_tick > seconds || ( candidate -> end_tick == seconds && candidate -> end_subtick > subseconds ) ) { break ; } before = node ; } sleeper_t * proc = malloc ( sizeof ( sleeper_t ) ) ; proc -> process = process ; proc -> end_tick = seconds ; proc -> end_subtick = subseconds ; proc -> is_fswait = 0 ; process -> timed_sleep_node = list_insert_after ( sleep_queue , before , proc ) ; spin_unlock ( sleep_lock ) ; }
@brief Wait until a given time.
@brief Wait until a given time .
/* Can't sleep, sleeping already */