LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build freebsd linux | 5 // +build freebsd linux |
6 | 6 |
7 #include "runtime.h" | 7 #include "runtime.h" |
8 | 8 |
9 // This implementation depends on OS-specific implementations of | 9 // This implementation depends on OS-specific implementations of |
10 // | 10 // |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // One-time notifications. | 104 // One-time notifications. |
105 void | 105 void |
106 runtime·noteclear(Note *n) | 106 runtime·noteclear(Note *n) |
107 { | 107 { |
108 n->key = 0; | 108 n->key = 0; |
109 } | 109 } |
110 | 110 |
111 void | 111 void |
112 runtime·notewakeup(Note *n) | 112 runtime·notewakeup(Note *n) |
113 { | 113 { |
114 » runtime·xchg(&n->key, 1); | 114 » if(runtime·xchg(&n->key, 1)) |
| 115 » » runtime·throw("notewakeup - double wakeup"); |
115 runtime·futexwakeup(&n->key, 1); | 116 runtime·futexwakeup(&n->key, 1); |
116 } | 117 } |
117 | 118 |
118 void | 119 void |
119 runtime·notesleep(Note *n) | 120 runtime·notesleep(Note *n) |
120 { | 121 { |
121 if(m->profilehz > 0) | 122 if(m->profilehz > 0) |
122 runtime·setprof(false); | 123 runtime·setprof(false); |
123 while(runtime·atomicload(&n->key) == 0) | 124 while(runtime·atomicload(&n->key) == 0) |
124 runtime·futexsleep(&n->key, 0, -1); | 125 runtime·futexsleep(&n->key, 0, -1); |
(...skipping 22 matching lines...) Expand all Loading... |
147 if(runtime·atomicload(&n->key) != 0) | 148 if(runtime·atomicload(&n->key) != 0) |
148 break; | 149 break; |
149 now = runtime·nanotime(); | 150 now = runtime·nanotime(); |
150 if(now >= deadline) | 151 if(now >= deadline) |
151 break; | 152 break; |
152 ns = deadline - now; | 153 ns = deadline - now; |
153 } | 154 } |
154 if(m->profilehz > 0) | 155 if(m->profilehz > 0) |
155 runtime·setprof(true); | 156 runtime·setprof(true); |
156 } | 157 } |
LEFT | RIGHT |