1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _CTFMERGE_H
27 #define _CTFMERGE_H
28
29 #pragma ident "%Z%%M% %I% %E% SMI"
30
31 /*
32 * Merging structures used in ctfmerge. See ctfmerge.c for locking semantics.
33 */
34
35 #include <pthread.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 #include "ctftools.h"
42 #include "barrier.h"
43 #include "fifo.h"
44
45 typedef struct wip {
46 pthread_mutex_t wip_lock;
47 pthread_cond_t wip_cv;
48 tdata_t *wip_td;
49 int wip_nmerged;
50 int wip_batchid;
51 } wip_t;
52
53 typedef struct workqueue {
54 int wq_next_batchid;
55
56 int wq_maxbatchsz;
57
58 wip_t *wq_wip;
59 int wq_nwipslots;
60 int wq_nthreads;
61 int wq_ithrottle;
62
63 pthread_mutex_t wq_queue_lock;
64 fifo_t *wq_queue;
65 pthread_cond_t wq_work_avail;
66 pthread_cond_t wq_work_removed;
67 int wq_ninqueue;
68 int wq_nextpownum;
69
70 pthread_mutex_t wq_donequeue_lock;
71 fifo_t *wq_donequeue;
72 int wq_lastdonebatch;
73 pthread_cond_t wq_done_cv;
74
75 pthread_cond_t wq_alldone_cv; /* protected by queue_lock */
76 int wq_alldone;
77
78 int wq_nomorefiles;
79
80 pthread_t *wq_thread;
81
82 barrier_t wq_bar1;
83 barrier_t wq_bar2;
84 } workqueue_t;
85
86 #ifdef __cplusplus
87 }
88 #endif
89
90 #endif /* _CTFMERGE_H */