Changeset 4233338b
- Timestamp:
- Jan 10, 2022, 4:07:04 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 56d711f
- Parents:
- 0ac728b (diff), 7d0ebd0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 1 deleted
- 8 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.hfa
r0ac728b r4233338b 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 12:29:26 202013 // Update Count : 1 112 // Last Modified On : Thu Jan 6 16:33:16 2022 13 // Update Count : 12 14 14 // 15 15 … … 155 155 156 156 if( unlikely(dst->context.SP == 0p) ) { 157 __stack_prepare(&dst->stack, 65000);157 __stack_prepare(&dst->stack, DEFAULT_STACK_SIZE); 158 158 __cfactx_start(main, dst, cor, __cfactx_invoke_coroutine); 159 159 } -
libcfa/src/concurrency/invoke.h
r0ac728b r4233338b 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 5 16:26:03 201913 // Update Count : 4 412 // Last Modified On : Thu Jan 6 16:37:40 2022 13 // Update Count : 47 14 14 // 15 15 … … 27 27 #ifndef _INVOKE_H_ 28 28 #define _INVOKE_H_ 29 30 enum { DEFAULT_STACK_SIZE = 65000 }; 29 31 30 32 struct __cfaehm_try_resume_node; -
libcfa/src/concurrency/kernel.cfa
r0ac728b r4233338b 142 142 extern void __disable_interrupts_hard(); 143 143 extern void __enable_interrupts_hard(); 144 145 static inline void __disable_interrupts_checked() {146 /* paranoid */ verify( __preemption_enabled() );147 disable_interrupts();148 /* paranoid */ verify( ! __preemption_enabled() );149 }150 151 static inline void __enable_interrupts_checked( bool poll = true ) {152 /* paranoid */ verify( ! __preemption_enabled() );153 enable_interrupts( poll );154 /* paranoid */ verify( __preemption_enabled() );155 }156 144 157 145 … … 776 764 // Unconditionnaly wake a thread 777 765 void __wake_proc(processor * this) { 766 /* paranoid */ verify( ! __preemption_enabled() ); 767 778 768 __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this); 779 769 780 __disable_interrupts_checked(); 781 /* paranoid */ verify( ! __preemption_enabled() ); 782 eventfd_t val; 783 val = 1; 784 eventfd_write( this->idle_fd, val ); 785 __enable_interrupts_checked(); 770 eventfd_t val; 771 val = 1; 772 eventfd_write( this->idle_fd, val ); 773 774 /* paranoid */ verify( ! __preemption_enabled() ); 786 775 } 787 776 -
libcfa/src/concurrency/kernel/startup.cfa
r0ac728b r4233338b 279 279 // When its coroutine terminates, it return control to the mainThread 280 280 // which is currently here 281 /* paranoid */ verify( !__atomic_load_n(&mainProcessor->do_terminate, __ATOMIC_ACQUIRE) ); 281 282 __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE); 283 __wake_proc( mainProcessor ); 282 284 __kernel_last_resume( __cfaabi_tls.this_processor ); 283 285 mainThread->self_cor.state = Halted; … … 403 405 404 406 __cfaabi_tls.this_thread->curr_cor = dst; 405 __stack_prepare( &dst->stack, 65000);407 __stack_prepare( &dst->stack, DEFAULT_STACK_SIZE ); 406 408 __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine); 407 409 … … 564 566 extern size_t __page_size; 565 567 void ^?{}(processor & this) with( this ){ 566 if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) { 567 __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this); 568 569 __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED); 568 /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ); 569 __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this); 570 571 __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED); 572 __disable_interrupts_checked(); 570 573 __wake_proc( &this ); 571 572 wait( terminated ); 573 /* paranoid */ verify( active_processor() != &this);574 }574 __enable_interrupts_checked(); 575 576 wait( terminated ); 577 /* paranoid */ verify( active_processor() != &this); 575 578 576 579 __destroy_pthread( kernel_thread, this.stack, 0p ); … … 721 724 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 722 725 723 size_t stacksize; 724 // default stack size, normally defined by shell limit 725 check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 726 assert( stacksize >= PTHREAD_STACK_MIN ); 726 size_t stacksize = DEFAULT_STACK_SIZE; 727 727 728 728 void * stack; … … 749 749 #endif 750 750 751 752 751 check( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 753 754 752 check( pthread_create( pthread, &attr, start, arg ), "pthread_create" ); 755 753 return stack; -
libcfa/src/concurrency/kernel_private.hfa
r0ac728b r4233338b 60 60 extern bool __preemption_enabled(); 61 61 62 static inline void __disable_interrupts_checked() { 63 /* paranoid */ verify( __preemption_enabled() ); 64 disable_interrupts(); 65 /* paranoid */ verify( ! __preemption_enabled() ); 66 } 67 68 static inline void __enable_interrupts_checked( bool poll = true ) { 69 /* paranoid */ verify( ! __preemption_enabled() ); 70 enable_interrupts( poll ); 71 /* paranoid */ verify( __preemption_enabled() ); 72 } 73 62 74 //release/wake-up the following resources 63 75 void __thread_finish( thread$ * thrd ); -
libcfa/src/concurrency/locks.hfa
r0ac728b r4233338b 177 177 }; 178 178 179 static inline void ?{}(fast_lock & this) __attribute__((deprecated("use linear_backoff_then_block_lock instead"))); 179 180 static inline void ?{}(fast_lock & this) { this.owner = 0p; } 180 181 … … 184 185 } 185 186 186 static inline void lock( fast_lock & this ) __attribute__(( artificial));187 static inline void lock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial)); 187 188 static inline void lock( fast_lock & this ) { 188 189 thread$ * thrd = active_thread(); … … 195 196 } 196 197 197 static inline bool try_lock( fast_lock & this ) __attribute__(( artificial));198 static inline bool try_lock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial)); 198 199 static inline bool try_lock ( fast_lock & this ) { 199 200 thread$ * thrd = active_thread(); … … 202 203 } 203 204 204 static inline thread$ * unlock( fast_lock & this ) __attribute__(( artificial));205 static inline thread$ * unlock( fast_lock & this ) __attribute__((deprecated("use linear_backoff_then_block_lock instead"), artificial)); 205 206 static inline thread$ * unlock( fast_lock & this ) { 206 207 /* paranoid */ verify(active_thread() == this.owner); -
libcfa/src/concurrency/thread.hfa
r0ac728b r4233338b 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 09:18:14 201913 // Update Count : 612 // Last Modified On : Thu Jan 6 16:40:16 2022 13 // Update Count : 7 14 14 // 15 15 … … 65 65 void ^?{}(thread$ & this); 66 66 67 static inline void ?{}(thread$ & this) { this{ "Anonymous Thread", *mainCluster, 0p, 65000}; }67 static inline void ?{}(thread$ & this) { this{ "Anonymous Thread", *mainCluster, 0p, DEFAULT_STACK_SIZE }; } 68 68 static inline void ?{}(thread$ & this, size_t stackSize ) { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; } 69 69 static inline void ?{}(thread$ & this, void * storage, size_t storageSize ) { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; } 70 static inline void ?{}(thread$ & this, struct cluster & cl ) { this{ "Anonymous Thread", cl, 0p, 65000}; }70 static inline void ?{}(thread$ & this, struct cluster & cl ) { this{ "Anonymous Thread", cl, 0p, DEFAULT_STACK_SIZE }; } 71 71 static inline void ?{}(thread$ & this, struct cluster & cl, size_t stackSize ) { this{ "Anonymous Thread", cl, 0p, stackSize }; } 72 72 static inline void ?{}(thread$ & this, struct cluster & cl, void * storage, size_t storageSize ) { this{ "Anonymous Thread", cl, storage, storageSize }; } 73 static inline void ?{}(thread$ & this, const char * const name) { this{ name, *mainCluster, 0p, 65000}; }74 static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl ) { this{ name, cl, 0p, 65000}; }73 static inline void ?{}(thread$ & this, const char * const name) { this{ name, *mainCluster, 0p, DEFAULT_STACK_SIZE }; } 74 static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl ) { this{ name, cl, 0p, DEFAULT_STACK_SIZE }; } 75 75 static inline void ?{}(thread$ & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; } 76 76 -
tests/unified_locking/mutex_test.hfa
r0ac728b r4233338b 10 10 thread$ * id; 11 11 uint32_t sum; 12 uint32_t cnt; 12 13 }; 13 14 … … 27 28 { 28 29 uint32_t tsum = mo.sum; 30 uint32_t cnt = mo.cnt; 29 31 mo.id = me; 30 32 yield(random(5)); 31 33 value = ((uint32_t)random()) ^ ((uint32_t)me); 32 34 if(mo.id != me) sout | "Intruder!"; 35 mo.cnt = cnt + 1; 33 36 mo.sum = tsum + value; 34 37 } … … 54 57 uint32_t sum = -32; 55 58 mo.sum = -32; 59 mo.cnt = 0; 56 60 processor p[2]; 57 61 sout | "Starting"; … … 63 67 } 64 68 sout | "Done!"; 69 if(mo.cnt != (13 * num_times)) sout | "Invalid cs count!" | mo.cnt | "vs "| (13 * num_times) | "(13 *" | num_times | ')'; 65 70 if(sum == mo.sum) sout | "Match!"; 66 71 else sout | "No Match!" | sum | "vs" | mo.sum;
Note: See TracChangeset
for help on using the changeset viewer.