source: trunk/kernel/kern/mcs_sync.h @ 15

Last change on this file since 15 was 1, checked in by alain, 8 years ago

First import

File size: 2.0 KB
Line 
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
32struct mcs_barrier_s;
33struct mcs_lock_s;
34
35typedef struct mcs_barrier_s mcs_barrier_t;
36typedef struct mcs_lock_s mcs_lock_t;
37
38void mcs_barrier_init(mcs_barrier_t *ptr, char *name, uint_t count);
39void mcs_barrier_wait(mcs_barrier_t *ptr);
40
41void mcs_lock_init(mcs_lock_t *ptr, char *name);
42
43void mcs_lock(mcs_lock_t *ptr, uint_t *irq_state);
44void mcs_unlock(mcs_lock_t *ptr, uint_t irq_state);
45
46void mcs_lock_remote(mcs_lock_t *ptr, cid_t cid, uint_t *irq_state);
47void mcs_unlock_remote(mcs_lock_t *ptr, cid_t cid, uint_t irq_state);
48
49//////////////////////////////////////////////
50//             Private Section              //
51//////////////////////////////////////////////
52
53struct 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
64struct 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_ */
Note: See TracBrowser for help on using the repository browser.