projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch "preempt" in "trunk".
[bertos.git]
/
bertos
/
kern
/
signal.c
diff --git
a/bertos/kern/signal.c
b/bertos/kern/signal.c
index dbe1261f2053381e7a4127e67ee084504f00bca3..19941f9477ae8775fe025a919a396bcc050bf76c 100644
(file)
--- a/
bertos/kern/signal.c
+++ b/
bertos/kern/signal.c
@@
-125,8
+125,8
@@
sigmask_t sig_check(sigmask_t sigs)
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
cpu_flags_t flags;
IRQ_SAVE_DISABLE(flags);
- result =
CurrentP
rocess->sig_recv & sigs;
-
CurrentP
rocess->sig_recv &= ~sigs;
+ result =
current_p
rocess->sig_recv & sigs;
+
current_p
rocess->sig_recv &= ~sigs;
IRQ_RESTORE(flags);
return result;
IRQ_RESTORE(flags);
return result;
@@
-140,7
+140,6
@@
sigmask_t sig_check(sigmask_t sigs)
sigmask_t sig_wait(sigmask_t sigs)
{
sigmask_t result;
sigmask_t sig_wait(sigmask_t sigs)
{
sigmask_t result;
- cpu_flags_t flags;
/* Sleeping with IRQs disabled or preemption forbidden is illegal */
IRQ_ASSERT_ENABLED();
/* Sleeping with IRQs disabled or preemption forbidden is illegal */
IRQ_ASSERT_ENABLED();
@@
-155,17
+154,16
@@
sigmask_t sig_wait(sigmask_t sigs)
* In this case, we'd deadlock with the signal bit already set
* and the process never being reinserted into the ready list.
*/
* In this case, we'd deadlock with the signal bit already set
* and the process never being reinserted into the ready list.
*/
- // FIXME: just use IRQ_DISABLE() here
- IRQ_SAVE_DISABLE(flags);
+ IRQ_DISABLE;
/* Loop until we get at least one of the signals */
/* Loop until we get at least one of the signals */
- while (!(result =
CurrentP
rocess->sig_recv & sigs))
+ while (!(result =
current_p
rocess->sig_recv & sigs))
{
/*
* Tell "them" that we want to be awaken when any of these
* signals arrives.
*/
{
/*
* Tell "them" that we want to be awaken when any of these
* signals arrives.
*/
-
CurrentP
rocess->sig_wait = sigs;
+
current_p
rocess->sig_wait = sigs;
/*
* Go to sleep and proc_switch() to another process.
/*
* Go to sleep and proc_switch() to another process.
@@
-173,9
+171,9
@@
sigmask_t sig_wait(sigmask_t sigs)
* We re-enable IRQs because proc_switch() does not
* guarantee to save and restore the interrupt mask.
*/
* We re-enable IRQs because proc_switch() does not
* guarantee to save and restore the interrupt mask.
*/
- IRQ_
RESTORE(flags)
;
+ IRQ_
ENABLE
;
proc_switch();
proc_switch();
- IRQ_
SAVE_DISABLE(flags)
;
+ IRQ_
DISABLE
;
/*
* When we come back here, the wait mask must have been
/*
* When we come back here, the wait mask must have been
@@
-183,14
+181,14
@@
sigmask_t sig_wait(sigmask_t sigs)
* one of the signals we were expecting must have been
* delivered to us.
*/
* one of the signals we were expecting must have been
* delivered to us.
*/
- ASSERT(!
CurrentP
rocess->sig_wait);
- ASSERT(
CurrentP
rocess->sig_recv & sigs);
+ ASSERT(!
current_p
rocess->sig_wait);
+ ASSERT(
current_p
rocess->sig_recv & sigs);
}
/* Signals found: clear them and return */
}
/* Signals found: clear them and return */
-
CurrentP
rocess->sig_recv &= ~sigs;
+
current_p
rocess->sig_recv &= ~sigs;
- IRQ_
RESTORE(flags)
;
+ IRQ_
ENABLE
;
return result;
}
return result;
}
@@
-249,9
+247,14
@@
void sig_signal(Process *proc, sigmask_t sigs)
/* Check if process needs to be awoken */
if (proc->sig_recv & proc->sig_wait)
{
/* Check if process needs to be awoken */
if (proc->sig_recv & proc->sig_wait)
{
- /* Wake up process and enqueue in ready list */
+ /*
+ * Wake up process and enqueue in ready list.
+ *
+ * Move this process to the head of the ready list, so that it
+ * will be chosen at the next scheduling point.
+ */
proc->sig_wait = 0;
proc->sig_wait = 0;
- SCHED_ENQUEUE(proc);
+ SCHED_ENQUEUE
_HEAD
(proc);
}
IRQ_RESTORE(flags);
}
IRQ_RESTORE(flags);