- Timestamp:
- Mar 15, 2017, 4:14:31 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 348006f
- Parents:
- c3acb841
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/monitor
rc3acb841 r84c52a8 22 22 #include "stdlib" 23 23 24 struct __monitor_t{24 struct monitor_desc { 25 25 spinlock lock; 26 26 thread * owner; … … 29 29 }; 30 30 31 static inline void ?{}( __monitor_t* this) {31 static inline void ?{}(monitor_desc * this) { 32 32 this->owner = 0; 33 33 this->recursion = 0; … … 35 35 36 36 //Basic entering routine 37 void enter( __monitor_t*);38 void leave( __monitor_t*);37 void enter(monitor_desc *); 38 void leave(monitor_desc *); 39 39 40 40 //Array entering routine 41 void enter( __monitor_t**, int count);42 void leave( __monitor_t**, int count);41 void enter(monitor_desc **, int count); 42 void leave(monitor_desc **, int count); 43 43 44 44 struct monitor_guard_t { 45 __monitor_t** m;45 monitor_desc ** m; 46 46 int count; 47 47 }; 48 48 49 static inline int ?<?( __monitor_t* lhs, __monitor_t* rhs) {49 static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) { 50 50 return ((intptr_t)lhs) < ((intptr_t)rhs); 51 51 } 52 52 53 static inline void ?{}( monitor_guard_t * this, __monitor_t** m ) {53 static inline void ?{}( monitor_guard_t * this, monitor_desc ** m ) { 54 54 this->m = m; 55 55 this->count = 1; … … 57 57 } 58 58 59 static inline void ?{}( monitor_guard_t * this, __monitor_t** m, int count ) {59 static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) { 60 60 this->m = m; 61 61 this->count = count; -
src/libcfa/concurrency/monitor.c
rc3acb841 r84c52a8 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // __monitor_t.c --8 // monitor_desc.c -- 9 9 // 10 10 // Author : Thierry Delisle … … 19 19 #include "kernel_private.h" 20 20 21 void enter( __monitor_t* this) {21 void enter(monitor_desc * this) { 22 22 lock( &this->lock ); 23 23 thread * thrd = this_thread(); … … 45 45 } 46 46 47 void leave( __monitor_t* this) {47 void leave(monitor_desc * this) { 48 48 lock( &this->lock ); 49 49 … … 72 72 } 73 73 74 void enter( __monitor_t** monitors, int count) {74 void enter(monitor_desc ** monitors, int count) { 75 75 for(int i = 0; i < count; i++) { 76 76 // printf("%d\n", i); … … 79 79 } 80 80 81 void leave( __monitor_t** monitors, int count) {81 void leave(monitor_desc ** monitors, int count) { 82 82 for(int i = count - 1; i >= 0; i--) { 83 83 // printf("%d\n", i); -
src/tests/monitor.c
rc3acb841 r84c52a8 6 6 struct global_t { 7 7 int value; 8 __monitor_tm;8 monitor_desc m; 9 9 }; 10 10 … … 16 16 17 17 void increment( /*mutex*/ global_t * this ) { 18 __monitor_t* mon = &this->m;18 monitor_desc * mon = &this->m; 19 19 monitor_guard_t g1 = { &mon }; 20 20 { -
src/tests/multi-monitor.c
rc3acb841 r84c52a8 6 6 static int global12, global23, global13; 7 7 8 static __monitor_tm1, m2, m3;8 static monitor_desc m1, m2, m3; 9 9 10 void increment( /*mutex*/ __monitor_t * p1, /*mutex*/ __monitor_t* p2, int * value ) {11 __monitor_t* mons[] = { p1, p2 };10 void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) { 11 monitor_desc * mons[] = { p1, p2 }; 12 12 monitor_guard_t g = { mons, 2 }; 13 13 *value += 1;
Note: See TracChangeset
for help on using the changeset viewer.