Changeset b067d9b for libcfa/src/concurrency/preemption.cfa
- Timestamp:
- Oct 29, 2019, 4:01:24 PM (6 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:
- 773db65, 9421f3d8
- Parents:
- 7951100 (diff), 8364209 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
r7951100 rb067d9b 14 14 // 15 15 16 #include "preemption.h" 16 #define __cforall_thread__ 17 18 #include "preemption.hfa" 17 19 #include <assert.h> 18 20 … … 24 26 } 25 27 26 #include "bits/signal.h "28 #include "bits/signal.hfa" 27 29 28 30 #if !defined(__CFA_DEFAULT_PREEMPTION__) … … 39 41 40 42 // FwdDeclarations : Signal handlers 41 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );42 void sigHandler_segv ( __CFA_SIGPARMS__ );43 void sigHandler_ill ( __CFA_SIGPARMS__ );44 void sigHandler_fpe ( __CFA_SIGPARMS__ );45 void sigHandler_abort ( __CFA_SIGPARMS__ );43 static void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ); 44 static void sigHandler_segv ( __CFA_SIGPARMS__ ); 45 static void sigHandler_ill ( __CFA_SIGPARMS__ ); 46 static void sigHandler_fpe ( __CFA_SIGPARMS__ ); 47 static void sigHandler_abort ( __CFA_SIGPARMS__ ); 46 48 47 49 // FwdDeclarations : alarm thread main 48 void * alarm_loop( __attribute__((unused)) void * args );50 static void * alarm_loop( __attribute__((unused)) void * args ); 49 51 50 52 // Machine specific register name … … 63 65 static pthread_t alarm_thread; // pthread handle to alarm thread 64 66 65 void ?{}(event_kernel_t & this) with( this ) {67 static void ?{}(event_kernel_t & this) with( this ) { 66 68 alarms{}; 67 69 lock{}; … … 85 87 86 88 // Tick one frame of the Discrete Event Simulation for alarms 87 void tick_preemption() {89 static void tick_preemption() { 88 90 alarm_node_t * node = NULL; // Used in the while loop but cannot be declared in the while condition 89 91 alarm_list_t * alarms = &event_kernel->alarms; // Local copy for ease of reading … … 263 265 } 264 266 265 // kill wrapper : signal a processor266 void terminate(processor * this) {267 disable_interrupts();268 __atomic_store_n(&this->do_terminate, true, __ATOMIC_SEQ_CST);269 wake( this );270 sigval_t value = { PREEMPT_TERMINATE };271 enable_interrupts( __cfaabi_dbg_ctx );272 pthread_sigqueue( this->kernel_thread, SIGUSR1, value );273 }274 275 267 // reserved for future use 276 268 static void timeout( thread_desc * this ) { … … 360 352 // Context switch signal handler 361 353 // Receives SIGUSR1 signal and causes the current thread to yield 362 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {354 static void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) { 363 355 __cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); ) 364 356 … … 403 395 // Main of the alarm thread 404 396 // Waits on SIGALRM and send SIGUSR1 to whom ever needs it 405 void * alarm_loop( __attribute__((unused)) void * args ) {397 static void * alarm_loop( __attribute__((unused)) void * args ) { 406 398 // Block sigalrms to control when they arrive 407 399 sigset_t mask;
Note:
See TracChangeset
for help on using the changeset viewer.