Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / legion / src / generic / include / barrier.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: barrier.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23/*
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28#ifndef _BARRIER_H
29#define _BARRIER_H
30
31#pragma ident "@(#)barrier.h 1.2 06/08/08 SMI"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include <thread.h>
38#include "basics.h"
39
40typedef struct {
41 int maxcnt; /* maximum number of runners */
42 struct _sb {
43 cond_t wait_cv; /* cv for waiters at barrier */
44 mutex_t wait_lk; /* mutex for waiters at barrier */
45 int runners; /* number of running threads */
46 } sb[2];
47 struct _sb *sbp; /* current sub-barrier */
48} barrier_t;
49
50extern int barrier_init(barrier_t *bp, int count);
51extern void barrier_wait(barrier_t *bp);
52
53typedef struct {
54 int maxcnt; /* maximum number of runners */
55 struct _sbb {
56 volatile int spin_cv; /* "cv" for waiters at barrier */
57 volatile int runners; /* number of running threads */
58 } sbb[2];
59 struct _sbb *sbbp; /* current sub-busy-barrier */
60} barrier_busy_t;
61
62extern int barrier_busy_init(barrier_busy_t *bbp, int count);
63extern void barrier_busy_wait(barrier_busy_t *bbp);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif /* _BARRIER_H */