kernel/sys/process.c
/**
 * @brief Signal a semaphore.
 *
 * Okay, so toaru32 used these general-purpose lists of processes
 * as a sort of sempahore system, so often when you see 'queue' it
 * can be read as 'semaphore' and be equally valid (outside of the
 * 'ready queue', I guess). This will awaken all processes currently
 * in the semaphore @p queue, unless they were marked as finished in
 * which case they will be discarded.
 *
 * Note that these "semaphore queues" are binary semaphores - simple
 * locks, but with smarter logic than the "spin_lock" primitive also
 * used throughout the kernel, as that just blindly switches tasks
 * until its atomic swap succeeds.
 *
 * @param queue The semaphore to signal
 * @returns the number of processes successfully awoken
 */
@brief Signal a semaphore.

Note that these "semaphore queues" are binary semaphores - simple
locks, but with smarter logic than the "spin_lock" primitive also
used throughout the kernel, as that just blindly switches tasks
until its atomic swap succeeds.

@param queue The semaphore to signal
@returns the number of processes successfully awoken
@brief Signal a semaphore . Note that these " semaphore queues " are binary semaphores - simple locks but with smarter logic than the " spin_lock " primitive also used throughout the kernel as that just blindly switches tasks until its atomic swap succeeds . @param queue The semaphore to signal @returns the number of processes successfully awoken
int wakeup_queue(list_t * queue) {
	int awoken_processes = 0;
	spin_lock(wait_lock_tmp);
	while (queue->length > 0) {
		node_t * node = list_pop(queue);
		if (!(((process_t *)node->value)->flags & PROC_FLAG_FINISHED)) {
			make_process_ready(node->value);
		}
		awoken_processes++;
	}
	spin_unlock(wait_lock_tmp);
	return awoken_processes;
}
int wakeup_queue ( list_t * queue ) { int awoken_processes = 0 ; spin_lock ( wait_lock_tmp ) ; while ( queue -> length > 0 ) { node_t * node = list_pop ( queue ) ; if ( ! ( ( ( process_t * ) node -> value ) -> flags & PROC_FLAG_FINISHED ) ) { make_process_ready ( node -> value ) ; } awoken_processes ++ ; } spin_unlock ( wait_lock_tmp ) ; return awoken_processes ; }
@brief Signal a semaphore.
@brief Signal a semaphore .