Changeset eafb094 for src/libcfa
- Timestamp:
- Feb 13, 2017, 5:20:06 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:
- 294647b, d3a804f5
- Parents:
- ee897e4b
- Location:
- src/libcfa/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel
ree897e4b reafb094 28 28 //----------------------------------------------------------------------------- 29 29 // Locks 30 // void lock( simple_lock * );31 // void lock( simple_lock *, spinlock * );32 // void unlock( simple_lock * );33 34 30 void lock( spinlock * ); 35 31 void unlock( spinlock * ); -
src/libcfa/concurrency/kernel.c
ree897e4b reafb094 36 36 #include "invoke.h" 37 37 38 static volatile int lock;39 40 void spin_lock( volatile int *lock ) {41 for ( unsigned int i = 1;; i += 1 ) {42 if ( *lock == 0 && __sync_lock_test_and_set_4( lock, 1 ) == 0 ) break;43 }44 }45 46 void spin_unlock( volatile int *lock ) {47 __sync_lock_release_4( lock );48 }49 50 38 //----------------------------------------------------------------------------- 51 39 // Kernel storage … … 176 164 void ?{}(cluster * this) { 177 165 ( &this->ready_queue ){}; 178 lock = 0;166 ( &this->lock ){}; 179 167 } 180 168 … … 413 401 //----------------------------------------------------------------------------- 414 402 // Locks 415 // void ?{}( simple_lock * this ) {416 // ( &this->blocked ){};417 // }418 419 // void ^?{}( simple_lock * this ) {420 421 // }422 423 // void lock( simple_lock * this ) {424 // {425 // spin_lock( &lock );426 // append( &this->blocked, this_thread() );427 // spin_unlock( &lock );428 // }429 // ScheduleInternal();430 // }431 432 // void lock( simple_lock * this, spinlock * to_release ) {433 // {434 // spin_lock( &lock );435 // append( &this->blocked, this_thread() );436 // spin_unlock( &lock );437 // }438 // ScheduleInternal( to_release );439 // lock( to_release );440 // }441 442 // void unlock( simple_lock * this ) {443 // thread * it;444 // while( it = pop_head( &this->blocked) ) {445 // ScheduleThread( it );446 // }447 // }448 449 403 void ?{}( spinlock * this ) { 450 404 this->lock = 0;
Note: See TracChangeset
for help on using the changeset viewer.