candidate sched.h and sys/sched.h for review
Ralf Corsepius
ralf.corsepius@rtems.org
Tue Mar 30 08:30:00 GMT 2010
On 03/29/2010 08:12 PM, Joel Sherrill wrote:
> Hi,
>
> Attached is a first attempt at adding sched_XXX
> prototypes to sched.h, updating sched_param to
> use the right field names for sporadic scheduler,
> and to have RTEMS and Cygwin SCHED_XXX constants
> unperturbed.
>
> I have compiled one target with this but that doesn't
> mean it is close to right. How does it look?
Comments interspersed.
>
> sched.h
>
>
> /*
> * $Id$
> */
>
> #ifndef_SCHED_H_
> #define_SCHED_H_
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> #include <sys/features.h>
> #include <sys/time.h>
Why sys/time.h?
SUSV/IEEE Std 1003.1-2008 says:
<cite>
The <sched.h> header shall define the timespec structure as described in
<time.h>.
</cite>
I don't see that this file uses any types/defines from <sys/time.h>, but
"timespec", which is mandated to specified in <time.h>
> #include <sys/sched.h>
Please move these includes above the "#ifdef __cplusplus".
> #if defined(_POSIX_PRIORITY_SCHEDULING)
> /*
> * 13.3.1 Set Scheduling Parameters, P1003.1b-1993, p. 252
> */
> int sched_setparam(
> pid_t pid,
> const struct sched_param *param
> );
>
> /*
> * 13.3.2 Set Scheduling Parameters, P1003.1b-1993, p. 253
> */
> int sched_getparam(
> pid_t pid,
> struct sched_param *param
> );
>
> /*
> * 13.3.3 Set Scheduling Policy and Scheduling Parameters,
> * P1003.1b-1993, p. 254
> */
> int sched_setscheduler(
> pid_t pid,
> int policy,
> const struct sched_param *param
> );
>
> /*
> * 13.3.4 Get Scheduling Policy, P1003.1b-1993, p. 256
> */
> int sched_getscheduler(
> pid_t pid
> );
>
> /*
> * 13.3.6 Get Scheduling Parameter Limits, P1003.1b-1993, p. 258
> */
> int sched_get_priority_max(
> int policy
> );
>
> int sched_get_priority_min(
> int policy
> );
>
> int sched_rr_get_interval(
> pid_t pid,
> struct timespec *interval
> );
> #endif /* _POSIX_PRIORITY_SCHEDULING */
>
> #if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING)
>
> /*
> * 13.3.5 Yield Processor, P1003.1b-1993, p. 257
> */
> int sched_yield( void );
>
> #endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */
>
> #ifdef __cplusplus
> }
> #endif
>
> #endif /*_SCHED_H_ */
>
>
> sys_sched.h
>
>
> /*
> * Written by Joel Sherrill<joel@OARcorp.com>.
> *
> * COPYRIGHT (c) 1989-2000.
> * On-Line Applications Research Corporation (OAR).
> *
> * Permission to use, copy, modify, and distribute this software for any
> * purpose without fee is hereby granted, provided that this entire notice
> * is included in all copies of any software which is or includes a copy
> * or modification of this software.
> *
> * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
> * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
> * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
> * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
> *
> * $Id: sched.h,v 1.2 2002/06/20 19:51:24 fitzsim Exp $
> */
>
>
> #ifndef __POSIX_SYS_SCHEDULING_h
> #define __POSIX_SYS_SCHEDULING_h
I would use "_SYS_SCHED_H_".
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> /* Scheduling Policies */
> /* Open Group Specifications Issue 6 */
> #if defined(__CYGWIN__)
> #define SCHED_OTHER 3
> #else
> #define SCHED_OTHER 0
> #endif
>
> #define SCHED_FIFO 1
> #define SCHED_RR 2
>
> #if defined(_POSIX_SPORADIC_SERVER)
> #define SCHED_SPORADIC 3
> #endif
>
> /* Scheduling Parameters */
> /* Open Group Specifications Issue 6 */
>
> struct sched_param {
> int sched_priority; /* Process execution scheduling priority */
>
> #if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER)
> int sched_ss_low_priority; /* Low scheduling priority for sporadic */
> /* server */
> struct timespec sched_ss_replenish_period;
> /* Replenishment period for sporadic server */
> struct timespec sched_ss_init_budget;
> /* Initial budget for sporadic server */
> int sched_ss_max_repl; /* Maximum pending replenishments for */
> /* sporadic server */
> #endif
> };
>
> #ifdef __cplusplus
> }
> #endif
>
> #endif
> /* end of include file */
>
More information about the Newlib
mailing list