ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 348006f was
348006f,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
Renamed thread to thread_desc
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | // -*- Mode: CFA -*- |
---|
2 | // |
---|
3 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
4 | // |
---|
5 | // The contents of this file are covered under the licence agreement in the |
---|
6 | // file "LICENCE" distributed with Cforall. |
---|
7 | // |
---|
8 | // monitor -- |
---|
9 | // |
---|
10 | // Author : Thierry Delisle |
---|
11 | // Created On : Thd Feb 23 12:27:26 2017 |
---|
12 | // Last Modified By : Thierry Delisle |
---|
13 | // Last Modified On : -- |
---|
14 | // Update Count : 0 |
---|
15 | // |
---|
16 | |
---|
17 | #ifndef MONITOR_H |
---|
18 | #define MONITOR_H |
---|
19 | |
---|
20 | #include "assert" |
---|
21 | #include "invoke.h" |
---|
22 | #include "stdlib" |
---|
23 | |
---|
24 | struct monitor_desc { |
---|
25 | spinlock lock; |
---|
26 | thread_desc * owner; |
---|
27 | simple_thread_list entry_queue; |
---|
28 | unsigned int recursion; |
---|
29 | }; |
---|
30 | |
---|
31 | static inline void ?{}(monitor_desc * this) { |
---|
32 | this->owner = 0; |
---|
33 | this->recursion = 0; |
---|
34 | } |
---|
35 | |
---|
36 | //Basic entering routine |
---|
37 | void enter(monitor_desc *); |
---|
38 | void leave(monitor_desc *); |
---|
39 | |
---|
40 | //Array entering routine |
---|
41 | void enter(monitor_desc **, int count); |
---|
42 | void leave(monitor_desc **, int count); |
---|
43 | |
---|
44 | struct monitor_guard_t { |
---|
45 | monitor_desc ** m; |
---|
46 | int count; |
---|
47 | }; |
---|
48 | |
---|
49 | static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) { |
---|
50 | return ((intptr_t)lhs) < ((intptr_t)rhs); |
---|
51 | } |
---|
52 | |
---|
53 | static inline void ?{}( monitor_guard_t * this, monitor_desc ** m ) { |
---|
54 | this->m = m; |
---|
55 | this->count = 1; |
---|
56 | enter( *this->m ); |
---|
57 | } |
---|
58 | |
---|
59 | static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) { |
---|
60 | this->m = m; |
---|
61 | this->count = count; |
---|
62 | qsort(this->m, count); |
---|
63 | enter( this->m, this->count ); |
---|
64 | } |
---|
65 | |
---|
66 | static inline void ^?{}( monitor_guard_t * this ) { |
---|
67 | leave( this->m, this->count ); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | #endif //MONITOR_H |
---|
Note: See
TracBrowser
for help on using the repository browser.