4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
6 * This file is part of DevLib - See devlib/README for information.
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.2 2004/06/03 11:27:09 bernie
23 * Add dual-license information.
25 * Revision 1.1 2004/05/23 17:27:00 bernie
26 * Import kern/ subdirectory.
36 #if CONFIG_KERN_SIGNALS
39 * Check if any of the signals in \a sigs has occurred and clear them.
40 * Return the signals that have occurred.
42 sigset_t sig_check(sigset_t sigs)
47 result = CurrentProcess->sig_recv & sigs;
48 CurrentProcess->sig_recv &= ~sigs;
55 * Sleep until any of the signals in \a sigs occurs.
56 * Return the signal(s) that have awaked the process.
58 sigset_t sig_wait(sigset_t sigs)
66 /* Check if we got at least one of the signals */
67 if ((result = CurrentProcess->sig_recv & sigs))
69 /* Yes, clear signals and return */
70 CurrentProcess->sig_recv &= ~sigs;
75 /* No, go to sleep and proc_schedule() another process */
76 CurrentProcess->sig_wait = sigs;
83 * Send the signals \a sigs to the process \a proc.
84 * The process will be awaken if it was waiting for any of them.
86 * This call is interrupt safe (no \c DISABLE_INTS/ENABLE_INTS protection)
88 void _sig_signal(Process *proc, sigset_t sigs)
91 proc->sig_recv |= sigs;
93 /* Check if process needs to be awaken */
94 if (proc->sig_recv & proc->sig_wait)
96 /* Wake up process and enqueue in ready list */
104 * Same as _sig_signal() with interrupt protection.
106 * \note Inlined manually because some compilers are too
107 * stupid to it automatically.
109 void sig_signal(Process *proc, sigset_t sigs)
113 /* Set the signals */
114 proc->sig_recv |= sigs;
116 /* Check if process needs to be awaken */
117 if (proc->sig_recv & proc->sig_wait)
119 /* Wake up process and enqueue in ready list */
127 #endif /* CONFIG_KERN_SIGNALS */