Changes in / [5d369c7:7b1f6d4]
- Files:
-
- 8 added
- 5 deleted
- 5 edited
-
libcfa/src/concurrency/locks.cfa (modified) (8 diffs)
-
libcfa/src/concurrency/locks.hfa (modified) (4 diffs)
-
tests/.expect/locks.txt (added)
-
tests/.expect/queue.txt (modified) (1 diff)
-
tests/.expect/sequence.txt (modified) (1 diff)
-
tests/.expect/stack.txt (modified) (1 diff)
-
tests/.expect/timeout_lock.txt (added)
-
tests/collections/multi_list.cfa (added)
-
tests/collections/queue.cfa (added)
-
tests/collections/sequence.cfa (added)
-
tests/collections/stack.cfa (added)
-
tests/locks.cfa (deleted)
-
tests/multi_list.cfa (deleted)
-
tests/queue.cfa (deleted)
-
tests/sequence.cfa (deleted)
-
tests/stack.cfa (deleted)
-
tests/unified_locking/locks.cfa (added)
-
tests/unified_locking/timeout_lock.cfa (added)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.cfa
r5d369c7 r7b1f6d4 17 17 this.t = t; 18 18 this.lock = 0p; 19 this.listed = false;20 19 } 21 20 … … 25 24 this.info = info; 26 25 this.lock = 0p; 27 this.listed = false;28 26 } 29 27 … … 36 34 info_thread(L) *& Next( info_thread(L) * this ) { 37 35 return (info_thread(L) *)Next( (Colable *)this ); 38 }39 40 bool listed( info_thread(L) * this ) {41 return Next( (Colable *)this ) != 0p;42 36 } 43 37 } … … 194 188 // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin. 195 189 lock( cond->lock __cfaabi_dbg_ctx2 ); 196 197 if ( i->listed ) { // is thread on queue190 if ( listed(i) ) { // is thread on queue 191 i->signalled = false; 198 192 cond->last_thread = i; // REMOVE THIS AFTER DEBUG 199 193 remove( cond->blocked_threads, *i ); //remove this thread O(1) … … 227 221 void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) { 228 222 if(&popped != 0p) { 229 popped. listed = false;223 popped.signalled = true; 230 224 count--; 231 225 if (popped.lock) { … … 266 260 addTail( blocked_threads, *i ); 267 261 count++; 268 i->listed = true;269 262 size_t recursion_count = 0; 270 263 if (i->lock) { … … 308 301 } 309 302 310 voidwait( condition_variable(L) & this, Duration duration ) with(this) {303 bool wait( condition_variable(L) & this, Duration duration ) with(this) { 311 304 info_thread( L ) i = { active_thread() }; 312 305 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 313 } 314 315 void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { 306 return i.signalled; 307 } 308 309 bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { 316 310 info_thread( L ) i = { active_thread(), info }; 317 311 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 318 } 319 320 void wait( condition_variable(L) & this, Time time ) with(this) { 312 return i.signalled; 313 } 314 315 bool wait( condition_variable(L) & this, Time time ) with(this) { 321 316 info_thread( L ) i = { active_thread() }; 322 317 queue_info_thread_timeout(this, i, time); 323 } 324 325 void wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) { 318 return i.signalled; 319 } 320 321 bool wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) { 326 322 info_thread( L ) i = { active_thread(), info }; 327 323 queue_info_thread_timeout(this, i, time); 324 return i.signalled; 328 325 } 329 326 … … 340 337 } 341 338 342 voidwait( condition_variable(L) & this, L & l, Duration duration ) with(this) {339 bool wait( condition_variable(L) & this, L & l, Duration duration ) with(this) { 343 340 info_thread(L) i = { active_thread() }; 344 341 i.lock = &l; 345 342 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 346 } 347 348 void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { 343 return i.signalled; 344 } 345 346 bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { 349 347 info_thread(L) i = { active_thread(), info }; 350 348 i.lock = &l; 351 349 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 352 } 353 354 void wait( condition_variable(L) & this, L & l, Time time ) with(this) { 350 return i.signalled; 351 } 352 353 bool wait( condition_variable(L) & this, L & l, Time time ) with(this) { 355 354 info_thread(L) i = { active_thread() }; 356 355 i.lock = &l; 357 356 queue_info_thread_timeout(this, i, time ); 358 } 359 360 void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) { 357 return i.signalled; 358 } 359 360 bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) { 361 361 info_thread(L) i = { active_thread(), info }; 362 362 i.lock = &l; 363 363 queue_info_thread_timeout(this, i, time ); 364 } 365 } 364 return i.signalled; 365 } 366 } -
libcfa/src/concurrency/locks.hfa
r5d369c7 r7b1f6d4 36 36 uintptr_t info; 37 37 L * lock; 38 bool listed; // true if info_thread is on queue, false otherwise;38 bool signalled; // true when signalled and false when timeout wakes thread 39 39 }; 40 40 … … 46 46 info_thread(L) *& Back( info_thread(L) * this ); 47 47 info_thread(L) *& Next( info_thread(L) * this ); 48 bool listed( info_thread(L) * this );49 48 } 50 49 … … 52 51 //// Blocking Locks 53 52 /////////////////////////////////////////////////////////////////// 54 55 // struct lock_thread {56 // struct $thread * t;57 // lock_thread * next;58 // };59 60 // void ?{}( lock_thread & this, struct $thread * thd );61 // void ^?{}( lock_thread & this );62 63 // lock_thread *& get_next( lock_thread & );64 53 65 54 struct blocking_lock { … … 183 172 int counter( condition_variable(L) & this ); 184 173 185 // TODO: look into changing timout routines to return bool showing if signalled or woken by kernel186 174 void wait( condition_variable(L) & this ); 187 175 void wait( condition_variable(L) & this, uintptr_t info ); 188 voidwait( condition_variable(L) & this, Duration duration );189 voidwait( condition_variable(L) & this, uintptr_t info, Duration duration );190 voidwait( condition_variable(L) & this, Time time );191 voidwait( condition_variable(L) & this, uintptr_t info, Time time );176 bool wait( condition_variable(L) & this, Duration duration ); 177 bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ); 178 bool wait( condition_variable(L) & this, Time time ); 179 bool wait( condition_variable(L) & this, uintptr_t info, Time time ); 192 180 193 181 void wait( condition_variable(L) & this, L & l ); 194 182 void wait( condition_variable(L) & this, L & l, uintptr_t info ); 195 voidwait( condition_variable(L) & this, L & l, Duration duration );196 voidwait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration );197 voidwait( condition_variable(L) & this, L & l, Time time );198 voidwait( condition_variable(L) & this, L & l, uintptr_t info, Time time );183 bool wait( condition_variable(L) & this, L & l, Duration duration ); 184 bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ); 185 bool wait( condition_variable(L) & this, L & l, Time time ); 186 bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ); 199 187 } -
tests/.expect/queue.txt
r5d369c7 r7b1f6d4 1 1 empty 2 0 3 18 2 4 0 2 4 6 8 10 12 14 16 18 3 5 18 4 18 1 3 5 7 9 11 13 15 17 19 6 18 7 18 1 3 5 7 9 11 13 15 17 8 0 1 2 3 4 5 6 7 8 9 9 6 7 8 9 10 0 1 2 3 4 5 11 6 7 8 9 0 1 2 3 4 5 5 12 empty 6 13 0 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 16 16 18 18 -
tests/.expect/sequence.txt
r5d369c7 r7b1f6d4 4 4 18 1 3 5 7 9 11 13 15 17 19 5 5 18 1 6 0 1 2 3 4 5 6 7 8 9 7 9 8 9 8 7 6 5 4 3 1 -2 0 9 4 3 1 -2 0 10 9 8 7 6 5 11 4 3 1 -2 0 9 8 7 6 5 6 12 empty 7 13 0 0 2 2 4 4 6 6 8 8 10 10 12 12 14 14 16 16 18 18 -
tests/.expect/stack.txt
r5d369c7 r7b1f6d4 1 1 empty 2 2 18 16 14 12 10 8 6 4 2 0 3 18 3 4 0 4 5 19 17 15 13 11 9 7 5 3 1 0
Note:
See TracChangeset
for help on using the changeset viewer.