summaryrefslogtreecommitdiffstats
path: root/nuttx/arch/sh
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2009-03-08 23:33:41 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2009-03-08 23:33:41 +0000
commit98f1f1514261a0675f5aef9d55fb1010b5092e14 (patch)
tree13c1a8443302b1e6527a50c27f5e1ba8ae1049ca /nuttx/arch/sh
parent8a85a86fdf13fb96e9a53177076c21f041eb652f (diff)
Add support for priority inheritance
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1581 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch/sh')
-rw-r--r--nuttx/arch/sh/src/common/up_reprioritizertr.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/nuttx/arch/sh/src/common/up_reprioritizertr.c b/nuttx/arch/sh/src/common/up_reprioritizertr.c
index dccc6ad4a6..58ba7a0d69 100644
--- a/nuttx/arch/sh/src/common/up_reprioritizertr.c
+++ b/nuttx/arch/sh/src/common/up_reprioritizertr.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/sh/src/common/up_reprioritizertr.c
*
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -85,14 +85,27 @@ void up_reprioritize_rtr(_TCB *tcb, ubyte priority)
{
/* Verify that the caller is sane */
- if (tcb->task_state < FIRST_READY_TO_RUN_STATE ||
- tcb->task_state > LAST_READY_TO_RUN_STATE ||
- priority < SCHED_PRIORITY_MIN ||
+#if CONFIG_DEBUG /* We only check parameters when debug is enabled */
+ if (priority < SCHED_PRIORITY_MIN ||
priority > SCHED_PRIORITY_MAX)
{
PANIC(OSERR_BADREPRIORITIZESTATE);
}
else
+#endif
+ if (tcb->task_state < FIRST_READY_TO_RUN_STATE ||
+ tcb->task_state > LAST_READY_TO_RUN_STATE)
+ {
+ /* This is a hack and needs to be fixed.. here some taks is reprioritizing
+ * another task that is not running. Here we just set the priority of
+ * the task -- BUT some of the other states are also prioritized and the
+ * waiting task should also be re-ordered in the prioritized wiating list.
+ * As a consequence, the other task is still waiting at the lower priority.
+ */
+
+ tcb->sched_priority = priority;
+ }
+ else
{
_TCB *rtcb = (_TCB*)g_readytorun.head;
boolean switch_needed;
@@ -109,6 +122,9 @@ void up_reprioritize_rtr(_TCB *tcb, ubyte priority)
/* Setup up the new task priority */
tcb->sched_priority = (ubyte)priority;
+#ifdef CONFIG_PRIORITY_INHERITANCE
+ tcb->base_priority = (ubyte)priority;
+#endif
/* Return the task to the specified blocked task list.
* sched_addreadytorun will return TRUE if the task was