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