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
This commit is contained in:
parent
327cdee632
commit
8c8f2bfd43
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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, ¶m);
|
||||
return sched_settcbprio(rtcb, rtcb->sched_priority);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user