4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
9 * \brief IPC signals implementation.
11 * Each process can wait for just one signal.
12 * Multiple processes can wait for the same signal. In this
13 * case, each signal will wake-up one of them.
17 * \author Bernardo Innocenti <bernie@develer.com>
22 * Revision 1.1 2004/05/23 17:27:00 bernie
23 * Import kern/ subdirectory.
33 #if CONFIG_KERN_SIGNALS
36 * Check if any of the signals in \a sigs has occurred and clear them.
37 * Return the signals that have occurred.
39 sigset_t sig_check(sigset_t sigs)
44 result = CurrentProcess->sig_recv & sigs;
45 CurrentProcess->sig_recv &= ~sigs;
52 * Sleep until any of the signals in \a sigs occurs.
53 * Return the signal(s) that have awaked the process.
55 sigset_t sig_wait(sigset_t sigs)
63 /* Check if we got at least one of the signals */
64 if ((result = CurrentProcess->sig_recv & sigs))
66 /* Yes, clear signals and return */
67 CurrentProcess->sig_recv &= ~sigs;
72 /* No, go to sleep and proc_schedule() another process */
73 CurrentProcess->sig_wait = sigs;
80 * Send the signals \a sigs to the process \a proc.
81 * The process will be awaken if it was waiting for any of them.
83 * This call is interrupt safe (no \c DISABLE_INTS/ENABLE_INTS protection)
85 void _sig_signal(Process *proc, sigset_t sigs)
88 proc->sig_recv |= sigs;
90 /* Check if process needs to be awaken */
91 if (proc->sig_recv & proc->sig_wait)
93 /* Wake up process and enqueue in ready list */
101 * Same as _sig_signal() with interrupt protection.
103 * \note Inlined manually because some compilers are too
104 * stupid to it automatically.
106 void sig_signal(Process *proc, sigset_t sigs)
110 /* Set the signals */
111 proc->sig_recv |= sigs;
113 /* Check if process needs to be awaken */
114 if (proc->sig_recv & proc->sig_wait)
116 /* Wake up process and enqueue in ready list */
124 #endif /* CONFIG_KERN_SIGNALS */