2008-04-29 00:22:51 +04:00
|
|
|
/* $NetBSD: sched.h,v 1.9 2008/04/28 20:22:54 martin Exp $ */
|
2001-07-17 07:04:16 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2003-01-18 21:05:05 +03:00
|
|
|
* by Nathan J. Williams.
|
2001-07-17 07:04:16 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-01-18 21:05:05 +03:00
|
|
|
#ifndef _SCHED_H_
|
|
|
|
#define _SCHED_H_
|
2001-07-17 07:04:16 +04:00
|
|
|
|
2003-01-18 21:05:05 +03:00
|
|
|
#include <sys/cdefs.h>
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#include <sys/featuretest.h>
|
2001-07-17 07:04:16 +04:00
|
|
|
#include <sys/sched.h>
|
|
|
|
|
2003-01-18 21:05:05 +03:00
|
|
|
/* Required by POSIX 1003.1, section 13.1, lines 12-13. */
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
/*
|
2005-10-09 15:17:28 +04:00
|
|
|
* These are permitted to fail and return -1 and set errno = ENOSYS if
|
2003-01-18 21:05:05 +03:00
|
|
|
* _POSIX_PRIORITY_SCHEDULING is not defined.
|
|
|
|
*/
|
2003-07-08 09:39:23 +04:00
|
|
|
int sched_setparam(pid_t, const struct sched_param *);
|
|
|
|
int sched_getparam(pid_t, struct sched_param *);
|
|
|
|
int sched_setscheduler(pid_t, int, const struct sched_param *);
|
|
|
|
int sched_getscheduler(pid_t);
|
|
|
|
int sched_get_priority_max(int);
|
|
|
|
int sched_get_priority_min(int);
|
|
|
|
int sched_rr_get_interval(pid_t, struct timespec *);
|
2003-01-18 21:05:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* Not optional in the presence of _POSIX_THREADS */
|
|
|
|
int sched_yield(void);
|
2004-12-13 19:08:12 +03:00
|
|
|
int __libc_thr_yield(void);
|
2003-01-18 21:05:05 +03:00
|
|
|
__END_DECLS
|
|
|
|
|
2004-12-10 19:40:40 +03:00
|
|
|
#ifndef __LIBPTHREAD_SOURCE__
|
|
|
|
#define sched_yield __libc_thr_yield
|
|
|
|
#endif /* __LIBPTHREAD_SOURCE__ */
|
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#if defined(_NETBSD_SOURCE)
|
2001-07-17 07:04:16 +04:00
|
|
|
|
2003-01-18 21:05:05 +03:00
|
|
|
/*
|
|
|
|
* Stuff that for historical reasons is in <sched.h>, but not defined
|
|
|
|
* by any standard.
|
|
|
|
*/
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
2005-02-03 07:39:32 +03:00
|
|
|
pid_t clone(int (*)(void *), void *, int, void *);
|
|
|
|
pid_t __clone(int (*)(void *), void *, int, void *);
|
2003-01-18 21:05:05 +03:00
|
|
|
__END_DECLS
|
2001-07-17 07:04:16 +04:00
|
|
|
|
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.
This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.
I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.
Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-29 03:16:11 +04:00
|
|
|
#endif /* _NETBSD_SOURCE */
|
2001-07-17 07:04:16 +04:00
|
|
|
|
2003-01-18 21:05:05 +03:00
|
|
|
#endif /* _SCHED_H_ */
|