kernel/sys/process.c
/**
 * @brief Wake up processes that were sleeping on timers.
 *
 * Reschedule all processes whose timed waits have expired as of
 * the time indicated by @p seconds and @p subseconds. If the sleep
 * was part of an fswait system call timing out, the call is marked
 * as timed out before the process is rescheduled.
 */
@brief Wake up processes that were sleeping on timers.
Reschedule all processes whose timed waits have expired as of
the time indicated by @p seconds and @p subseconds. If the sleep
was part of an fswait system call timing out, the call is marked
as timed out before the process is rescheduled.
@brief Wake up processes that were sleeping on timers . Reschedule all processes whose timed waits have expired as of the time indicated by @p seconds and @p subseconds . If the sleep was part of an fswait system call timing out the call is marked as timed out before the process is rescheduled .
void wakeup_sleepers(unsigned long seconds, unsigned long subseconds) {
	spin_lock(sleep_lock);
	if (sleep_queue->length) {
		sleeper_t * proc = ((sleeper_t *)sleep_queue->head->value);
		while (proc && (proc->end_tick < seconds || (proc->end_tick == seconds && proc->end_subtick <= subseconds))) {
			if (proc->is_fswait) {
				proc->is_fswait = -1;
				process_alert_node_locked(proc->process,proc);
			} else {
				process_t * process = proc->process;
				process->sleep_node.owner = NULL;
				process->timed_sleep_node = NULL;
				if (!process_is_ready(process)) {
					spin_lock(wait_lock_tmp);
					make_process_ready(process);
					spin_unlock(wait_lock_tmp);
				}
			}
			free(proc);
			free(list_dequeue(sleep_queue));
			if (sleep_queue->length) {
				proc = ((sleeper_t *)sleep_queue->head->value);
			} else {
				break;
			}
		}
	}
	spin_unlock(sleep_lock);
}
void wakeup_sleepers ( unsigned long seconds , unsigned long subseconds ) { spin_lock ( sleep_lock ) ; if ( sleep_queue -> length ) { sleeper_t * proc = ( ( sleeper_t * ) sleep_queue -> head -> value ) ; while ( proc && ( proc -> end_tick < seconds || ( proc -> end_tick == seconds && proc -> end_subtick <= subseconds ) ) ) { if ( proc -> is_fswait ) { proc -> is_fswait = -1 ; process_alert_node_locked ( proc -> process , proc ) ; } else { process_t * process = proc -> process ; process -> sleep_node . owner = NULL ; process -> timed_sleep_node = NULL ; if ( ! process_is_ready ( process ) ) { spin_lock ( wait_lock_tmp ) ; make_process_ready ( process ) ; spin_unlock ( wait_lock_tmp ) ; } } free ( proc ) ; free ( list_dequeue ( sleep_queue ) ) ; if ( sleep_queue -> length ) { proc = ( ( sleeper_t * ) sleep_queue -> head -> value ) ; } else { break ; } } } spin_unlock ( sleep_lock ) ; }
@brief Wake up processes that were sleeping on timers.
@brief Wake up processes that were sleeping on timers .