#include <cpu/types.h> // cpu_stack_t
#include <cpu/frame.h> // CPU_SAVED_REGS_CNT
+#include <kern/signal.h>
+
/*
* WARNING: struct Process is considered private, so its definition can change any time
* without notice. DO NOT RELY on any field defined here, use only the interface
iptr_t user_data; /**< Custom data passed to the process */
#if CONFIG_KERN_SIGNALS
- sigmask_t sig_wait; /**< Signals the process is waiting for */
- sigmask_t sig_recv; /**< Received signals */
+ Signal sig;
#endif
#if CONFIG_KERN_HEAP
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
- result = current_process->sig_recv & sigs;
- current_process->sig_recv &= ~sigs;
+ result = current_process->sig.recv & sigs;
+ current_process->sig.recv &= ~sigs;
IRQ_RESTORE(flags);
return result;
IRQ_DISABLE;
/* Loop until we get at least one of the signals */
- while (!(result = current_process->sig_recv & sigs))
+ while (!(result = current_process->sig.recv & sigs))
{
/*
* Tell "them" that we want to be awaken when any of these
* signals arrives.
*/
- current_process->sig_wait = sigs;
+ current_process->sig.wait = sigs;
/* Go to sleep and proc_switch() to another process. */
proc_switch();
* least one of the signals we were expecting must have been
* delivered to us.
*/
- ASSERT(!current_process->sig_wait);
- ASSERT(current_process->sig_recv & sigs);
+ ASSERT(!current_process->sig.wait);
+ ASSERT(current_process->sig.recv & sigs);
}
/* Signals found: clear them and return */
- current_process->sig_recv &= ~sigs;
+ current_process->sig.recv &= ~sigs;
IRQ_ENABLE;
return result;
IRQ_SAVE_DISABLE(flags);
/* Set the signals */
- proc->sig_recv |= sigs;
+ proc->sig.recv |= sigs;
/* Check if process needs to be awoken */
- if (proc->sig_recv & proc->sig_wait)
+ if (proc->sig.recv & proc->sig.wait)
{
ASSERT(proc != current_process);
- proc->sig_wait = 0;
+ proc->sig.wait = 0;
if (wakeup)
proc_wakeup(proc);
else
/* Fwd decl */
struct Process;
+/**
+ * Signal structure
+ */
+typedef struct Signal
+{
+ sigmask_t wait; /**< Signals the process is waiting for */
+ sigmask_t recv; /**< Received signals */
+} Signal;
+
/* Inter-process Communication services */
sigmask_t sig_check(sigmask_t sigs);
void sig_send(struct Process *proc, sigmask_t sig);