Changeset f2b12406
- Timestamp:
- Jul 12, 2017, 10:14:11 AM (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:
- f73f5f4
- Parents:
- 0322865c
- Location:
- src/libcfa/concurrency
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/invoke.c
r0322865c rf2b12406 80 80 // 2 - Leave its monitor 81 81 // 3 - Disable the interupts 82 // The order of these 3 operations is very important 82 // 4 - Final suspend 83 // The order of these 4 operations is very important 84 //Final suspend, should never return 83 85 __leave_thread_monitor( thrd ); 84 85 //Final suspend, should never return86 __suspend_internal();87 86 abortf("Resumed dead thread"); 88 87 } -
src/libcfa/concurrency/kernel.c
r0322865c rf2b12406 42 42 //----------------------------------------------------------------------------- 43 43 // Kernel storage 44 #define KERNEL_STORAGE(T,X) static char X## _storage[sizeof(T)]44 #define KERNEL_STORAGE(T,X) static char X##Storage[sizeof(T)] 45 45 46 46 KERNEL_STORAGE(processorCtx_t, systemProcessorCtx); … … 48 48 KERNEL_STORAGE(system_proc_t, systemProcessor); 49 49 KERNEL_STORAGE(thread_desc, mainThread); 50 KERNEL_STORAGE(machine_context_t, mainThread _context);50 KERNEL_STORAGE(machine_context_t, mainThreadCtx); 51 51 52 52 cluster * systemCluster; … … 84 84 85 85 this->limit = (void *)(((intptr_t)this->base) - this->size); 86 this->context = &mainThread _context_storage;86 this->context = &mainThreadCtxStorage; 87 87 this->top = this->base; 88 88 } … … 432 432 } 433 433 434 void LeaveThread(spinlock * lock, thread_desc * thrd) { 435 verify( disable_preempt_count > 0 ); 436 this_processor->finish.action_code = thrd ? Release_Schedule : Release; 437 this_processor->finish.lock = lock; 438 this_processor->finish.thrd = thrd; 439 440 suspend(); 441 } 442 434 443 //============================================================================================= 435 444 // Kernel Setup logic … … 443 452 // SKULLDUGGERY: the mainThread steals the process main thread 444 453 // which will then be scheduled by the systemProcessor normally 445 mainThread = (thread_desc *)&mainThread _storage;454 mainThread = (thread_desc *)&mainThreadStorage; 446 455 current_stack_info_t info; 447 456 mainThread{ &info }; … … 450 459 451 460 // Initialize the system cluster 452 systemCluster = (cluster *)&systemCluster _storage;461 systemCluster = (cluster *)&systemClusterStorage; 453 462 systemCluster{}; 454 463 … … 457 466 // Initialize the system processor and the system processor ctx 458 467 // (the coroutine that contains the processing control flow) 459 systemProcessor = (system_proc_t *)&systemProcessor _storage;460 systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx _storage };468 systemProcessor = (system_proc_t *)&systemProcessorStorage; 469 systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtxStorage }; 461 470 462 471 // Add the main thread to the ready queue -
src/libcfa/concurrency/kernel_private.h
r0322865c rf2b12406 51 51 void BlockInternal(spinlock ** locks, unsigned short count); 52 52 void BlockInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count); 53 void LeaveThread(spinlock * lock, thread_desc * thrd); 53 54 54 55 //----------------------------------------------------------------------------- -
src/libcfa/concurrency/monitor.c
r0322865c rf2b12406 124 124 thread_desc * new_owner = next_thread( this ); 125 125 126 //We can now let other threads in safely 127 unlock( &this->lock ); 128 129 //We need to wake-up the thread 130 if( new_owner) ScheduleThread( new_owner ); 126 LeaveThread( &this->lock, new_owner ); 131 127 } 132 128 } -
src/libcfa/concurrency/preemption.c
r0322865c rf2b12406 209 209 LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n"); 210 210 __kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO ); 211 __kernel_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );212 __kernel_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );211 // __kernel_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); 212 // __kernel_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO ); 213 213 214 214 signal_block( SIGALRM ); … … 417 417 ) 418 418 419 void sigHandler_segv( __CFA_SIGPARMS__ ) {420 LIB_DEBUG_DO(421 #ifdef __USE_STREAM__422 serr | "*CFA runtime error* program cfa-cpp terminated with"423 | (sig == SIGSEGV ? "segment fault." : "bus error.")424 | endl;425 #else426 fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." );427 #endif428 429 // skip first 2 stack frames430 __kernel_backtrace( 1 );431 )432 exit( EXIT_FAILURE );433 }419 // void sigHandler_segv( __CFA_SIGPARMS__ ) { 420 // LIB_DEBUG_DO( 421 // #ifdef __USE_STREAM__ 422 // serr | "*CFA runtime error* program cfa-cpp terminated with" 423 // | (sig == SIGSEGV ? "segment fault." : "bus error.") 424 // | endl; 425 // #else 426 // fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." ); 427 // #endif 428 429 // // skip first 2 stack frames 430 // __kernel_backtrace( 1 ); 431 // ) 432 // exit( EXIT_FAILURE ); 433 // } 434 434 435 435 // void sigHandler_abort( __CFA_SIGPARMS__ ) {
Note: See TracChangeset
for help on using the changeset viewer.