diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2003-12-23 22:37:04 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2003-12-23 22:37:04 +0000 |
commit | f77f861163e821db8eae3803b0b326a725d319dc (patch) | |
tree | 54a61b9516524be4f3e5eff78cd2a309b56106ba /lib | |
parent | 85a7bfe57b9dd0fbe5d3fcab5c89a297297f058d (diff) |
Add stub implementations of pthread_[gs]etconcurrency
From: FreeBSD' libc_r
ok marc@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libpthread/include/pthread.h | 4 | ||||
-rw-r--r-- | lib/libpthread/man/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libpthread/man/pthread_getconcurrency.3 | 114 | ||||
-rw-r--r-- | lib/libpthread/uthread/Makefile.inc | 3 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_concurrency.c | 63 |
5 files changed, 185 insertions, 3 deletions
diff --git a/lib/libpthread/include/pthread.h b/lib/libpthread/include/pthread.h index 18a852dfe45..ed5b2744105 100644 --- a/lib/libpthread/include/pthread.h +++ b/lib/libpthread/include/pthread.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread.h,v 1.17 2003/02/27 07:03:21 cloder Exp $ */ +/* $OpenBSD: pthread.h,v 1.18 2003/12/23 22:37:03 brad Exp $ */ /* * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu @@ -306,6 +306,8 @@ int pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param * param); int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param * param); +int pthread_getconcurrency(void); +int pthread_setconcurrency(int); #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) int pthread_attr_getinheritsched(const pthread_attr_t *, int *); diff --git a/lib/libpthread/man/Makefile.inc b/lib/libpthread/man/Makefile.inc index 46dfba808e8..7aca8757226 100644 --- a/lib/libpthread/man/Makefile.inc +++ b/lib/libpthread/man/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.16 2003/01/20 18:12:11 marc Exp $ +# $OpenBSD: Makefile.inc,v 1.17 2003/12/23 22:37:03 brad Exp $ # $FreeBSD: Makefile.inc,v 1.6 1999/08/28 00:03:02 peter Exp $ # POSIX thread man files @@ -23,6 +23,7 @@ MAN+= \ pthread_detach.3 \ pthread_equal.3 \ pthread_exit.3 \ + pthread_getconcurrency.3 \ pthread_getspecific.3 \ pthread_join.3 \ pthread_key_create.3 \ @@ -92,6 +93,7 @@ MLINKS+=flockfile.3 funlockfile.3 \ pthread_schedparam.3 pthread_setschedparam.3 \ pthread_testcancel.3 pthread_setcancelstate.3 \ pthread_testcancel.3 pthread_setcanceltype.3 \ + pthread_getconcurrency.3 pthread_setconcurrency.3 \ sem_open.3 sem_close.3 \ sem_open.3 sem_unlink.3 \ sem_wait.3 sem_trywait.3 diff --git a/lib/libpthread/man/pthread_getconcurrency.3 b/lib/libpthread/man/pthread_getconcurrency.3 new file mode 100644 index 00000000000..4bb24fb144d --- /dev/null +++ b/lib/libpthread/man/pthread_getconcurrency.3 @@ -0,0 +1,114 @@ +.\" $OpenBSD: pthread_getconcurrency.3,v 1.1 2003/12/23 22:37:03 brad Exp $ +.\" +.\" Copyright (c) 2003 Sergey Osokin <osa@FreeBSD.org.ru> +.\" All rights reserved. +.\" +.\" 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 AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_getconcurrency.3,v 1.2 2003/05/24 19:50:43 ru Exp $ +.Dd April 11, 2003 +.Dt PTHREAD_GETCONCURRENCY 3 +.Os +.Sh NAME +.Nm pthread_getconcurrency , +.Nm pthread_setconcurrency +.Nd get or set level of concurrency +.Sh SYNOPSIS +.Fd #include <pthread.h> +.Ft int +.Fn pthread_getconcurrency void +.Ft int +.Fn pthread_setconcurrency "int new_level" +.Sh DESCRIPTION +The +.Fn pthread_getconcurrency +function allows an application to inform the threads implementation +of its desired concurrency level, +.Fa new_level . +The actual level of concurrency provided by the implementation +as a result of this function call is unspecified. +If +.Fa new_level +is zero, it causes the implementation to maintain the concurrency +level at its discretion as if +.Fn pthread_setconcurrency +was never called. +The +.Fn pthread_getconcurrency +function returns the value set by a previous call to the +.Fn pthread_setconcurrency +function. +If the +.Fn pthread_setconcurrency +function was not previously called, this function returns zero to +indicate that the implementation is maintaining the concurrency +level. +When an application calls +.Fn pthread_setconcurrency , +it is informing the implementation of its desired concurrency +level. +The implementation uses this as a hint, not a requirement. +.Sh RETURN VALUES +If successful, the +.Fn pthread_setconcurrency +function returns zero. +Otherwise, an error number is returned +to indicate the error. +The +.Fn pthread_getconcurrency +function always returns the concurrency level set by a previous +call to +.Fn pthread_setconcurrency . +If the +.Fn pthread_setconcurrency +function has never been called, +.Fn pthread_getconcurrency +returns zero. +.Sh ERRORS +.Fn pthread_setconcurrency +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa new_level +is negative. +.It Bq Er EAGAIN +The value specified by +.Fa new_level +would cause a system resource to be exceeded. +.El +.Sh APPLICATION USAGE +Use of these functions changes the state of the underlying +concurrency upon which the application depends. +Library developers are advised to not use the +.Fn pthread_getconcurrency +and +.Fn pthread_setconcurrency +functions since their use may conflict with an application's +use of these functions. +.Sh STANDARDS +The +.Fn pthread_getconcurrency +and +.Fn pthread_setconcurrency +functions conform to +.St -susv2 . diff --git a/lib/libpthread/uthread/Makefile.inc b/lib/libpthread/uthread/Makefile.inc index b37a3cf4fc3..81553971e20 100644 --- a/lib/libpthread/uthread/Makefile.inc +++ b/lib/libpthread/uthread/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.15 2003/10/22 00:25:42 brad Exp $ +# $OpenBSD: Makefile.inc,v 1.16 2003/12/23 22:37:03 brad Exp $ # $FreeBSD: Makefile.inc,v 1.19 1999/08/28 00:03:19 peter Exp $ # uthread sources @@ -30,6 +30,7 @@ SRCS+= \ uthread_cancel.c \ uthread_clean.c \ uthread_close.c \ + uthread_concurrency.c \ uthread_cond.c \ uthread_condattr_destroy.c \ uthread_condattr_init.c \ diff --git a/lib/libpthread/uthread/uthread_concurrency.c b/lib/libpthread/uthread/uthread_concurrency.c new file mode 100644 index 00000000000..a82e976ab4a --- /dev/null +++ b/lib/libpthread/uthread/uthread_concurrency.c @@ -0,0 +1,63 @@ +/* $OpenBSD: uthread_concurrency.c,v 1.1 2003/12/23 22:37:03 brad Exp $ */ + +/* + * Copyright (c) 2003 Sergey Osokin <osa@FreeBSD.org.ru>. + * All rights reserved. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Sergey Osokin. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY SERGEY OSOKIN 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 AUTHOR 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. + * + * $FreeBSD: src/lib/libc_r/uthread/uthread_concurrency.c,v 1.1 2003/04/20 01:53:12 jdp Exp $ + */ + +#include <errno.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" + +static int current_concurrency = 0; + +int +pthread_getconcurrency(void) +{ + return current_concurrency; +} + +int +pthread_setconcurrency(int new_level) +{ + int ret; + + if (new_level < 0) { + ret = EINVAL; + } else { + current_concurrency = new_level; + ret = 0; + } + return(ret); +} +#endif |