1 /*- 2 * Copyright (c) 2009-2014, Stacey Son <sson@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD: $ 27 */ 28 29 #include <sys/param.h> 30 31 struct _pthread_workqueue; 32 33 typedef struct _pthread_workqueue * pthread_workqueue_t; 34 typedef void * pthread_workitem_handle_t; 35 36 /* Pad size to 64 bytes. */ 37 typedef struct { 38 uint32_t sig; 39 int queueprio; 40 int overcommit; 41 unsigned int pad[13]; 42 } pthread_workqueue_attr_t; 43 44 /* Work queue priority attributes. */ 45 #define WORKQ_HIGH_PRIOQUEUE 0 /* Assign to high priority queue. */ 46 #define WORKQ_DEFAULT_PRIOQUEUE 1 /* Assign to default priority queue. */ 47 #define WORKQ_LOW_PRIOQUEUE 2 /* Assign to low priority queue. */ 48 #define WORKQ_BG_PRIOQUEUE 3 /* background priority queue */ 49 50 #define WORKQ_NUM_PRIOQUEUE 4 51 52 extern __int32_t workq_targetconc[WORKQ_NUM_PRIOQUEUE]; 53 54 int pthread_workqueue_init_np(void); 55 int pthread_workqueue_create_np(pthread_workqueue_t * workqp, 56 const pthread_workqueue_attr_t * attr); 57 int pthread_workqueue_additem_np(pthread_workqueue_t workq, 58 void *( *workitem_func)(void *), void * workitem_arg, 59 pthread_workitem_handle_t * itemhandlep, unsigned int *gencountp); 60 int pthread_workqueue_attr_init_np(pthread_workqueue_attr_t * attrp); 61 int pthread_workqueue_attr_destroy_np(pthread_workqueue_attr_t * attr); 62 int pthread_workqueue_attr_setqueuepriority_np(pthread_workqueue_attr_t * attr, 63 int qprio); 64 int pthread_workqueue_attr_getovercommit_np( 65 const pthread_workqueue_attr_t * attr, int * ocommp); 66 int pthread_workqueue_attr_setovercommit_np(pthread_workqueue_attr_t * attr, 67 int ocomm); 68 int pthread_workqueue_requestconcurrency_np(pthread_workqueue_t workq, 69 int queue, int request_concurrency); 70 int pthread_workqueue_getovercommit_np(pthread_workqueue_t workq, 71 unsigned int *ocommp); 72 void pthread_workqueue_atfork_child(void); 73 void pthread_workqueue_atfork_parent(void); 74 void pthread_workqueue_atfork_prepare(void); 75 __END_DECLS 76