Squashed commit of the following:

sched/sched:  Correct some build issues introduced by last set of changes.
    sched/sched:  Add new internal OS function nxsched_setaffinity() that is identical to sched_isetaffinity() except that it does not modify the errno value.  All usage of sched_setaffinity() within the OS is replaced with nxsched_setaffinity().
    sched/sched:  Internal functions sched_reprioritize() and sched_setpriority() no longer movidify the errno value.  Also renamed to nxsched_reprioritize() and sched_setpriority().
    sched/sched:  Add new internal OS function nxsched_getscheduler() that is identical to sched_getscheduler() except that it does not modify the errno value.  All usage of sched_getscheduler() within the OS is replaced with nxsched_getscheduler().
    sched/sched:  Add new internal OS function nxsched_setparam() that is identical to sched_setparam() except that it does not modify the errno value.  All usage of sched_setparam() within the OS is replaced with nxsched_setparam().
    sched/sched:  Add new internal OS function nxsched_getparam() that is identical to sched_getparam() except that it does not modify the errno value (actually, the previous value erroneously neglected to set the errno value to begin with, but this fixes both issues).  All usage of sched_getparam() within the OS is replaced with nxsched_getparam().
This commit is contained in:
Gregory Nutt
2018-01-30 11:07:36 -06:00
parent 947191780f
commit 170a50c690
30 changed files with 605 additions and 246 deletions

View File

@@ -1,7 +1,7 @@
/****************************************************************************
* sched/pthread/pthread_getschedparam.c
*
* Copyright (C) 2007, 2008, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2008, 2015, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -37,11 +37,16 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <pthread.h>
#include <sched.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/sched.h>
#include "pthread/pthread.h"
/****************************************************************************
@@ -90,30 +95,34 @@ int pthread_getschedparam(pthread_t thread, FAR int *policy,
sinfo("Thread ID=%d policy=0x%p param=0x%p\n", thread, policy, param);
if (!policy || !param)
if (policy == NULL || param == NULL)
{
ret = EINVAL;
}
else
{
/* Get the schedparams of the thread. */
/* Get the scheduler parameters of the thread. */
ret = sched_getparam((pid_t)thread, param);
if (ret != OK)
ret = nxsched_getparam((pid_t)thread, param);
if (ret < 0)
{
ret = EINVAL;
ret = -ret;
}
/* Return the policy. */
/* Get the scheduler policy. */
*policy = sched_getscheduler((pid_t)thread);
if (*policy == ERROR)
ret = nxsched_getscheduler((pid_t)thread);
if (ret < 0)
{
ret = get_errno();
ret = -ret;
}
else
{
*policy = ret;
ret = OK;
}
}
sinfo("Returning %d\n", ret);
return ret;
}