Changes in / [bd21af5:460bd3a]
- Location:
- src
- Files:
-
- 5 edited
-
libcfa/concurrency/kernel.c (modified) (12 diffs)
-
libcfa/concurrency/kernel_private.h (modified) (1 diff)
-
libcfa/concurrency/preemption.c (modified) (5 diffs)
-
libcfa/concurrency/preemption.h (modified) (1 diff)
-
tests/.expect/attributes.x86.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel.c
rbd21af5 r460bd3a 37 37 38 38 //Start and stop routine for the kernel, declared first to make sure they run first 39 staticvoid kernel_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));40 staticvoid kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));39 void kernel_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) )); 40 void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) )); 41 41 42 42 //----------------------------------------------------------------------------- … … 133 133 134 134 // Construct the processor context of non-main processors 135 staticvoid ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) {135 void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) { 136 136 (this.__cor){ info }; 137 137 this.proc = proc; 138 138 } 139 139 140 static void start(processor * this);141 140 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) { 142 141 this.name = name; … … 187 186 // Kernel Scheduling logic 188 187 //============================================================================================= 189 static void runThread(processor * this, thread_desc * dst);190 static void finishRunning(processor * this);191 static void halt(processor * this);192 193 188 //Main of the processor contexts 194 189 void main(processorCtx_t & runner) { … … 244 239 // runThread runs a thread by context switching 245 240 // from the processor coroutine to the target thread 246 staticvoid runThread(processor * this, thread_desc * dst) {241 void runThread(processor * this, thread_desc * dst) { 247 242 assert(dst->curr_cor); 248 243 coroutine_desc * proc_cor = get_coroutine(this->runner); … … 261 256 262 257 // KERNEL_ONLY 263 staticvoid returnToKernel() {258 void returnToKernel() { 264 259 coroutine_desc * proc_cor = get_coroutine(kernelTLS.this_processor->runner); 265 260 coroutine_desc * thrd_cor = kernelTLS.this_thread->curr_cor = kernelTLS.this_coroutine; … … 270 265 // Once a thread has finished running, some of 271 266 // its final actions must be executed from the kernel 272 staticvoid finishRunning(processor * this) with( this->finish ) {267 void finishRunning(processor * this) with( this->finish ) { 273 268 verify( ! kernelTLS.preemption_state.enabled ); 274 269 choose( action_code ) { … … 304 299 // This is the entry point for processors (kernel threads) 305 300 // It effectively constructs a coroutine by stealing the pthread stack 306 staticvoid * CtxInvokeProcessor(void * arg) {301 void * CtxInvokeProcessor(void * arg) { 307 302 processor * proc = (processor *) arg; 308 303 kernelTLS.this_processor = proc; … … 341 336 } 342 337 343 staticvoid start(processor * this) {338 void start(processor * this) { 344 339 __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this); 345 340 … … 547 542 //----------------------------------------------------------------------------- 548 543 // Kernel boot procedures 549 staticvoid kernel_startup(void) {544 void kernel_startup(void) { 550 545 verify( ! kernelTLS.preemption_state.enabled ); 551 546 __cfaabi_dbg_print_safe("Kernel : Starting\n"); … … 623 618 } 624 619 625 staticvoid kernel_shutdown(void) {620 void kernel_shutdown(void) { 626 621 __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n"); 627 622 … … 660 655 // Kernel Quiescing 661 656 //============================================================================================= 662 static void halt(processor * this) with( *this ) { 657 658 void halt(processor * this) with( *this ) { 663 659 // verify( ! __atomic_load_n(&do_terminate, __ATOMIC_SEQ_CST) ); 664 660 … … 687 683 // Unexpected Terminating logic 688 684 //============================================================================================= 685 686 689 687 static __spinlock_t kernel_abort_lock; 690 688 static bool kernel_abort_called = false; -
src/libcfa/concurrency/kernel_private.h
rbd21af5 r460bd3a 54 54 // Processor 55 55 void main(processorCtx_t *); 56 void start(processor * this); 57 void runThread(processor * this, thread_desc * dst); 58 void finishRunning(processor * this); 59 void halt(processor * this); 56 60 57 61 static inline void wake_fast(processor * this) { -
src/libcfa/concurrency/preemption.c
rbd21af5 r460bd3a 39 39 40 40 // FwdDeclarations : Signal handlers 41 staticvoid sigHandler_ctxSwitch( __CFA_SIGPARMS__ );42 staticvoid sigHandler_segv ( __CFA_SIGPARMS__ );43 staticvoid sigHandler_ill ( __CFA_SIGPARMS__ );44 staticvoid sigHandler_fpe ( __CFA_SIGPARMS__ );45 staticvoid sigHandler_abort ( __CFA_SIGPARMS__ );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__ ); 46 46 47 47 // FwdDeclarations : alarm thread main 48 staticvoid * alarm_loop( __attribute__((unused)) void * args );48 void * alarm_loop( __attribute__((unused)) void * args ); 49 49 50 50 // Machine specific register name … … 63 63 static pthread_t alarm_thread; // pthread handle to alarm thread 64 64 65 staticvoid ?{}(event_kernel_t & this) with( this ) {65 void ?{}(event_kernel_t & this) with( this ) { 66 66 alarms{}; 67 67 lock{}; … … 85 85 86 86 // Tick one frame of the Discrete Event Simulation for alarms 87 staticvoid tick_preemption() {87 void tick_preemption() { 88 88 alarm_node_t * node = NULL; // Used in the while loop but cannot be declared in the while condition 89 89 alarm_list_t * alarms = &event_kernel->alarms; // Local copy for ease of reading … … 350 350 // Context switch signal handler 351 351 // Receives SIGUSR1 signal and causes the current thread to yield 352 staticvoid sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {352 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) { 353 353 __cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); ) 354 354 … … 393 393 // Main of the alarm thread 394 394 // Waits on SIGALRM and send SIGUSR1 to whom ever needs it 395 staticvoid * alarm_loop( __attribute__((unused)) void * args ) {395 void * alarm_loop( __attribute__((unused)) void * args ) { 396 396 // Block sigalrms to control when they arrive 397 397 sigset_t mask; -
src/libcfa/concurrency/preemption.h
rbd21af5 r460bd3a 22 22 void kernel_stop_preemption(); 23 23 void update_preemption( processor * this, Duration duration ); 24 void tick_preemption(); 24 25 25 26 struct preemption_scope { -
src/tests/.expect/attributes.x86.txt
rbd21af5 r460bd3a 367 367 signed int __apd7__Fi_Fi_i_Fi_i___1(__attribute__ ((unused,unused,unused)) signed int (*__anonymous_object23)(__attribute__ ((unused)) signed int __anonymous_object24), __attribute__ ((unused,unused,unused)) signed int (*__anonymous_object25)(__attribute__ ((unused)) signed int __anonymous_object26)); 368 368 struct Vad { 369 __attribute__ ((unused)) signed int __anonymous_object27 :4;369 __attribute__ ((unused)) signed int __anonymous_object27; 370 370 __attribute__ ((unused)) signed int __anonymous_object28:4; 371 __attribute__ ((unused,unused)) signed int __anonymous_object29:6; 371 __attribute__ ((unused)) signed int __anonymous_object29:4; 372 __attribute__ ((unused,unused)) signed int __anonymous_object30:6; 372 373 }; 373 374 static inline void ___constructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1); … … 375 376 static inline void ___destructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1); 376 377 static inline struct Vad ___operator_assign__F4sVad_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1); 378 static inline void ___constructor__F_4sVadi_autogen___1(struct Vad *___dst__4sVad_1, __attribute__ ((unused)) signed int __anonymous_object31); 377 379 static inline void ___constructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1){ 380 ((void)((*___dst__4sVad_1).__anonymous_object27) /* ?{} */); 378 381 } 379 382 static inline void ___constructor__F_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1){ 383 ((void)((*___dst__4sVad_1).__anonymous_object27=___src__4sVad_1.__anonymous_object27) /* ?{} */); 380 384 } 381 385 static inline void ___destructor__F_4sVad_autogen___1(struct Vad *___dst__4sVad_1){ 386 ((void)((*___dst__4sVad_1).__anonymous_object27) /* ^?{} */); 382 387 } 383 388 static inline struct Vad ___operator_assign__F4sVad_4sVad4sVad_autogen___1(struct Vad *___dst__4sVad_1, struct Vad ___src__4sVad_1){ 384 389 struct Vad ___ret__4sVad_1; 390 ((void)((*___dst__4sVad_1).__anonymous_object27=___src__4sVad_1.__anonymous_object27)); 385 391 ((void)___constructor__F_4sVad4sVad_autogen___1((&___ret__4sVad_1), (*___dst__4sVad_1))); 386 392 return ___ret__4sVad_1; 387 393 } 394 static inline void ___constructor__F_4sVadi_autogen___1(struct Vad *___dst__4sVad_1, __attribute__ ((unused)) signed int __anonymous_object32){ 395 ((void)((*___dst__4sVad_1).__anonymous_object27=__anonymous_object32) /* ?{} */); 396 }
Note:
See TracChangeset
for help on using the changeset viewer.