Changeset 513daec for src/libcfa/concurrency
- Timestamp:
- Nov 2, 2017, 5:23:25 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:
- c1a9c86
- Parents:
- 025278e
- Location:
- src/libcfa/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/invoke.h
r025278e r513daec 29 29 30 30 typedef void (*fptr_t)(); 31 typedef int_fast16_t __lock_size_t; 31 32 32 33 struct spinlock { -
src/libcfa/concurrency/monitor.c
r025278e r513daec 26 26 // Forward declarations 27 27 static inline void set_owner ( monitor_desc * this, thread_desc * owner ); 28 static inline void set_owner ( monitor_desc * storage [], short count, thread_desc * owner );29 static inline void set_mask ( monitor_desc * storage [], short count, const __waitfor_mask_t & mask );28 static inline void set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner ); 29 static inline void set_mask ( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ); 30 30 static inline void reset_mask( monitor_desc * this ); 31 31 … … 33 33 static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors ); 34 34 35 static inline void lock_all ( spinlock * locks [], unsigned short count );36 static inline void lock_all ( monitor_desc * source [], spinlock * /*out*/ locks [], unsigned short count );37 static inline void unlock_all( spinlock * locks [], unsigned short count );38 static inline void unlock_all( monitor_desc * locks [], unsigned short count );39 40 static inline void save ( monitor_desc * ctx [], short count, spinlock * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );41 static inline void restore( monitor_desc * ctx [], short count, spinlock * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );42 43 static inline void init ( int count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );44 static inline void init_push( int count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );35 static inline void lock_all ( spinlock * locks [], __lock_size_t count ); 36 static inline void lock_all ( monitor_desc * source [], spinlock * /*out*/ locks [], __lock_size_t count ); 37 static inline void unlock_all( spinlock * locks [], __lock_size_t count ); 38 static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ); 39 40 static inline void save ( monitor_desc * ctx [], __lock_size_t count, spinlock * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] ); 41 static inline void restore( monitor_desc * ctx [], __lock_size_t count, spinlock * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] ); 42 43 static inline void init ( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ); 44 static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ); 45 45 46 46 static inline thread_desc * check_condition ( __condition_criterion_t * ); … … 330 330 } 331 331 332 333 332 // Ctor for monitor guard 334 333 // Sorts monitors before entering … … 349 348 __enter_monitor_dtor( this.m, func ); 350 349 } 351 352 350 353 351 // Dtor for monitor guard … … 661 659 } 662 660 663 static inline void set_owner( monitor_desc * monitors [], short count, thread_desc * owner ) {661 static inline void set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner ) { 664 662 monitors[0]->owner = owner; 665 663 monitors[0]->recursion = 1; 666 for( int i = 1; i < count; i++ ) {664 for( __lock_size_t i = 1; i < count; i++ ) { 667 665 monitors[i]->owner = owner; 668 666 monitors[i]->recursion = 0; … … 670 668 } 671 669 672 static inline void set_mask( monitor_desc * storage [], short count, const __waitfor_mask_t & mask ) {673 for( int i = 0; i < count; i++) {670 static inline void set_mask( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) { 671 for( __lock_size_t i = 0; i < count; i++) { 674 672 storage[i]->mask = mask; 675 673 } … … 725 723 } 726 724 727 static inline void init( int count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {728 for( int i = 0; i < count; i++) {725 static inline void init( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) { 726 for( __lock_size_t i = 0; i < count; i++) { 729 727 (criteria[i]){ monitors[i], waiter }; 730 728 } … … 733 731 } 734 732 735 static inline void init_push( int count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {736 for( int i = 0; i < count; i++) {733 static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) { 734 for( __lock_size_t i = 0; i < count; i++) { 737 735 (criteria[i]){ monitors[i], waiter }; 738 736 LIB_DEBUG_PRINT_SAFE( "Kernel : target %p = %p\n", criteria[i].target, &criteria[i] ); … … 743 741 } 744 742 745 static inline void lock_all( spinlock * locks [], unsigned short count ) {746 for( int i = 0; i < count; i++ ) {743 static inline void lock_all( spinlock * locks [], __lock_size_t count ) { 744 for( __lock_size_t i = 0; i < count; i++ ) { 747 745 lock_yield( locks[i] DEBUG_CTX2 ); 748 746 } 749 747 } 750 748 751 static inline void lock_all( monitor_desc * source [], spinlock * /*out*/ locks [], unsigned short count ) {752 for( int i = 0; i < count; i++ ) {749 static inline void lock_all( monitor_desc * source [], spinlock * /*out*/ locks [], __lock_size_t count ) { 750 for( __lock_size_t i = 0; i < count; i++ ) { 753 751 spinlock * l = &source[i]->lock; 754 752 lock_yield( l DEBUG_CTX2 ); … … 757 755 } 758 756 759 static inline void unlock_all( spinlock * locks [], unsigned short count ) {760 for( int i = 0; i < count; i++ ) {757 static inline void unlock_all( spinlock * locks [], __lock_size_t count ) { 758 for( __lock_size_t i = 0; i < count; i++ ) { 761 759 unlock( locks[i] ); 762 760 } 763 761 } 764 762 765 static inline void unlock_all( monitor_desc * locks [], unsigned short count ) {766 for( int i = 0; i < count; i++ ) {763 static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ) { 764 for( __lock_size_t i = 0; i < count; i++ ) { 767 765 unlock( &locks[i]->lock ); 768 766 } … … 771 769 static inline void save( 772 770 monitor_desc * ctx [], 773 short count,771 __lock_size_t count, 774 772 __attribute((unused)) spinlock * locks [], 775 773 unsigned int /*out*/ recursions [], 776 774 __waitfor_mask_t /*out*/ masks [] 777 775 ) { 778 for( int i = 0; i < count; i++ ) {776 for( __lock_size_t i = 0; i < count; i++ ) { 779 777 recursions[i] = ctx[i]->recursion; 780 778 masks[i] = ctx[i]->mask; … … 784 782 static inline void restore( 785 783 monitor_desc * ctx [], 786 short count,784 __lock_size_t count, 787 785 spinlock * locks [], 788 786 unsigned int /*out*/ recursions [], … … 790 788 ) { 791 789 lock_all( locks, count ); 792 for( int i = 0; i < count; i++ ) {790 for( __lock_size_t i = 0; i < count; i++ ) { 793 791 ctx[i]->recursion = recursions[i]; 794 792 ctx[i]->mask = masks[i];
Note: See TracChangeset
for help on using the changeset viewer.