Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
7.2 kB · 231 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232.\" Copyright (C) 2010 mark@heily.com.\" Copyright (C) 2009 sson@FreeBSD.org.\" 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 December 12, 2009.Dt PTHREAD_WORKQUEUE 3.Os.Sh NAME.Nm pthread_workqueue_init_np ,.Nm pthread_workqueue_create_np ,.Nm pthread_workqueue_additem_np .Nd thread workqueue operations.Pp.Nm pthread_workqueue_attr_init_np ,.Nm pthread_workqueue_attr_destroy_np ,.Nm pthread_workqueue_attr_getovercommit_np ,.Nm pthread_workqueue_attr_setovercommit_np ,.Nm pthread_workqueue_attr_getqueuepriority_np ,.Nm pthread_workqueue_attr_setqueuepriority_np .Nd thread workqueue attribute operations.Sh SYNOPSIS.In pthread_workqueue.h.Ft int.Fn pthread_workqueue_init_np "void".Ft int.Fn pthread_workqueue_create_np "pthread_workqueue_t *workqp" "const pthread_workqueue_attr_t * attr".Ft int.Fn pthread_workqueue_additem_np "pthread_workqueue_t workq" "void ( *workitem_func)(void *)" "void * workitem_arg" "pthread_workitem_handle_t * itemhandlep" "unsigned int *gencountp".Ft int.Fn pthread_workqueue_attr_init_np "pthread_workqueue_attr_t *attr".Ft int.Fn pthread_workqueue_attr_destroy_np "pthread_workqueue_attr_t *attr".Ft int.Fn pthread_workqueue_attr_getovercommit_np "pthread_workqueue_attr_t *attr" "int *ocommp".Ft int.Fn pthread_workqueue_attr_setovercommit_np "pthread_workqueue_attr_t *attr" "int ocomm".Ft int.Fn pthread_workqueue_attr_getqueuepriority_np "pthread_workqueue_attr_t *attr" "int *qpriop".Ft int.Fn pthread_workqueue_attr_setqueuepriority_np "pthread_workqueue_attr_t *attr" "int qprio".Sh DESCRIPTIONThe .Fn pthread_workqueue_*_npfunctions are used to create and submit work items to a thread pool..PpThe user may create multiple work queues of different priority andmanually overcommit the available resources..Pp.Fn pthread_workqueue_init_np allocates and initializes the thread workqueue subsystem..Pp.Fn pthread_workqueue_create_npcreates a new thread workqueue with the attributes given by.Fa attr .If .Fa attris NULL then the default attributes are used.A workqueue handle is returned in the.Fa workqp parameter..PpThread workqueue attributes are used to specify parameters to.Fn pthread_workqueue_create_np .One attribute object can be used in multiple calls to.Fn pthread_workqueue_create_np ,with or without modifications between calls..Pp.Fn pthread_workqueue_additem_npis used to submit work items to the thread pool specified by.Fa workqparameter.The work item function and function argument are given by.Fa workitem_funcand.Fa workitem_arg . The work item handle is returned in .Fa itemhandlep ..PpThe.Fn pthread_workqueue_attr_init_npfunction initializes.Fa attrwith all the default thread workqueue attributes..PpThe.Fn pthread_workqueue_attr_destroy_npfunction destroys.Fa attr ..PpThe.Fn pthread_workqueue_attr_set*_npfunctions set the attribute that corresponds to each function name..Fn pthread_workqueue_attr_setovercommit_npcan be used to set the overcommit flag.If the overcommit flag is set then more threads will be started, ifneeded, which may overcommit the physical resources of the system..Fn pthread_workqueue_attr_setqueuepriority_npsets the queue priority attribute of the thread work queue and must beset to one of the following values:.Bl -tag -width "Va WORKQ_DEFAULT_PRIOQUEUE".It Va WORKQ_HIGH_PRIOQUEUEWork items in the queue with this attribute will be given higher priority bythe thread scheduler..It Va WORKQ_DEFAULT_PRIOQUEUE Work items in the queue with this attribute are given the defaultpriority..It Va WORKQ_LOW_PRIOQUEUEWork items in the queue with this attribute will be given lower priorityby the thread scheduler. .El.PpThe.Fn pthread_workqueue_attr_get*_npfunctions copy the value of the attribute that corresponds to each function nameto the location pointed to by the second function parameter..Sh RETURN VALUESIf successful, these functions return 0.Otherwise, an error number is returned to indicate the error..Sh ERRORSThe.Fn pthread_workqueue_init_npfunction will fail if:.Bl -tag -width Er.It Bq Er ENOMEMOut of memory..El.PpThe.Fn pthread_workqueue_create_npfunction will fail if:.Bl -tag -width Er.It Bq Er ENOMEMOut of memory..El.PpThe.Fn pthread_workqueue_additem_npfunction will fail if:.Bl -tag -width Er.It Bq Er EINVALInvalid workqueue handle..It Bq Er ENOMEMOut of memory..It Bq Er ESRCHCan not find workqueue..El.PpThe.Fn pthread_workqueue_attr_init_npfunction will fail if:.Bl -tag -width Er.It Bq Er ENOMEMOut of memory..El.PpThe.Fn pthread_workqueue_attr_destroy_npfunction will fail if:.Bl -tag -width Er.It Bq Er EINVALInvalid value for.Fa attr ..El.PpThe.Fn pthread_workqueue_attr_setqueuepriority_npfunction will fail if:.Bl -tag -width Er.It Bq Er EINVALInvalid value for.Fa attror for .Fa qprio..El.PpThe.Fn pthread_workqueue_attr_setovercommit_np ,.Fn pthread_workqueue_attr_getovercommit_npand.Fn pthread_workqueue_attr_getqueuepriority_npfunctions will fail if:.Bl -tag -width Er.It Bq Er EINVALInvalid value for.Fa attr ..El.Sh SEE ALSO.Xr pthread 3 ,.Xr sysctl 3.Sh BUGSThere is no way, currently, to remove or destory work queues and pendingwork items other than exiting the process..PpAll worker threads run at the same thread priority; however, items placed on high-priority workqueues will be executed before those on lower-priority workqueues..Sh HISTORYThis thread workqueues code was created to support Grand Central Dispatch (GCDor libdispatch) and first appeared in .Fx 8.0 ..Sh AUTHORS.An "Mark Heily" Aq mark@heily.com ..Br.PpBased on earlier work by.An "Stacey Son" Aq sson@FreeBSD.organd.An Apple, Inc.