Changeset 1a3040c for libcfa/src/concurrency
- Timestamp:
- Dec 4, 2019, 11:25:58 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- fa35958
- Parents:
- 121be3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r121be3e r1a3040c 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 1 17:52:57201913 // Update Count : 4 512 // Last Modified On : Tue Dec 3 21:46:54 2019 13 // Update Count : 49 14 14 // 15 15 … … 27 27 #include <unistd.h> 28 28 #include <limits.h> // PTHREAD_STACK_MIN 29 #include <sys/mman.h> // mprotect 29 30 } 30 31 … … 281 282 282 283 thread_desc * readyThread = 0p; 283 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) 284 { 284 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) { 285 285 readyThread = nextThread( this->cltr ); 286 286 287 if(readyThread) 288 { 287 if(readyThread) { 289 288 verify( ! kernelTLS.preemption_state.enabled ); 290 289 … … 297 296 298 297 spin_count = 0; 299 } 300 else 301 { 298 } else { 302 299 // spin(this, &spin_count); 303 300 halt(this); … … 445 442 446 443 static void Abort( int ret, const char * func ) { 447 if ( ret ) { 444 if ( ret ) { // pthread routines return errno values 448 445 abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) ); 449 446 } // if … … 455 452 Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 456 453 454 size_t stacksize; 455 // default stack size, normally defined by shell limit 456 Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 457 assert( stacksize >= PTHREAD_STACK_MIN ); 458 457 459 #ifdef __CFA_DEBUG__ 458 size_t guardsize; 459 Abort( pthread_attr_getguardsize( &attr, &guardsize ), "pthread_attr_getguardsize" ); 460 Abort( pthread_attr_setguardsize( &attr, guardsize ), "pthread_attr_setguardsize" ); 460 void * stack = memalign( __page_size, stacksize + __page_size ); 461 // pthread has no mechanism to create the guard page in user supplied stack. 462 if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) { 463 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 464 } // if 465 #else 466 void * stack = malloc( stacksize ); 461 467 #endif 462 468 463 size_t stacksize;464 Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); // default stack size, normally defined by shell limit465 assert( stacksize >= PTHREAD_STACK_MIN );466 void * stack = malloc( stacksize );467 469 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 468 470
Note: See TracChangeset
for help on using the changeset viewer.