Index: head/lib/libc/sys/cpuset.2 =================================================================== --- head/lib/libc/sys/cpuset.2 (revision 201891) +++ head/lib/libc/sys/cpuset.2 (revision 201892) @@ -1,226 +1,228 @@ .\" Copyright (c) 2008 Christian Brueffer .\" Copyright (c) 2008 Jeffrey Roberson .\" 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$ .\" -.Dd March 29, 2008 +.Dd January 8, 2010 .Dt CPUSET 2 .Os .Sh NAME .Nm cpuset , .Nm cpuset_getid , .Nm cpuset_setid .Nd manage CPU affinity sets .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/cpuset.h .Ft int .Fn cpuset "cpusetid_t *setid" .Ft int .Fn cpuset_setid "cpuwhich_t which" "id_t id" "cpusetid_t setid" .Ft int .Fn cpuset_getid "cpulevel_t level" "cpuwhich_t which" "id_t id" "cpusetid_t *setid" .Sh DESCRIPTION The .Nm family of system calls allow applications to control sets of processors and assign processes and threads to these sets. Processor sets contain lists of CPUs that members may run on and exist only as long as some process is a member of the set. All processes in the system have an assigned set. The default set for all processes in the system is the set numbered 1. Threads belong to the same set as the process which contains them, however, they may further restrict their set with the anonymous per-thread mask. .Pp Sets are referenced by a number of type .Ft cpuset_id_t . Each thread has a root set, an assigned set, and an anonymous mask. Only the root and assigned sets are numbered. The root set is the set of all CPUs available in the system or in the system partition the thread is running in. The assigned set is a subset of the root set and is administratively assignable on a per-process basis. Many processes and threads may be members of a numbered set. .Pp The anonymous set is a further thread-specific refinement on the assigned set. It is intended that administrators will manipulate numbered sets using .Xr cpuset 1 while application developers will manipulate anonymous sets using .Xr cpuset_setaffinity 2 . .Pp To select the correct set a value of type .Ft cpulevel_t is used. The following values for .Fa level are supported: .Bl -column CPU_LEVEL_CPUSET -offset indent .It Dv CPU_LEVEL_ROOT Ta "Root set" .It Dv CPU_LEVEL_CPUSET Ta "Assigned set" .It Dv CPU_LEVEL_WHICH Ta "Set specified by which argument" .El .Pp The .Fa which argument determines how the value of .Fa id is interpreted and is of type .Ft cpuwhich_t . The .Fa which argument may have the following values: .Bl -column CPU_WHICH_CPUSET -offset indent .It Dv CPU_WHICH_TID Ta "id is lwpid_t (thread id)" .It Dv CPU_WHICH_PID Ta "id is pid_t (process id)" .It Dv CPU_WHICH_CPUSET Ta "id is a cpusetid_t (cpuset id)" .It Dv CPU_WHICH_IRQ Ta "id is an irq number" .El .Pp An .Fa id of '-1' may be used with a .Fa which of .Dv CPU_WHICH_TID , .Dv CPU_WHICH_PID , or .Dv CPU_WHICH_CPUSET to mean the current thread, process, or current thread's cpuset. All cpuset syscalls allow this usage. .Pp A .Fa level argument of .Dv CPU_LEVEL_WHICH combined with a .Fa which argument other than .Dv CPU_WHICH_CPUSET refers to the anonymous mask of the object. This mask does not have an id and may only be manipulated with .Xr cpuset_setaffinity 2 . .Pp .Fn cpuset creates a new set containing the same CPUs as the root set of the current process and stores its id in the space provided by .Fa setid . On successful completion the calling process joins the set and is the only member. Children inherit this set after a call to .Xr fork 2 . .Pp .Fn cpuset_setid attempts to set the id of the object specified by the .Fa which argument. Currently .Dv CPU_WHICH_PID is the only acceptable value for which as threads do not have an id distinct from their process and the API does not permit changing the id of an existing set. Upon successful completion all of the threads in the target process will be running on CPUs permitted by the set. .Pp .Fn cpuset_getid retrieves a set id from the object indicated by .Fa which and stores it in the space pointed to by .Fa setid . The retrieved id may be that of either the root or assigned set depending on the value of .Fa level . .Fa level should be .Dv CPU_LEVEL_CPUSET or .Dv CPU_LEVEL_ROOT to get the set id from the process or thread specified by the .Fa id argument. Specifying .Dv CPU_LEVEL_WHICH with a process or thread is unsupported since this references the unnumbered anonymous mask. .Pp The actual contents of the sets may be retrieved or manipulated using .Xr cpuset_getaffinity 2 and .Xr cpuset_setaffinity 2 . See those manual pages for more detail. .Sh RETURN VALUES .Rv -std .Sh ERRORS The following error codes may be set in .Va errno : .Bl -tag -width Er .It Bq Er EINVAL The .Fa which or .Fa level argument was not a valid value. .It Bq Er EDEADLK The .Fn cpuset_setid call would leave a thread without a valid CPU to run on because the set does not overlap with the thread's anonymous mask. .It Bq Er EFAULT The setid pointer passed to .Fn cpuset_getid or .Fn cpuset was invalid. .It Bq Er ESRCH The object specified by the .Fa id and .Fa which arguments could not be found. .It Bq Er EPERM The calling process did not have the credentials required to complete the operation. .It Bq Er ENFILE There was no free .Ft cpusetid_t for allocation. .El .Sh SEE ALSO .Xr cpuset 1 , .Xr cpuset_getaffinity 2 , .Xr cpuset_setaffinity 2 , -.Xr CPU_SET 3 +.Xr CPU_SET 3 , +.Xr pthread_affinity_np 3 , +.Xr pthread_attr_affinity_np 3 .Sh HISTORY The .Nm family of system calls first appeared in .Fx 7.1 . .Sh AUTHOR .An Jeffrey Roberson Aq jeff@FreeBSD.org Index: head/lib/libc/sys/cpuset_getaffinity.2 =================================================================== --- head/lib/libc/sys/cpuset_getaffinity.2 (revision 201891) +++ head/lib/libc/sys/cpuset_getaffinity.2 (revision 201892) @@ -1,157 +1,159 @@ .\" Copyright (c) 2008 Christian Brueffer .\" Copyright (c) 2008 Jeffrey Roberson .\" 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$ .\" -.Dd November 29, 2008 +.Dd January 8, 2010 .Dt CPUSET 2 .Os .Sh NAME .Nm cpuset_getaffinity , .Nm cpuset_setaffinity .Nd manage CPU affinity .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In sys/param.h .In sys/cpuset.h .Ft int .Fn cpuset_getaffinity "cpulevel_t level" "cpuwhich_t which" "id_t id" "size_t setsize" "cpuset_t *mask" .Ft int .Fn cpuset_setaffinity "cpulevel_t level" "cpuwhich_t which" "id_t id" "size_t setsize" "const cpuset_t *mask" .Sh DESCRIPTION .Fn cpuset_getaffinity and .Fn cpuset_setaffinity allow the manipulation of sets of CPUs available to processes, threads, interrupts, jails and other resources. These functions may manipulate sets of CPUs that contain many processes or per-object anonymous masks that effect only a single object. .Pp The valid values for the .Fa level and .Fa which arguments are documented in .Xr cpuset 2 . These arguments specify which object and which set of the object we are referring to. Not all possible combinations are valid. For example, only processes may belong to a numbered set accessed by a .Fa level argument of .Dv CPU_LEVEL_CPUSET . All resources, however, have a mask which may be manipulated with .Dv CPU_LEVEL_WHICH . .Pp Masks of type .Ft cpuset_t are composed using the .Xr CPU_SET 2 macros. The kernel tolerates large sets as long as all CPUs specified in the set exist. Sets smaller than the kernel uses generate an error on calls to .Fn cpuset_getaffinity even if the result set would fit within the user supplied set. Calls to .Fn cpuset_setaffinity tolerate small sets with no restrictions. .Pp The supplied mask should have a size of .Fa setsize bytes. This size is usually provided by calling .Li sizeof(mask) which is ultimately determined by the value of .Dv CPU_SETSIZE as defined in .In sys/cpuset.h . .Pp .Fn cpuset_getaffinity retrieves the mask from the object specified by .Fa level , .Fa which and .Fa id and stores it in the space provided by .Fa mask . .Pp .Fn cpuset_setaffinity attempts to set the mask for the object specified by .Fa level , .Fa which and .Fa id to the value in .Fa mask . .Pp .Sh RETURN VALUES .Rv -std .Sh ERRORS The following error codes may be set in .Va errno : .Bl -tag -width Er .It Bq Er EINVAL The .Fa level or .Fa which argument was not a valid value. .It Bq Er EDEADLK The .Fn cpuset_setaffinity call would leave a thread without a valid CPU to run on because the set does not overlap with the thread's anonymous mask. .It Bq Er EFAULT The mask pointer passed was invalid. .It Bq Er ESRCH The object specified by the .Fa id and .Fa which arguments could not be found. .It Bq Er ERANGE The .Fa cpusetsize was either preposterously large or smaller than the kernel set size. .It Bq Er EPERM The calling process did not have the credentials required to complete the operation. .El .Sh SEE ALSO .Xr cpuset 1 , .Xr cpuset 2 , .Xr cpuset_getid 2 , .Xr cpuset_setid 2 , -.Xr CPU_SET 3 +.Xr CPU_SET 3 , +.Xr pthread_affinity_np 3 , +.Xr pthread_attr_affinity_np 3 .Sh HISTORY The .Nm family of system calls first appeared in .Fx 7.1 . .Sh AUTHOR .An Jeffrey Roberson Aq jeff@FreeBSD.org Index: head/share/man/man3/Makefile =================================================================== --- head/share/man/man3/Makefile (revision 201891) +++ head/share/man/man3/Makefile (revision 201892) @@ -1,272 +1,278 @@ # @(#)Makefile 8.2 (Berkeley) 12/13/93 # $FreeBSD$ .include MAN= assert.3 \ bitstring.3 \ end.3 \ fpgetround.3 \ intro.3 \ makedev.3 \ ${PTHREAD_MAN} \ queue.3 \ siginfo.3 \ stdarg.3 \ sysexits.3 \ tgmath.3 \ timeradd.3 \ tree.3 MLINKS= bitstring.3 bit_alloc.3 \ bitstring.3 bit_clear.3 \ bitstring.3 bit_decl.3 \ bitstring.3 bit_ffc.3 \ bitstring.3 bit_ffs.3 \ bitstring.3 bit_nclear.3 \ bitstring.3 bit_nset.3 \ bitstring.3 bit_set.3 \ bitstring.3 bitstr_size.3 \ bitstring.3 bit_test.3 MLINKS+= end.3 edata.3 \ end.3 etext.3 MLINKS+= fpgetround.3 fpgetmask.3 \ fpgetround.3 fpgetprec.3 \ fpgetround.3 fpgetsticky.3 \ fpgetround.3 fpresetsticky.3 \ fpgetround.3 fpsetmask.3 \ fpgetround.3 fpsetprec.3 \ fpgetround.3 fpsetround.3 MLINKS+= makedev.3 major.3 \ makedev.3 minor.3 MLINKS+= ${PTHREAD_MLINKS} MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 LIST_ENTRY.3 \ queue.3 LIST_FIRST.3 \ queue.3 LIST_FOREACH.3 \ queue.3 LIST_FOREACH_SAFE.3 \ queue.3 LIST_HEAD.3 \ queue.3 LIST_HEAD_INITIALIZER.3 \ queue.3 LIST_INIT.3 \ queue.3 LIST_INSERT_AFTER.3 \ queue.3 LIST_INSERT_BEFORE.3 \ queue.3 LIST_INSERT_HEAD.3 \ queue.3 LIST_NEXT.3 \ queue.3 LIST_REMOVE.3 \ queue.3 SLIST_EMPTY.3 \ queue.3 SLIST_ENTRY.3 \ queue.3 SLIST_FIRST.3 \ queue.3 SLIST_FOREACH.3 \ queue.3 SLIST_FOREACH_SAFE.3 \ queue.3 SLIST_HEAD.3 \ queue.3 SLIST_HEAD_INITIALIZER.3 \ queue.3 SLIST_INIT.3 \ queue.3 SLIST_INSERT_AFTER.3 \ queue.3 SLIST_INSERT_HEAD.3 \ queue.3 SLIST_NEXT.3 \ queue.3 SLIST_REMOVE.3 \ queue.3 SLIST_REMOVE_AFTER.3 \ queue.3 SLIST_REMOVE_HEAD.3 \ queue.3 STAILQ_CONCAT.3 \ queue.3 STAILQ_EMPTY.3 \ queue.3 STAILQ_ENTRY.3 \ queue.3 STAILQ_FIRST.3 \ queue.3 STAILQ_FOREACH.3 \ queue.3 STAILQ_FOREACH_SAFE.3 \ queue.3 STAILQ_HEAD.3 \ queue.3 STAILQ_HEAD_INITIALIZER.3 \ queue.3 STAILQ_INIT.3 \ queue.3 STAILQ_INSERT_AFTER.3 \ queue.3 STAILQ_INSERT_HEAD.3 \ queue.3 STAILQ_INSERT_TAIL.3 \ queue.3 STAILQ_LAST.3 \ queue.3 STAILQ_NEXT.3 \ queue.3 STAILQ_REMOVE.3 \ queue.3 STAILQ_REMOVE_AFTER.3 \ queue.3 STAILQ_REMOVE_HEAD.3 \ queue.3 TAILQ_CONCAT.3 \ queue.3 TAILQ_EMPTY.3 \ queue.3 TAILQ_ENTRY.3 \ queue.3 TAILQ_FIRST.3 \ queue.3 TAILQ_FOREACH.3 \ queue.3 TAILQ_FOREACH_REVERSE.3 \ queue.3 TAILQ_FOREACH_REVERSE_SAFE.3 \ queue.3 TAILQ_FOREACH_SAFE.3 \ queue.3 TAILQ_HEAD.3 \ queue.3 TAILQ_HEAD_INITIALIZER.3 \ queue.3 TAILQ_INIT.3 \ queue.3 TAILQ_INSERT_AFTER.3 \ queue.3 TAILQ_INSERT_BEFORE.3 \ queue.3 TAILQ_INSERT_HEAD.3 \ queue.3 TAILQ_INSERT_TAIL.3 \ queue.3 TAILQ_LAST.3 \ queue.3 TAILQ_NEXT.3 \ queue.3 TAILQ_PREV.3 \ queue.3 TAILQ_REMOVE.3 MLINKS+= stdarg.3 va_arg.3 \ stdarg.3 va_copy.3 \ stdarg.3 va_end.3 \ stdarg.3 varargs.3 \ stdarg.3 va_start.3 MLINKS+= timeradd.3 timerclear.3 \ timeradd.3 timercmp.3 \ timeradd.3 timerisset.3 \ timeradd.3 timersub.3 MLINKS+= tree.3 RB_EMPTY.3 \ tree.3 RB_ENTRY.3 \ tree.3 RB_FIND.3 \ tree.3 RB_FOREACH.3 \ tree.3 RB_FOREACH_REVERSE.3 \ tree.3 RB_GENERATE.3 \ tree.3 RB_GENERATE_STATIC.3 \ tree.3 RB_HEAD.3 \ tree.3 RB_INIT.3 \ tree.3 RB_INITIALIZER.3 \ tree.3 RB_INSERT.3 \ tree.3 RB_LEFT.3 \ tree.3 RB_MAX.3 \ tree.3 RB_MIN.3 \ tree.3 RB_NEXT.3 \ tree.3 RB_NFIND.3 \ tree.3 RB_PARENT.3 \ tree.3 RB_PREV.3 \ tree.3 RB_PROTOTYPE.3 \ tree.3 RB_PROTOTYPE_STATIC.3 \ tree.3 RB_REMOVE.3 \ tree.3 RB_RIGHT.3 \ tree.3 RB_ROOT.3 \ tree.3 SPLAY_EMPTY.3 \ tree.3 SPLAY_ENTRY.3 \ tree.3 SPLAY_FIND.3 \ tree.3 SPLAY_FOREACH.3 \ tree.3 SPLAY_GENERATE.3 \ tree.3 SPLAY_HEAD.3 \ tree.3 SPLAY_INIT.3 \ tree.3 SPLAY_INITIALIZER.3 \ tree.3 SPLAY_INSERT.3 \ tree.3 SPLAY_LEFT.3 \ tree.3 SPLAY_MAX.3 \ tree.3 SPLAY_MIN.3 \ tree.3 SPLAY_NEXT.3 \ tree.3 SPLAY_PROTOTYPE.3 \ tree.3 SPLAY_REMOVE.3 \ tree.3 SPLAY_RIGHT.3 \ tree.3 SPLAY_ROOT.3 .if ${MK_LIBTHR} != "no" PTHREAD_MAN= pthread.3 \ + pthread_affinity_np.3 \ pthread_atfork.3 \ pthread_attr.3 \ + pthread_attr_affinity_np.3 \ pthread_attr_get_np.3 \ pthread_attr_setcreatesuspend_np.3 \ pthread_barrierattr.3 \ pthread_barrier_destroy.3 \ pthread_cancel.3 \ pthread_cleanup_pop.3 \ pthread_cleanup_push.3 \ pthread_condattr.3 \ pthread_cond_broadcast.3 \ pthread_cond_destroy.3 \ pthread_cond_init.3 \ pthread_cond_signal.3 \ pthread_cond_timedwait.3 \ pthread_cond_wait.3 \ pthread_create.3 \ pthread_detach.3 \ pthread_equal.3 \ pthread_exit.3 \ pthread_getconcurrency.3 \ pthread_getspecific.3 \ pthread_join.3 \ pthread_key_create.3 \ pthread_key_delete.3 \ pthread_kill.3 \ pthread_main_np.3 \ pthread_multi_np.3 \ pthread_mutexattr.3 \ pthread_mutexattr_getkind_np.3 \ pthread_mutex_destroy.3 \ pthread_mutex_init.3 \ pthread_mutex_lock.3 \ pthread_mutex_timedlock.3 \ pthread_mutex_trylock.3 \ pthread_mutex_unlock.3 \ pthread_once.3 \ pthread_resume_all_np.3 \ pthread_resume_np.3 \ pthread_rwlockattr_destroy.3 \ pthread_rwlockattr_getpshared.3 \ pthread_rwlockattr_init.3 \ pthread_rwlockattr_setpshared.3 \ pthread_rwlock_destroy.3 \ pthread_rwlock_init.3 \ pthread_rwlock_rdlock.3 \ pthread_rwlock_timedrdlock.3 \ pthread_rwlock_timedwrlock.3 \ pthread_rwlock_unlock.3 \ pthread_rwlock_wrlock.3 \ pthread_schedparam.3 \ pthread_self.3 \ pthread_set_name_np.3 \ pthread_setspecific.3 \ pthread_sigmask.3 \ pthread_spin_init.3 \ pthread_spin_lock.3 \ pthread_suspend_all_np.3 \ pthread_suspend_np.3 \ pthread_switch_add_np.3 \ pthread_testcancel.3 \ pthread_yield.3 -PTHREAD_MLINKS= pthread_attr.3 pthread_attr_destroy.3 \ +PTHREAD_MLINKS= pthread_affinity_np.3 pthread_getaffinity_np.3 \ + pthread_affinity_np.3 pthread_setaffinity_np.3 +PTHREAD_MLINKS+=pthread_attr.3 pthread_attr_destroy.3 \ pthread_attr.3 pthread_attr_getdetachstate.3 \ pthread_attr.3 pthread_attr_getguardsize.3 \ pthread_attr.3 pthread_attr_getinheritsched.3 \ pthread_attr.3 pthread_attr_getschedparam.3 \ pthread_attr.3 pthread_attr_getschedpolicy.3 \ pthread_attr.3 pthread_attr_getscope.3 \ pthread_attr.3 pthread_attr_getstack.3 \ pthread_attr.3 pthread_attr_getstackaddr.3 \ pthread_attr.3 pthread_attr_getstacksize.3 \ pthread_attr.3 pthread_attr_init.3 \ pthread_attr.3 pthread_attr_setdetachstate.3 \ pthread_attr.3 pthread_attr_setguardsize.3 \ pthread_attr.3 pthread_attr_setinheritsched.3 \ pthread_attr.3 pthread_attr_setschedparam.3 \ pthread_attr.3 pthread_attr_setschedpolicy.3 \ pthread_attr.3 pthread_attr_setscope.3 \ pthread_attr.3 pthread_attr_setstack.3 \ pthread_attr.3 pthread_attr_setstackaddr.3 \ pthread_attr.3 pthread_attr_setstacksize.3 +PTHREAD_MLINKS+=pthread_attr_affinity_np.3 pthread_attr_getaffinity_np.3 \ + pthread_attr_affinity_np.3 pthread_attr_setaffinity_np.3 PTHREAD_MLINKS+=pthread_barrierattr.3 pthread_barrierattr_destroy.3 \ pthread_barrierattr.3 pthread_barrierattr_getpshared.3 \ pthread_barrierattr.3 pthread_barrierattr_init.3 \ pthread_barrierattr.3 pthread_barrierattr_setpshared.3 PTHREAD_MLINKS+=pthread_barrier_destroy.3 pthread_barrier_init.3 \ pthread_barrier_destroy.3 pthread_barrier_wait.3 PTHREAD_MLINKS+=pthread_condattr.3 pthread_condattr_destroy.3 \ pthread_condattr.3 pthread_condattr_init.3 PTHREAD_MLINKS+=pthread_getconcurrency.3 pthread_setconcurrency.3 PTHREAD_MLINKS+=pthread_multi_np.3 pthread_single_np.3 PTHREAD_MLINKS+=pthread_mutexattr.3 pthread_mutexattr_destroy.3 \ pthread_mutexattr.3 pthread_mutexattr_getprioceiling.3 \ pthread_mutexattr.3 pthread_mutexattr_getprotocol.3 \ pthread_mutexattr.3 pthread_mutexattr_gettype.3 \ pthread_mutexattr.3 pthread_mutexattr_init.3 \ pthread_mutexattr.3 pthread_mutexattr_setprioceiling.3 \ pthread_mutexattr.3 pthread_mutexattr_setprotocol.3 \ pthread_mutexattr.3 pthread_mutexattr_settype.3 PTHREAD_MLINKS+=pthread_mutexattr_getkind_np.3 pthread_mutexattr_setkind_np.3 PTHREAD_MLINKS+=pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 PTHREAD_MLINKS+=pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 PTHREAD_MLINKS+=pthread_schedparam.3 pthread_getschedparam.3 \ pthread_schedparam.3 pthread_setschedparam.3 PTHREAD_MLINKS+=pthread_spin_init.3 pthread_spin_destroy.3 \ pthread_spin_lock.3 pthread_spin_trylock.3 \ pthread_spin_lock.3 pthread_spin_unlock.3 PTHREAD_MLINKS+=pthread_switch_add_np.3 pthread_switch_delete_np.3 PTHREAD_MLINKS+=pthread_testcancel.3 pthread_setcancelstate.3 \ pthread_testcancel.3 pthread_setcanceltype.3 .endif .include Index: head/share/man/man3/pthread.3 =================================================================== --- head/share/man/man3/pthread.3 (revision 201891) +++ head/share/man/man3/pthread.3 (revision 201892) @@ -1,548 +1,550 @@ .\" Copyright (c) 1996 John Birrell . .\" 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 John Birrell. .\" 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 JOHN BIRRELL 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 REGENTS 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$ .\" -.Dd April 1, 2009 +.Dd January 8, 2010 .Dt PTHREAD 3 .Os .Sh NAME .Nm pthread .Nd POSIX thread functions .Sh LIBRARY .Lb libpthread .Sh SYNOPSIS .In pthread.h .Sh DESCRIPTION POSIX threads are a set of functions that support applications with requirements for multiple flows of control, called .Em threads , within a process. Multithreading is used to improve the performance of a program. .Pp The POSIX thread functions are summarized in this section in the following groups: .Pp .Bl -bullet -offset indent -compact .It Thread Routines .It Attribute Object Routines .It Mutex Routines .It Condition Variable Routines .It Read/Write Lock Routines .It Per-Thread Context Routines .It Cleanup Routines .El .Ss Thread Routines .Bl -tag -width indent .It Xo .Ft int .Fo pthread_create .Fa "pthread_t *thread" "const pthread_attr_t *attr" .Fa "void *\*[lp]*start_routine\*[rp]\*[lp]void *\*[rp]" "void *arg" .Fc .Xc Creates a new thread of execution. .It Xo .Ft int .Fn pthread_cancel "pthread_t thread" .Xc Cancels execution of a thread. .It Xo .Ft int .Fn pthread_detach "pthread_t thread" .Xc Marks a thread for deletion. .It Xo .Ft int .Fn pthread_equal "pthread_t t1" "pthread_t t2" .Xc Compares two thread IDs. .It Xo .Ft void .Fn pthread_exit "void *value_ptr" .Xc Terminates the calling thread. .It Xo .Ft int .Fn pthread_join "pthread_t thread" "void **value_ptr" .Xc Causes the calling thread to wait for the termination of the specified thread. .It Xo .Ft int .Fn pthread_kill "pthread_t thread" "int sig" .Xc Delivers a signal to a specified thread. .It Xo .Ft int .Fn pthread_once "pthread_once_t *once_control" "void \*[lp]*init_routine\*[rp]\*[lp]void\*[rp]" .Xc Calls an initialization routine once. .It Xo .Ft pthread_t .Fn pthread_self void .Xc Returns the thread ID of the calling thread. .It Xo .Ft int .Fn pthread_setcancelstate "int state" "int *oldstate" .Xc Sets the current thread's cancelability state. .It Xo .Ft int .Fn pthread_setcanceltype "int type" "int *oldtype" .Xc Sets the current thread's cancelability type. .It Xo .Ft void .Fn pthread_testcancel void .Xc Creates a cancellation point in the calling thread. .It Xo .Ft void .Fn pthread_yield void .Xc Allows the scheduler to run another thread instead of the current one. .El .Ss Attribute Object Routines .Bl -tag -width indent .It Xo .Ft int .Fn pthread_attr_destroy "pthread_attr_t *attr" .Xc Destroy a thread attributes object. .It Xo .Ft int .Fo pthread_attr_getinheritsched .Fa "const pthread_attr_t *attr" "int *inheritsched" .Fc .Xc Get the inherit scheduling attribute from a thread attributes object. .It Xo .Ft int .Fo pthread_attr_getschedparam .Fa "const pthread_attr_t *attr" "struct sched_param *param" .Fc .Xc Get the scheduling parameter attribute from a thread attributes object. .It Xo .Ft int .Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy" .Xc Get the scheduling policy attribute from a thread attributes object. .It Xo .Ft int .Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope" .Xc Get the contention scope attribute from a thread attributes object. .It Xo .Ft int .Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize" .Xc Get the stack size attribute from a thread attributes object. .It Xo .Ft int .Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr" .Xc Get the stack address attribute from a thread attributes object. .It Xo .Ft int .Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate" .Xc Get the detach state attribute from a thread attributes object. .It Xo .Ft int .Fn pthread_attr_init "pthread_attr_t *attr" .Xc Initialize a thread attributes object with default values. .It Xo .Ft int .Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched" .Xc Set the inherit scheduling attribute in a thread attributes object. .It Xo .Ft int .Fo pthread_attr_setschedparam .Fa "pthread_attr_t *attr" "const struct sched_param *param" .Fc .Xc Set the scheduling parameter attribute in a thread attributes object. .It Xo .Ft int .Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy" .Xc Set the scheduling policy attribute in a thread attributes object. .It Xo .Ft int .Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" .Xc Set the contention scope attribute in a thread attributes object. .It Xo .Ft int .Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" .Xc Set the stack size attribute in a thread attributes object. .It Xo .Ft int .Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" .Xc Set the stack address attribute in a thread attributes object. .It Xo .Ft int .Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" .Xc Set the detach state in a thread attributes object. .El .Ss Mutex Routines .Bl -tag -width indent .It Xo .Ft int .Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr" .Xc Destroy a mutex attributes object. .It Xo .Ft int .Fn pthread_mutexattr_getprioceiling "pthread_mutexattr_t *attr" "int *ceiling" .Xc Obtain priority ceiling attribute of mutex attribute object. .It Xo .Ft int .Fn pthread_mutexattr_getprotocol "pthread_mutexattr_t *attr" "int *protocol" .Xc Obtain protocol attribute of mutex attribute object. .It Xo .Ft int .Fn pthread_mutexattr_gettype "pthread_mutexattr_t *attr" "int *type" .Xc Obtain the mutex type attribute in the specified mutex attributes object. .It Xo .Ft int .Fn pthread_mutexattr_init "pthread_mutexattr_t *attr" .Xc Initialize a mutex attributes object with default values. .It Xo .Ft int .Fn pthread_mutexattr_setprioceiling "pthread_mutexattr_t *attr" "int ceiling" .Xc Set priority ceiling attribute of mutex attribute object. .It Xo .Ft int .Fn pthread_mutexattr_setprotocol "pthread_mutexattr_t *attr" "int protocol" .Xc Set protocol attribute of mutex attribute object. .It Xo .Ft int .Fn pthread_mutexattr_settype "pthread_mutexattr_t *attr" "int type" .Xc Set the mutex type attribute that is used when a mutex is created. .It Xo .Ft int .Fn pthread_mutex_destroy "pthread_mutex_t *mutex" .Xc Destroy a mutex. .It Xo .Ft int .Fo pthread_mutex_init .Fa "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" .Fc .Xc Initialize a mutex with specified attributes. .It Xo .Ft int .Fn pthread_mutex_lock "pthread_mutex_t *mutex" .Xc Lock a mutex and block until it becomes available. .It Xo .Ft int .Fo pthread_mutex_timedlock .Fa "pthread_mutex_t *mutex" "const struct timespec *abstime" .Fc .Xc Lock a mutex and block until it becomes available or until the timeout expires. .It Xo .Ft int .Fn pthread_mutex_trylock "pthread_mutex_t *mutex" .Xc Try to lock a mutex, but do not block if the mutex is locked by another thread, including the current thread. .It Xo .Ft int .Fn pthread_mutex_unlock "pthread_mutex_t *mutex" .Xc Unlock a mutex. .El .Ss Condition Variable Routines .Bl -tag -width indent .It Xo .Ft int .Fn pthread_condattr_destroy "pthread_condattr_t *attr" .Xc Destroy a condition variable attributes object. .It Xo .Ft int .Fn pthread_condattr_init "pthread_condattr_t *attr" .Xc Initialize a condition variable attributes object with default values. .It Xo .Ft int .Fn pthread_cond_broadcast "pthread_cond_t *cond" .Xc Unblock all threads currently blocked on the specified condition variable. .It Xo .Ft int .Fn pthread_cond_destroy "pthread_cond_t *cond" .Xc Destroy a condition variable. .It Xo .Ft int .Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" .Xc Initialize a condition variable with specified attributes. .It Xo .Ft int .Fn pthread_cond_signal "pthread_cond_t *cond" .Xc Unblock at least one of the threads blocked on the specified condition variable. .It Xo .Ft int .Fo pthread_cond_timedwait .Fa "pthread_cond_t *cond" "pthread_mutex_t *mutex" .Fa "const struct timespec *abstime" .Fc .Xc Wait no longer than the specified time for a condition and lock the specified mutex. .It Xo .Ft int .Fn pthread_cond_wait "pthread_cond_t *" "pthread_mutex_t *mutex" .Xc Wait for a condition and lock the specified mutex. .El .Ss Read/Write Lock Routines .Bl -tag -width indent .It Xo .Ft int .Fn pthread_rwlock_destroy "pthread_rwlock_t *lock" .Xc Destroy a read/write lock object. .It Xo .Ft int .Fo pthread_rwlock_init .Fa "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" .Fc .Xc Initialize a read/write lock object. .It Xo .Ft int .Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock" .Xc Lock a read/write lock for reading, blocking until the lock can be acquired. .It Xo .Ft int .Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock" .Xc Attempt to lock a read/write lock for reading, without blocking if the lock is unavailable. .It Xo .Ft int .Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock" .Xc Attempt to lock a read/write lock for writing, without blocking if the lock is unavailable. .It Xo .Ft int .Fn pthread_rwlock_unlock "pthread_rwlock_t *lock" .Xc Unlock a read/write lock. .It Xo .Ft int .Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock" .Xc Lock a read/write lock for writing, blocking until the lock can be acquired. .It Xo .Ft int .Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr" .Xc Destroy a read/write lock attribute object. .It Xo .Ft int .Fo pthread_rwlockattr_getpshared .Fa "const pthread_rwlockattr_t *attr" "int *pshared" .Fc .Xc Retrieve the process shared setting for the read/write lock attribute object. .It Xo .Ft int .Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr" .Xc Initialize a read/write lock attribute object. .It Xo .Ft int .Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared" .Xc Set the process shared setting for the read/write lock attribute object. .El .Ss Per-Thread Context Routines .Bl -tag -width indent .It Xo .Ft int .Fn pthread_key_create "pthread_key_t *key" "void \*[lp]*routine\*[rp]\*[lp]void *\*[rp]" .Xc Create a thread-specific data key. .It Xo .Ft int .Fn pthread_key_delete "pthread_key_t key" .Xc Delete a thread-specific data key. .It Xo .Ft "void *" .Fn pthread_getspecific "pthread_key_t key" .Xc Get the thread-specific value for the specified key. .It Xo .Ft int .Fn pthread_setspecific "pthread_key_t key" "const void *value_ptr" .Xc Set the thread-specific value for the specified key. .El .Ss Cleanup Routines .Bl -tag -width indent .It Xo .Ft int .Fo pthread_atfork .Fa "void \*[lp]*prepare\*[rp]\*[lp]void\*[rp]" .Fa "void \*[lp]*parent\*[rp]\*[lp]void\*[rp]" .Fa "void \*[lp]*child\*[rp]\*[lp]void\*[rp]" .Fc .Xc Register fork handlers .It Xo .Ft void .Fn pthread_cleanup_pop "int execute" .Xc Remove the routine at the top of the calling thread's cancellation cleanup stack and optionally invoke it. .It Xo .Ft void .Fn pthread_cleanup_push "void \*[lp]*routine\*[rp]\*[lp]void *\*[rp]" "void *routine_arg" .Xc Push the specified cancellation cleanup handler onto the calling thread's cancellation stack. .El .Sh IMPLEMENTATION NOTES The current .Fx POSIX thread implementation is built into the .Lb libthr library. It contains thread-safe versions of .Lb libc functions and the thread functions. Threaded applications are linked with this library. .Sh SEE ALSO .Xr libthr 3 , +.Xr pthread_affinity_np 3 , .Xr pthread_atfork 3 , +.Xr pthread_attr 3 , .Xr pthread_cancel 3 , .Xr pthread_cleanup_pop 3 , .Xr pthread_cleanup_push 3 , .Xr pthread_condattr_destroy 3 , .Xr pthread_condattr_init 3 , .Xr pthread_cond_broadcast 3 , .Xr pthread_cond_destroy 3 , .Xr pthread_cond_init 3 , .Xr pthread_cond_signal 3 , .Xr pthread_cond_timedwait 3 , .Xr pthread_cond_wait 3 , .Xr pthread_create 3 , .Xr pthread_detach 3 , .Xr pthread_equal 3 , .Xr pthread_exit 3 , .Xr pthread_getspecific 3 , .Xr pthread_join 3 , .Xr pthread_key_delete 3 , .Xr pthread_kill 3 , .Xr pthread_mutexattr_destroy 3 , .Xr pthread_mutexattr_getprioceiling 3 , .Xr pthread_mutexattr_getprotocol 3 , .Xr pthread_mutexattr_gettype 3 , .Xr pthread_mutexattr_init 3 , .Xr pthread_mutexattr_setprioceiling 3 , .Xr pthread_mutexattr_setprotocol 3 , .Xr pthread_mutexattr_settype 3 , .Xr pthread_mutex_destroy 3 , .Xr pthread_mutex_init 3 , .Xr pthread_mutex_lock 3 , .Xr pthread_mutex_trylock 3 , .Xr pthread_mutex_unlock 3 , .Xr pthread_once 3 , .Xr pthread_rwlockattr_destroy 3 , .Xr pthread_rwlockattr_getpshared 3 , .Xr pthread_rwlockattr_init 3 , .Xr pthread_rwlockattr_setpshared 3 , .Xr pthread_rwlock_destroy 3 , .Xr pthread_rwlock_init 3 , .Xr pthread_rwlock_rdlock 3 , .Xr pthread_rwlock_unlock 3 , .Xr pthread_rwlock_wrlock 3 , .Xr pthread_self 3 , .Xr pthread_setcancelstate 3 , .Xr pthread_setcanceltype 3 , .Xr pthread_setspecific 3 , .Xr pthread_testcancel 3 .Sh STANDARDS The functions with the .Nm pthread_ prefix and not .Nm _np suffix or .Nm pthread_rwlock prefix conform to .St -p1003.1-96 . .Pp The functions with the .Nm pthread_ prefix and .Nm _np suffix are non-portable extensions to POSIX threads. .Pp The functions with the .Nm pthread_rwlock prefix are extensions created by The Open Group as part of the .St -susv2 . Index: head/share/man/man3/pthread_affinity_np.3 =================================================================== --- head/share/man/man3/pthread_affinity_np.3 (nonexistent) +++ head/share/man/man3/pthread_affinity_np.3 (revision 201892) @@ -0,0 +1,157 @@ +.\"- +.\" Copyright (c) 2010 Xin LI +.\" 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$ +.\" +.Dd January 8, 2010 +.Dt PTHREAD_AFFINITY_NP 3 +.Os +.Sh NAME +.Nm pthread_getaffinity_np , +.Nm pthread_setaffinity_np +.Nd manage CPU affinity +.Sh LIBRARY +.Lb libpthread +.Sh SYNOPSIS +.In pthread_np.h +.Ft int +.Fn pthread_getaffinity_np "pthread_t td" "size_t cpusetsize" "cpuset_t *cpusetp" +.Ft int +.Fn pthread_setaffinity_np "pthread_t td" "size_t cpusetsize" "const cpuset_t *cpusetp" +.Sh DESCRIPTION +.Fn pthread_getaffinity_np +and +.Fn pthread_setaffinity_np +allow the manipulation of sets of CPUs available to specified thread. +.Pp +Masks of type +.Ft cpuset_t +are composed using the +.Xr CPU_SET 2 +macros. +The kernel tolerates large sets as long as all CPUs specified +in the set exist. +Sets smaller than the kernel uses generate an error on calls to +.Fn pthread_getaffinity_np +even if the result set would fit within the user supplied set. +Calls to +.Fn pthread_setaffinity_np +tolerate small sets with no restrictions. +.Pp +The supplied mask should have a size of +.Fa cpusetsize +bytes. +This size is usually provided by calling +.Li sizeof(cpuset_t) +which is ultimately determined by the value of +.Dv CPU_SETSIZE +as defined in +.In sys/cpuset.h . +.Pp +.Fn pthread_getaffinity_np +retrieves the +mask from the thread specified by +.Fa td , +and stores it in the space provided by +.Fa cpumaskp . +.Pp +.Fn pthread_setaffinity_np +attempts to set the mask for the thread specified by +.Fa td +to the value in +.Fa cpumaskp . +.Pp +.Sh RETURN VALUES +If successful, the +.Fn pthread_getaffinity_np +and +.Fn pthread_setaffinity_np +functions will return zero. +Otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +The +.Fn pthread_getaffinity_np +and +.Fn pthread_setaffinity_np +functions may fail if: +.Bl -tag -width Er +.It Bq Er EDEADLK +The +.Fn pthread_setaffinity_np +call would leave a thread without a valid CPU to run on because the set +does not overlap with the thread's anonymous mask. +.It Bq Er EFAULT +The +.Fa cpumaskp +pointer passed was invalid. +.It Bq Er ESRCH +The thread specified by the +.Fa td +argument could not be found. +.It Bq Er ERANGE +The +.Fa cpusetsize +was either preposterously large or smaller than the kernel set size. +.It Bq Er EPERM +The calling thread did not have the credentials required to complete the +operation. +.El +.Sh SEE ALSO +.Xr cpuset 1 , +.Xr cpuset 2 , +.Xr cpuset_getid 2 , +.Xr cpuset_setid 2 , +.Xr CPU_SET 3 , +.Xr pthread 3 , +.Xr pthread_attr_get_affinity_np 3 , +.Xr pthread_attr_set_affinity_np 3 . +.Sh STANDARDS +The +.Nm pthread_getaffinity_np +and +.Nm pthread_setaffinity_np +functions are non-standard +.Fx +extensions and may be not available on other operating systems. +.Sh HISTORY +The +.Nm pthread_getaffinity_np +and +.Nm pthread_setaffinity_np +function first appeared in +.Fx 7.2 . +.Sh AUTHORS +.An -nosplit +The +.Nm pthread_getaffinity_np +and +.Nm pthread_setaffinity_np +functions were written by +.An David Xu +.Aq davidxu@FreeBSD.org , +and this manpage was written by +.An Xin LI +.Aq delphij@FreeBSD.org . Property changes on: head/share/man/man3/pthread_affinity_np.3 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/share/man/man3/pthread_attr.3 =================================================================== --- head/share/man/man3/pthread_attr.3 (revision 201891) +++ head/share/man/man3/pthread_attr.3 (revision 201892) @@ -1,238 +1,238 @@ .\" Copyright (C) 2000 Jason Evans . .\" 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(s), this list of conditions and the following disclaimer as .\" the first lines of this file unmodified other than the possible .\" addition of one or more copyright notices. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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$ -.Dd April 28, 2000 +.Dd January 8, 2010 .Dt PTHREAD_ATTR 3 .Os .Sh NAME .Nm pthread_attr_init , .Nm pthread_attr_destroy , .Nm pthread_attr_setstack , .Nm pthread_attr_getstack , .Nm pthread_attr_setstacksize , .Nm pthread_attr_getstacksize , .Nm pthread_attr_setguardsize , .Nm pthread_attr_getguardsize , .Nm pthread_attr_setstackaddr , .Nm pthread_attr_getstackaddr , .Nm pthread_attr_setdetachstate , .Nm pthread_attr_getdetachstate , .Nm pthread_attr_setinheritsched , .Nm pthread_attr_getinheritsched , .Nm pthread_attr_setschedparam , .Nm pthread_attr_getschedparam , .Nm pthread_attr_setschedpolicy , .Nm pthread_attr_getschedpolicy , .Nm pthread_attr_setscope , .Nm pthread_attr_getscope .Nd thread attribute operations .Sh LIBRARY .Lb libpthread .Sh SYNOPSIS .In pthread.h .Ft int .Fn pthread_attr_init "pthread_attr_t *attr" .Ft int .Fn pthread_attr_destroy "pthread_attr_t *attr" .Ft int .Fn pthread_attr_setstack "pthread_attr_t *attr" " void *stackaddr" "size_t stacksize" .Ft int .Fn pthread_attr_getstack "const pthread_attr_t * restrict attr" "void ** restrict stackaddr" "size_t * restrict stacksize" .Ft int .Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" .Ft int .Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize" .Ft int .Fn pthread_attr_setguardsize "pthread_attr_t *attr" "size_t guardsize" .Ft int .Fn pthread_attr_getguardsize "const pthread_attr_t *attr" "size_t *guardsize" .Ft int .Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" .Ft int .Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr" .Ft int .Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" .Ft int .Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate" .Ft int .Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched" .Ft int .Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched" .Ft int .Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param" .Ft int .Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param" .Ft int .Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy" .Ft int .Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy" .Ft int .Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" .Ft int .Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope" .Sh DESCRIPTION Thread attributes are used to specify parameters to .Fn pthread_create . One attribute object can be used in multiple calls to .Fn pthread_create , with or without modifications between calls. .Pp The .Fn pthread_attr_init function initializes .Fa attr with all the default thread attributes. .Pp The .Fn pthread_attr_destroy function destroys .Fa attr . .Pp The .Fn pthread_attr_set* functions set the attribute that corresponds to each function name. .Pp The .Fn pthread_attr_get* functions copy the value of the attribute that corresponds to each function name to the location pointed to by the second function parameter. .Sh RETURN VALUES If successful, these functions return 0. Otherwise, an error number is returned to indicate the error. .Sh ERRORS The .Fn pthread_attr_init function will fail if: .Bl -tag -width Er .It Bq Er ENOMEM Out of memory. .El .Pp The .Fn pthread_attr_destroy function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for .Fa attr . .El .Pp The .Fn pthread_attr_setstacksize and .Fn pthread_attr_setstack functions will fail if: .Bl -tag -width Er .It Bq Er EINVAL .Fa stacksize is less than .Dv PTHREAD_STACK_MIN . .El .Pp The .Fn pthread_attr_setdetachstate function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for .Fa detachstate . .El .Pp The .Fn pthread_attr_setinheritsched function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for .Fa attr . .El .Pp The .Fn pthread_attr_setschedparam function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for .Fa attr . .It Bq Er ENOTSUP Invalid value for .Fa param . .El .Pp The .Fn pthread_attr_setschedpolicy function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for .Fa attr . .It Bq Er ENOTSUP Invalid or unsupported value for .Fa policy . .El .Pp The .Fn pthread_attr_setscope function will fail if: .Bl -tag -width Er .It Bq Er EINVAL Invalid value for .Fa attr . .It Bq Er ENOTSUP Invalid or unsupported value for .Fa contentionscope . .El .Sh SEE ALSO .Xr pthread_attr_get_np 3 , +.Xr pthread_attr_affinity_np 3 , .Xr pthread_create 3 .Sh STANDARDS -The .Fn pthread_attr_init , .Fn pthread_attr_destroy , .Fn pthread_attr_setstacksize , .Fn pthread_attr_getstacksize , .Fn pthread_attr_setstackaddr , .Fn pthread_attr_getstackaddr , .Fn pthread_attr_setdetachstate , and .Fn pthread_attr_getdetachstate functions conform to .St -p1003.1-96 .Pp The .Fn pthread_attr_setinheritsched , .Fn pthread_attr_getinheritsched , .Fn pthread_attr_setschedparam , .Fn pthread_attr_getschedparam , .Fn pthread_attr_setschedpolicy , .Fn pthread_attr_getschedpolicy , .Fn pthread_attr_setscope , and .Fn pthread_attr_getscope functions conform to .St -susv2 Index: head/share/man/man3/pthread_attr_affinity_np.3 =================================================================== --- head/share/man/man3/pthread_attr_affinity_np.3 (nonexistent) +++ head/share/man/man3/pthread_attr_affinity_np.3 (revision 201892) @@ -0,0 +1,150 @@ +.\"- +.\" Copyright (c) 2010 Xin LI +.\" 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$ +.\" +.Dd January 8, 2010 +.Dt PTHREAD_ATTR_AFFINITY_NP 3 +.Os +.Sh NAME +.Nm pthread_attr_getaffinity_np , +.Nm pthread_attr_setaffinity_np +.Nd manage CPU affinity in thread attribute object +.Sh LIBRARY +.Lb libpthread +.Sh SYNOPSIS +.In pthread_np.h +.Ft int +.Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp" +.Ft int +.Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp" +.Sh DESCRIPTION +.Fn pthread_attr_getaffinity_np +and +.Fn pthread_attr_setaffinity_np +allow the manipulation of sets of CPUs available to specified thread attribute object. +.Pp +Masks of type +.Ft cpuset_t +are composed using the +.Xr CPU_SET 2 +macros. +The kernel tolerates large sets as long as all CPUs specified +in the set exist. +Sets smaller than the kernel uses generate an error on calls to +.Fn pthread_attr_getaffinity_np +even if the result set would fit within the user supplied set. +Calls to +.Fn pthread_attr_setaffinity_np +tolerate small sets with no restrictions. +.Pp +The supplied mask should have a size of +.Fa cpusetsize +bytes. +This size is usually provided by calling +.Li sizeof(cpuset_t) +which is ultimately determined by the value of +.Dv CPU_SETSIZE +as defined in +.In sys/cpuset.h . +.Pp +.Fn pthread_attr_getaffinity_np +retrieves the +mask from the thread attribute object specified by +.Fa pattr , +and stores it in the space provided by +.Fa cpumaskp . +.Pp +.Fn pthread_attr_setaffinity_np +set the mask for the thread attribute object specified by +.Fa pattr +to the value in +.Fa cpumaskp . +.Pp +.Sh RETURN VALUES +If successful, the +.Fn pthread_attr_getaffinity_np +and +.Fn pthread_attr_setaffinity_np +functions will return zero. +Otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +The +.Fn pthread_attr_getaffinity_np +and +.Fn pthread_attr_setaffinity_np +functions will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa pattr +or the attribute specified by it is NULL. +.El +.Pp +The +.Fn pthread_attr_setaffinity_np +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa pattr +or the attribute specified by it is NULL. +.It Bq Er ENOMEM +Insufficient memory exists to store the cpuset mask. +.El +.Sh SEE ALSO +.Xr cpuset 1 , +.Xr cpuset 2 , +.Xr cpuset_getid 2 , +.Xr cpuset_setid 2 , +.Xr CPU_SET 3 , +.Xr pthread_get_affinity_np 3 , +.Xr pthread_set_affinity_np 3 . +.Sh STANDARDS +The +.Nm pthread_attr_getaffinity_np +and +.Nm pthread_attr_setaffinity_np +functions are non-standard +.Fx +extensions and may be not available on other operating systems. +.Sh HISTORY +The +.Nm pthread_attr_getaffinity_np +and +.Nm pthread_attr_setaffinity_np +functions first appeared in +.Fx 7.2 . +.Sh AUTHORS +.An -nosplit +The +.Nm pthread_attr_getaffinity_np +and +.Nm pthread_attr_setaffinity_np +functions were written by +.An David Xu Aq davidxu@FreeBSD.org , +and this manpage was written by +.An Xin LI Aq delphij@FreeBSD.org . Property changes on: head/share/man/man3/pthread_attr_affinity_np.3 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property