summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-03-10 02:03:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-03-10 02:03:24 +0000
commitc0a3f1ae96ef7e9f5d76e530a3fec5ff3456258a (patch)
tree7adae52052812fa4cf30ebed6fb2211e52407f4c
parent89bd2d728bdcd66ed7802bcfe361fd2e039b7f15 (diff)
downloadnuttx-c0a3f1ae96ef7e9f5d76e530a3fec5ff3456258a.tar.gz
nuttx-c0a3f1ae96ef7e9f5d76e530a3fec5ff3456258a.tar.bz2
nuttx-c0a3f1ae96ef7e9f5d76e530a3fec5ff3456258a.zip
Make better use of new sched_settcpprio() API
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1588 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/sched/pthread_setschedprio.c4
-rw-r--r--nuttx/sched/sched_setparam.c4
-rw-r--r--nuttx/sched/sched_setscheduler.c52
-rw-r--r--nuttx/sched/sched_settcbprio.c9
-rw-r--r--nuttx/sched/sched_yield.c52
5 files changed, 63 insertions, 58 deletions
diff --git a/nuttx/sched/pthread_setschedprio.c b/nuttx/sched/pthread_setschedprio.c
index 6d3beb1de..fc4c2d612 100644
--- a/nuttx/sched/pthread_setschedprio.c
+++ b/nuttx/sched/pthread_setschedprio.c
@@ -104,7 +104,7 @@ int pthread_setschedprio(pthread_t thread, int prio)
/* Set the errno to some non-zero value (failsafe) */
- *get_errno_ptr() = EINVAL;
+ errno = EINVAL;
/* Call sched_setparam() to change the priority */
@@ -114,7 +114,7 @@ int pthread_setschedprio(pthread_t thread, int prio)
{
/* If sched_setparam() fails, return the errno */
- ret = *get_errno_ptr();
+ ret = errno;
}
return ret;
}
diff --git a/nuttx/sched/sched_setparam.c b/nuttx/sched/sched_setparam.c
index 4bd676087..b08611169 100644
--- a/nuttx/sched/sched_setparam.c
+++ b/nuttx/sched/sched_setparam.c
@@ -110,9 +110,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param)
/* Verify that the requested priority is in the valid range */
- if (!param ||
- param->sched_priority < SCHED_PRIORITY_MIN ||
- param->sched_priority > SCHED_PRIORITY_MAX)
+ if (!param)
{
errno = EINVAL;
return ERROR;
diff --git a/nuttx/sched/sched_setscheduler.c b/nuttx/sched/sched_setscheduler.c
index 7fee93118..929cc58e8 100644
--- a/nuttx/sched/sched_setscheduler.c
+++ b/nuttx/sched/sched_setscheduler.c
@@ -1,7 +1,7 @@
-/************************************************************
- * sched_setscheduler.c
+/****************************************************************************
+ * sched/sched_setscheduler.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
@@ -46,35 +46,35 @@
#include "os_internal.h"
#include "clock_internal.h"
-/************************************************************
+/****************************************************************************
* Definitions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Type Declarations
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Function Prototypes
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Public Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Name:sched_setscheduler
*
* Description:
@@ -104,7 +104,7 @@
*
* Assumptions:
*
- ************************************************************/
+ ****************************************************************************/
int sched_setscheduler(pid_t pid, int policy,
const struct sched_param *param)
@@ -123,7 +123,7 @@ int sched_setscheduler(pid_t pid, int policy,
if (policy != SCHED_FIFO)
#endif
{
- *get_errno_ptr() = EINVAL;
+ errno = EINVAL;
return ERROR;
}
@@ -139,7 +139,7 @@ int sched_setscheduler(pid_t pid, int policy,
tcb = sched_gettcb(pid);
if (!tcb)
{
- *get_errno_ptr() = ESRCH;
+ errno = ESRCH;
return ERROR;
}
@@ -173,7 +173,7 @@ int sched_setscheduler(pid_t pid, int policy,
/* Set the new priority */
- ret = sched_setparam(pid, param);
+ ret = sched_settcbprio(tcb, param->sched_priority);
sched_unlock();
if (ret != OK)
diff --git a/nuttx/sched/sched_settcbprio.c b/nuttx/sched/sched_settcbprio.c
index 28810ce5d..78b96b83c 100644
--- a/nuttx/sched/sched_settcbprio.c
+++ b/nuttx/sched/sched_settcbprio.c
@@ -105,6 +105,15 @@ int sched_settcbprio(FAR _TCB *tcb, int sched_priority)
tstate_t task_state;
irqstate_t saved_state;
+ /* Verify that the requested priority is in the valid range */
+
+ if (sched_priority < SCHED_PRIORITY_MIN ||
+ sched_priority > SCHED_PRIORITY_MAX)
+ {
+ errno = EINVAL;
+ return ERROR;
+ }
+
/* We need to assure that there there is no interrupt activity while
* performing the following.
*/
diff --git a/nuttx/sched/sched_yield.c b/nuttx/sched/sched_yield.c
index edbb00abc..9e4560ad1 100644
--- a/nuttx/sched/sched_yield.c
+++ b/nuttx/sched/sched_yield.c
@@ -1,7 +1,7 @@
-/************************************************************
- * sched_yield.c
+/****************************************************************************
+ * sched/sched_yield.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,46 +31,46 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/arch.h>
#include "os_internal.h"
-/************************************************************
+/****************************************************************************
* Definitions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Type Declarations
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Global Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Variables
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Function Prototypes
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Public Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Name: sched_yield
*
* Description:
@@ -85,18 +85,16 @@
*
* Assumptions:
*
- ************************************************************/
+ ****************************************************************************/
-int sched_yield (void)
+int sched_yield(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
- struct sched_param param;
/* This equivalent to just resetting the task priority to
* its current value since this will cause the task to
* be rescheduled behind any other tasks at the same priority.
*/
- param.sched_priority = rtcb->sched_priority;
- return sched_setparam(0, &param);
+ return sched_settcbprio(rtcb, rtcb->sched_priority);
}