summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-19 14:22:43 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-19 14:22:43 +0000
commitbf14d0a7cfb1c59f692cd24d9e97699b01e103b4 (patch)
treec94333bd8c43f9af9dcf280bf2eb76e1cf071765 /nuttx/sched
parent35aaf2d6d6776ea47729eb80efb15e04671ab316 (diff)
downloadpx4-nuttx-bf14d0a7cfb1c59f692cd24d9e97699b01e103b4.tar.gz
px4-nuttx-bf14d0a7cfb1c59f692cd24d9e97699b01e103b4.tar.bz2
px4-nuttx-bf14d0a7cfb1c59f692cd24d9e97699b01e103b4.zip
Interrupts must be disabled in all low level context switches
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@89 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/sched_setparam.c4
-rw-r--r--nuttx/sched/sched_unlock.c5
-rw-r--r--nuttx/sched/task_activate.c5
3 files changed, 12 insertions, 2 deletions
diff --git a/nuttx/sched/sched_setparam.c b/nuttx/sched/sched_setparam.c
index c9a935a4d..52389ae49 100644
--- a/nuttx/sched/sched_setparam.c
+++ b/nuttx/sched/sched_setparam.c
@@ -175,7 +175,9 @@ int sched_setparam(pid_t pid, const struct sched_param *param)
{
/* A context switch will occur. */
+ irqstate_t flags = irqsave();
up_reprioritize_rtr(tcb, (ubyte)sched_priority);
+ irqrestore(flags);
}
/* Otherwise, we can just change priority since it has no effect */
@@ -202,7 +204,9 @@ int sched_setparam(pid_t pid, const struct sched_param *param)
{
/* A context switch will occur. */
+ irqstate_t flags = irqsave();
up_reprioritize_rtr(tcb, (ubyte)sched_priority);
+ irqrestore(flags);
}
/* Otherwise, we can just change priority and re-schedule (since it
diff --git a/nuttx/sched/sched_unlock.c b/nuttx/sched/sched_unlock.c
index 773b3dd71..073f5e31f 100644
--- a/nuttx/sched/sched_unlock.c
+++ b/nuttx/sched/sched_unlock.c
@@ -93,6 +93,10 @@ STATUS sched_unlock(void)
if (rtcb && !up_interrupt_context())
{
+ /* Prevent context switches throughout the following */
+
+ irqstate_t flags = irqsave();
+
/* Decrement the preemption lock counter */
if (rtcb->lockcount)
@@ -117,6 +121,7 @@ STATUS sched_unlock(void)
up_release_pending();
}
}
+ irqrestore(flags);
}
return OK;
}
diff --git a/nuttx/sched/task_activate.c b/nuttx/sched/task_activate.c
index ce574428a..b216cc316 100644
--- a/nuttx/sched/task_activate.c
+++ b/nuttx/sched/task_activate.c
@@ -90,9 +90,10 @@
STATUS task_activate(FAR _TCB *tcb)
{
-#ifdef CONFIG_SCHED_INSTRUMENTATION
irqstate_t flags = irqsave();
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+
/* Check if this is really a re-start */
if (tcb->task_state != TSTATE_TASK_INACTIVE)
@@ -109,9 +110,9 @@ STATUS task_activate(FAR _TCB *tcb)
*/
sched_note_start(tcb);
- irqrestore(flags);
#endif
up_unblock_task(tcb);
+ irqrestore(flags);
return OK;
}