Changeset daacf82 for src/libcfa
- Timestamp:
- Sep 26, 2017, 4:06:22 PM (7 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:
- a7d151f
- Parents:
- 19c43b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/monitor.c
r19c43b7 rdaacf82 23 23 //----------------------------------------------------------------------------- 24 24 // Forward declarations 25 static inline void set_owner( monitor_desc * this, thread_desc * owner ); 26 static inline void set_owner( monitor_desc ** storage, short count, thread_desc * owner ); 27 static inline void set_mask ( monitor_desc ** storage, short count, const __waitfor_mask_t & mask ); 25 static inline void set_owner ( monitor_desc * this, thread_desc * owner ); 26 static inline void set_owner ( monitor_desc ** storage, short count, thread_desc * owner ); 27 static inline void set_mask ( monitor_desc ** storage, short count, const __waitfor_mask_t & mask ); 28 static inline void reset_mask( monitor_desc * this ); 28 29 29 30 static inline thread_desc * next_thread( monitor_desc * this ); … … 102 103 // Some one was waiting for us, enter 103 104 set_owner( this, thrd ); 105 106 // Reset mask 107 reset_mask( this ); 104 108 105 109 LIB_DEBUG_PRINT_SAFE("Kernel : mon accepts \n"); … … 420 424 // block 421 425 void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) { 422 LIB_DEBUG_PRINT_SAFE("Kernel : waitfor internal \n");423 424 426 // This statment doesn't have a contiguous list of monitors... 425 427 // Create one! … … 428 430 short actual_count = aggregate( mon_storage, mask ); 429 431 430 if(actual_count == 0) { 431 LIB_DEBUG_PRINT_SAFE("Kernel : nothing to wait for \n"); 432 return; 433 } 432 if(actual_count == 0) return; 434 433 435 434 LIB_DEBUG_PRINT_SAFE("Kernel : waitfor internal proceeding\n"); … … 499 498 set_mask( monitors, count, mask ); 500 499 500 for(int i = 0; i < count; i++) { 501 verify( monitors[i]->owner == this_thread ); 502 } 503 501 504 //Everything is ready to go to sleep 502 505 BlockInternal( locks, count ); … … 537 540 storage[i]->mask = mask; 538 541 } 542 } 543 544 static inline void reset_mask( monitor_desc * this ) { 545 this->mask.accepted = NULL; 546 this->mask.clauses = NULL; 547 this->mask.size = 0; 539 548 } 540 549 … … 599 608 600 609 static inline void lock_all( spinlock ** locks, unsigned short count ) { 601 LIB_DEBUG_ACQUIRE();602 LIB_DEBUG_PRINT_NOLOCK("Kernel : Locking");603 610 for( int i = 0; i < count; i++ ) { 604 LIB_DEBUG_PRINT_NOLOCK(" %p", locks[i]);605 611 lock_yield( locks[i] DEBUG_CTX2 ); 606 612 } 607 LIB_DEBUG_PRINT_NOLOCK("\n");608 LIB_DEBUG_RELEASE();609 613 } 610 614 611 615 static inline void lock_all( monitor_desc ** source, spinlock ** /*out*/ locks, unsigned short count ) { 612 LIB_DEBUG_ACQUIRE();613 LIB_DEBUG_PRINT_NOLOCK("Kernel : Locking");614 616 for( int i = 0; i < count; i++ ) { 615 617 spinlock * l = &source[i]->lock; 616 LIB_DEBUG_PRINT_NOLOCK(" %p", l);617 618 lock_yield( l DEBUG_CTX2 ); 618 619 if(locks) locks[i] = l; 619 620 } 620 LIB_DEBUG_PRINT_NOLOCK("\n");621 LIB_DEBUG_RELEASE();622 621 } 623 622 … … 634 633 } 635 634 636 static inline void save 635 static inline void save( monitor_desc ** ctx, short count, __attribute((unused)) spinlock ** locks, unsigned int * /*out*/ recursions, __waitfor_mask_t * /*out*/ masks ) { 637 636 for( int i = 0; i < count; i++ ) { 638 637 recursions[i] = ctx[i]->recursion;
Note: See TracChangeset
for help on using the changeset viewer.