mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
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:
+166
-1
@@ -1,7 +1,7 @@
|
||||
/********************************************************************************
|
||||
* include/nuttx/sched.h
|
||||
*
|
||||
* Copyright (C) 2007-2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2016, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -178,6 +178,34 @@
|
||||
#define SPORADIC_FLAG_REPLENISH (1 << 2) /* Bit 2: Replenishment cycle */
|
||||
/* Bits 3-7: Available */
|
||||
|
||||
/* Most internal nxsched_* interfaces are not available in the user space in
|
||||
* PROTECTED and KERNEL builds. In that context, the application semaphore
|
||||
* interfaces must be used. The differences between the two sets of
|
||||
* interfaces are: (1) the nxsched_* interfaces do not cause cancellation
|
||||
* points and (2) they do not modify the errno variable.
|
||||
*
|
||||
* This is only important when compiling libraries (libc or libnx) that are
|
||||
* used both by the OS (libkc.a and libknx.a) or by the applications
|
||||
* (libuc.a and libunx.a). The that case, the correct interface must be
|
||||
* used for the build context.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
# define _SCHED_GETPARAM(t,p) nxsched_getparam(t,p)
|
||||
# define _SCHED_SETPARAM(t,p) nxsched_setparam(t,p)
|
||||
# define _SCHED_GETSCHEDULER(t) nxsched_getscheduler(t)
|
||||
# define _SCHED_SETAFFINITY(t,c,m) nxsched_setaffinity(t,c,m)
|
||||
# define _SCHED_ERRNO(r) (-(r))
|
||||
# define _SCHED_ERRVAL(r) (r)
|
||||
#else
|
||||
# define _SCHED_GETPARAM(t,p) sched_getparam(t,p)
|
||||
# define _SCHED_SETPARAM(t,p) sched_setparam(t,p)
|
||||
# define _SCHED_GETSCHEDULER(t) sched_getscheduler(t)
|
||||
# define _SCHED_SETAFFINITY(t,c,m) sched_setaffinity(t,c,m)
|
||||
# define _SCHED_ERRNO(r) errno
|
||||
# define _SCHED_ERRVAL(r) (-errno)
|
||||
#endif
|
||||
|
||||
/********************************************************************************
|
||||
* Public Type Definitions
|
||||
********************************************************************************/
|
||||
@@ -879,6 +907,143 @@ void sched_suspend_scheduler(FAR struct tcb_s *tcb);
|
||||
# define sched_suspend_scheduler(tcb)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_getparam
|
||||
*
|
||||
* Description:
|
||||
* This function gets the scheduling priority of the task specified by
|
||||
* pid. It is identical in function, differing only in its return value:
|
||||
* This function does not modify the errno variable.
|
||||
*
|
||||
* This is a non-standard, internal OS function and is not intended for
|
||||
* use by application logic. Applications should use the standard
|
||||
* sched_getparam().
|
||||
*
|
||||
* Inputs:
|
||||
* pid - the task ID of the task. If pid is zero, the priority
|
||||
* of the calling task is returned.
|
||||
* param - A structure whose member sched_priority is the integer
|
||||
* priority. The task's priority is copied to the sched_priority
|
||||
* element of this structure.
|
||||
*
|
||||
* Return Value:
|
||||
* 0 (OK) if successful, otherwise a negated errno value is returned to
|
||||
* indicate the nature of the failure..
|
||||
*
|
||||
* This function can fail if param is null (EINVAL) or if pid does
|
||||
* not correspond to any task (ESRCH).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct sched_param; /* Forward reference */
|
||||
int nxsched_getparam (pid_t pid, FAR struct sched_param *param);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_setparam
|
||||
*
|
||||
* Description:
|
||||
* This function sets the priority of a specified task. It is identical
|
||||
* to the function sched_setparam(), differing only in its return value:
|
||||
* This function does not modify the errno variable.
|
||||
*
|
||||
* NOTE: Setting a task's priority to the same value has a similar effect
|
||||
* to sched_yield() -- The task will be moved to after all other tasks
|
||||
* with the same priority.
|
||||
*
|
||||
* This is a non-standard, internal OS function and is not intended for
|
||||
* use by application logic. Applications should use the standard
|
||||
* sched_setparam().
|
||||
*
|
||||
* Inputs:
|
||||
* pid - the task ID of the task to reprioritize. If pid is zero, the
|
||||
* priority of the calling task is changed.
|
||||
* param - A structure whose member sched_priority is the integer priority.
|
||||
* The range of valid priority numbers is from SCHED_PRIORITY_MIN
|
||||
* through SCHED_PRIORITY_MAX.
|
||||
*
|
||||
* Return Value:
|
||||
* 0 (OK) if successful, otherwise a negated errno value is returned to
|
||||
* indicate the nature of the failure..
|
||||
*
|
||||
* EINVAL The parameter 'param' is invalid or does not make sense for the
|
||||
* current scheduling policy.
|
||||
* EPERM The calling task does not have appropriate privileges.
|
||||
* ESRCH The task whose ID is pid could not be found.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct sched_param; /* Forward reference */
|
||||
int nxsched_setparam(pid_t pid, FAR const struct sched_param *param);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_getscheduler
|
||||
*
|
||||
* Description:
|
||||
* sched_getscheduler() returns the scheduling policy currently
|
||||
* applied to the task identified by pid. If pid equals zero, the
|
||||
* policy of the calling task will be retrieved.
|
||||
*
|
||||
* This functions is identical to the function sched_getscheduler(),
|
||||
* differing only in its return value: This function does not modify
|
||||
* the errno variable.
|
||||
*
|
||||
* This is a non-standard, internal OS function and is not intended for
|
||||
* use by application logic. Applications should use the standard
|
||||
* sched_getscheduler().
|
||||
*
|
||||
* Inputs:
|
||||
* pid - the task ID of the task to query. If pid is zero, the
|
||||
* calling task is queried.
|
||||
*
|
||||
* Return Value:
|
||||
* On success, sched_getscheduler() returns the policy for the task
|
||||
* (either SCHED_FIFO or SCHED_RR). On error, a negated errno value
|
||||
* returned:
|
||||
*
|
||||
* ESRCH The task whose ID is pid could not be found.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxsched_getscheduler(pid_t pid);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_setaffinity
|
||||
*
|
||||
* Description:
|
||||
* sched_setaffinity() sets the CPU affinity mask of the thread whose ID
|
||||
* is pid to the value specified by mask. If pid is zero, then the
|
||||
* calling thread is used. The argument cpusetsize is the length (i
|
||||
* bytes) of the data pointed to by mask. Normally this argument would
|
||||
* be specified as sizeof(cpu_set_t).
|
||||
*
|
||||
* If the thread specified by pid is not currently running on one of the
|
||||
* CPUs specified in mask, then that thread is migrated to one of the
|
||||
* CPUs specified in mask.
|
||||
*
|
||||
* nxsched_setaffinity() is identical to the function sched_setparam(),
|
||||
* differing only in its return value: This function does not modify
|
||||
* the errno variable. This is a non-standard, internal OS function and
|
||||
* is not intended for use by application logic. Applications should
|
||||
* use the standard sched_setparam().
|
||||
*
|
||||
* Inputs:
|
||||
* pid - The ID of thread whose affinity set will be modified.
|
||||
* cpusetsize - Size of cpuset. MUST be sizeofcpu_set_t().
|
||||
* mask - The location to return the thread's new affinity set.
|
||||
*
|
||||
* Return Value:
|
||||
* 0 if successful. Otherwise, ERROR (-1) is returned, and errno is
|
||||
* set appropriately:
|
||||
*
|
||||
* ESRCH The task whose ID is pid could not be found.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
int nxsched_setaffinity(pid_t pid, size_t cpusetsize,
|
||||
FAR const cpu_set_t *mask);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user