1 | /* |
---|
2 | * kern/mcs_sync.h - ticket-based barriers and locks synchronization |
---|
3 | * |
---|
4 | * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless |
---|
5 | * Copyright (c) 2011,2012 UPMC Sorbonne Universites |
---|
6 | * |
---|
7 | * This file is part of ALMOS-kernel. |
---|
8 | * |
---|
9 | * ALMOS-kernel is free software; you can redistribute it and/or modify it |
---|
10 | * under the terms of the GNU General Public License as published by |
---|
11 | * the Free Software Foundation; version 2.0 of the License. |
---|
12 | * |
---|
13 | * ALMOS-kernel is distributed in the hope that it will be useful, but |
---|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | * General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with ALMOS-kernel; if not, write to the Free Software Foundation, |
---|
20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _MCS_SYNC_H_ |
---|
24 | #define _MCS_SYNC_H_ |
---|
25 | |
---|
26 | #include <types.h> |
---|
27 | |
---|
28 | /////////////////////////////////////////////// |
---|
29 | // Public Section // |
---|
30 | /////////////////////////////////////////////// |
---|
31 | |
---|
32 | struct mcs_barrier_s; |
---|
33 | struct mcs_lock_s; |
---|
34 | |
---|
35 | typedef struct mcs_barrier_s mcs_barrier_t; |
---|
36 | typedef struct mcs_lock_s mcs_lock_t; |
---|
37 | |
---|
38 | void mcs_barrier_init(mcs_barrier_t *ptr, char *name, uint_t count); |
---|
39 | void mcs_barrier_wait(mcs_barrier_t *ptr); |
---|
40 | |
---|
41 | void mcs_lock_init(mcs_lock_t *ptr, char *name); |
---|
42 | |
---|
43 | void mcs_lock(mcs_lock_t *ptr, uint_t *irq_state); |
---|
44 | void mcs_unlock(mcs_lock_t *ptr, uint_t irq_state); |
---|
45 | |
---|
46 | void mcs_lock_remote(mcs_lock_t *ptr, cid_t cid, uint_t *irq_state); |
---|
47 | void mcs_unlock_remote(mcs_lock_t *ptr, cid_t cid, uint_t irq_state); |
---|
48 | |
---|
49 | ////////////////////////////////////////////// |
---|
50 | // Private Section // |
---|
51 | ////////////////////////////////////////////// |
---|
52 | |
---|
53 | struct mcs_barrier_s |
---|
54 | { |
---|
55 | cacheline_t val; |
---|
56 | cacheline_t phase; |
---|
57 | cacheline_t cntr; |
---|
58 | cacheline_t ticket; |
---|
59 | cacheline_t ticket2; |
---|
60 | char *name CACHELINE; |
---|
61 | } mcs_barrier_t; |
---|
62 | |
---|
63 | |
---|
64 | struct mcs_lock_s |
---|
65 | { |
---|
66 | cacheline_t cntr; |
---|
67 | cacheline_t ticket; |
---|
68 | char *name CACHELINE; |
---|
69 | } mgs_lock_t; |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | #endif /* _MCS_SYNC_H_ */ |
---|