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 24cde55 was
ead8c7e,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
Remove extraenous asserts
|
-
Property mode set to
100644
|
File size:
988 bytes
|
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.c -- |
---|
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 | #include "monitor" |
---|
18 | |
---|
19 | #include "kernel_private.h" |
---|
20 | |
---|
21 | void enter(monitor * this) { |
---|
22 | lock( &this->lock ); |
---|
23 | thread * thrd = this_thread(); |
---|
24 | |
---|
25 | if( this->holder ) { |
---|
26 | append( &this->entry_queue, thrd ); |
---|
27 | ScheduleInternal( &this->lock ); |
---|
28 | return; |
---|
29 | } |
---|
30 | else { |
---|
31 | this->holder = thrd; |
---|
32 | } |
---|
33 | |
---|
34 | unlock( &this->lock ); |
---|
35 | } |
---|
36 | |
---|
37 | void leave(monitor * this) { |
---|
38 | lock( &this->lock ); |
---|
39 | |
---|
40 | thread * thrd = this_thread(); |
---|
41 | assert( thrd == this->holder ); |
---|
42 | |
---|
43 | this->holder = pop_head( &this->entry_queue ); |
---|
44 | |
---|
45 | unlock( &this->lock ); |
---|
46 | if( this->holder ) ScheduleThread( this->holder ); |
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.