summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-17 21:32:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-17 21:32:21 +0000
commite9faebc794c798462a34d5fae9c922d46e95a374 (patch)
tree41f650510bb4f327ed7bf981fac39bef006d8bb7 /nuttx/sched
parent054179a134bf123279f6c3774a773d838e95c181 (diff)
downloadpx4-nuttx-e9faebc794c798462a34d5fae9c922d46e95a374.tar.gz
px4-nuttx-e9faebc794c798462a34d5fae9c922d46e95a374.tar.bz2
px4-nuttx-e9faebc794c798462a34d5fae9c922d46e95a374.zip
Add test of roundrobin scheduler (still does not work)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@81 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/sched_addreadytorun.c10
-rw-r--r--nuttx/sched/sched_processtimer.c44
2 files changed, 33 insertions, 21 deletions
diff --git a/nuttx/sched/sched_addreadytorun.c b/nuttx/sched/sched_addreadytorun.c
index 3192fc7f9..4344caf31 100644
--- a/nuttx/sched/sched_addreadytorun.c
+++ b/nuttx/sched/sched_addreadytorun.c
@@ -92,6 +92,7 @@
* whatever list it was in.
* - The caller handles the condition that occurs if the
* the head of the g_readytorun list is changed.
+ *
************************************************************/
boolean sched_addreadytorun(FAR _TCB *btcb)
@@ -99,14 +100,15 @@ boolean sched_addreadytorun(FAR _TCB *btcb)
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
boolean ret;
- /* Check if pre-emption is disabled for the current running task and
- * if the rtrTask would cause the current running task to be preempted.
+ /* Check if pre-emption is disabled for the current running
+ * task and if the new ready-to-run task would cause the
+ * current running task to be preempted.
*/
if (rtcb->lockcount && rtcb->sched_priority < btcb->sched_priority)
{
- /* Yes. Preemption would occur! Add the btcb to the g_pendingtasks
- * task list for now.
+ /* Yes. Preemption would occur! Add the new ready-to-run
+ * task to the g_pendingtasks task list for now.
*/
sched_addprioritized(btcb, &g_pendingtasks);
diff --git a/nuttx/sched/sched_processtimer.c b/nuttx/sched/sched_processtimer.c
index c6ee8fdb8..3decd12e7 100644
--- a/nuttx/sched/sched_processtimer.c
+++ b/nuttx/sched/sched_processtimer.c
@@ -91,31 +91,41 @@ static void sched_process_timeslice(void)
if (rtcb->timeslice <= 1)
{
- /* We know we are at the head of the ready to run
- * prioritized list. We must be the highest priority
- * task eligible for execution. Check the next task
- * in the ready to run list. If it is the same
- * priority, then we need to relinquish the CPU and
- * give that task a shot.
+
+ /* Yes, Now check if the task has pre-emption disabled.
+ * If so, then we will freeze the timeslice count at
+ * the value until the next tick after pre-emption
+ * has been enabled.
*/
- if (rtcb->flink &&
- rtcb->flink->sched_priority >= rtcb->sched_priority)
+ if (!rtcb->lockcount)
{
- struct sched_param param;
-
- /* Reset the timeslice */
+ /* Reset the timeslice in any case. */
rtcb->timeslice = CONFIG_RR_INTERVAL;
- /* Just resetting the task priority to its current
- * value. This this will cause the task to be
- * rescheduled behind any other tasks at the same
- * priority.
+ /* We know we are at the head of the ready to run
+ * prioritized list. We must be the highest priority
+ * task eligible for execution. Check the next task
+ * in the ready to run list. If it is the same
+ * priority, then we need to relinquish the CPU and
+ * give that task a shot.
*/
- param.sched_priority = rtcb->sched_priority;
- (void)sched_setparam(0, &param);
+ if (rtcb->flink &&
+ rtcb->flink->sched_priority >= rtcb->sched_priority)
+ {
+ struct sched_param param;
+
+ /* Just resetting the task priority to its current
+ * value. This this will cause the task to be
+ * rescheduled behind any other tasks at the same
+ * priority.
+ */
+
+ param.sched_priority = rtcb->sched_priority;
+ (void)sched_setparam(0, &param);
+ }
}
}
else