kernel/sys/process.c
/**
 * @brief Place an available process in the ready queue.
 *
 * Marks a process as available for general scheduling.
 * If the process was currently in a sleep queue, it is
 * marked as having been interrupted and removed from its
 * owning queue before being moved.
 *
 * The process must not otherwise have been in a scheduling
 * queue before it is placed in the ready queue.
 */
@brief Place an available process in the ready queue.
Marks a process as available for general scheduling.
If the process was currently in a sleep queue, it is
marked as having been interrupted and removed from its
owning queue before being moved.

The process must not otherwise have been in a scheduling
queue before it is placed in the ready queue.
@brief Place an available process in the ready queue . Marks a process as available for general scheduling . If the process was currently in a sleep queue it is marked as having been interrupted and removed from its owning queue before being moved . The process must not otherwise have been in a scheduling queue before it is placed in the ready queue .
void make_process_ready(volatile process_t * proc) {
	if (proc->sleep_node.owner != NULL) {
		int sleep_lock_is_mine = sleep_lock.owner == (this_core->cpu_id + 1);
		if (!sleep_lock_is_mine) spin_lock(sleep_lock);
		if (proc->sleep_node.owner == sleep_queue) {
			if (proc->timed_sleep_node) {
				list_delete(sleep_queue, proc->timed_sleep_node);
				proc->sleep_node.owner = NULL;
				free(proc->timed_sleep_node->value);
			}
		} else {
			__sync_or_and_fetch(&proc->flags, PROC_FLAG_SLEEP_INT);
			list_delete((list_t*)proc->sleep_node.owner, (node_t*)&proc->sleep_node);
		}
		if (!sleep_lock_is_mine) spin_unlock(sleep_lock);
	}
	spin_lock(process_queue_lock);
	if (proc->sched_node.owner) {
		spin_unlock(process_queue_lock);
		return;
	}
	list_append(process_queue, (node_t*)&proc->sched_node);
	spin_unlock(process_queue_lock);
	arch_wakeup_others();
}
void make_process_ready ( volatile process_t * proc ) { if ( proc -> sleep_node . owner != NULL ) { int sleep_lock_is_mine = sleep_lock . owner == ( this_core -> cpu_id + 1 ) ; if ( ! sleep_lock_is_mine ) spin_lock ( sleep_lock ) ; if ( proc -> sleep_node . owner == sleep_queue ) { if ( proc -> timed_sleep_node ) { list_delete ( sleep_queue , proc -> timed_sleep_node ) ; proc -> sleep_node . owner = NULL ; free ( proc -> timed_sleep_node -> value ) ; } } else { __sync_or_and_fetch ( & proc -> flags , PROC_FLAG_SLEEP_INT ) ; list_delete ( ( list_t * ) proc -> sleep_node . owner , ( node_t * ) & proc -> sleep_node ) ; } if ( ! sleep_lock_is_mine ) spin_unlock ( sleep_lock ) ; } spin_lock ( process_queue_lock ) ; if ( proc -> sched_node . owner ) { spin_unlock ( process_queue_lock ) ; return ; } list_append ( process_queue , ( node_t * ) & proc -> sched_node ) ; spin_unlock ( process_queue_lock ) ; arch_wakeup_others ( ) ; }
@brief Place an available process in the ready queue.
@brief Place an available process in the ready queue .
/* The sleep queue is slightly special... */ /* This was blocked on a semaphore we can interrupt. */ /* There's only one ready queue, so this means the process was already ready, which
		 * is indicative of a bug somewhere as we shouldn't be added processes to the ready
		 * queue multiple times. */