Changes in src/libcfa/concurrency/kernel.c [c2b9f21:0cf5b79]
- File:
-
- 1 edited
-
src/libcfa/concurrency/kernel.c (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel.c
rc2b9f21 r0cf5b79 14 14 // 15 15 16 #include "libhdr.h" 17 16 18 //C Includes 17 19 #include <stddef.h> … … 148 150 149 151 this.runner = &runner; 150 __cfaabi_dbg_print_safe("Kernel : constructing main processor context %p\n", &runner);152 LIB_DEBUG_PRINT_SAFE("Kernel : constructing main processor context %p\n", &runner); 151 153 runner{ &this }; 152 154 } … … 154 156 void ^?{}(processor & this) { 155 157 if( ! this.do_terminate ) { 156 __cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);158 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", &this); 157 159 this.do_terminate = true; 158 160 P( this.terminated ); … … 179 181 processor * this = runner.proc; 180 182 181 __cfaabi_dbg_print_safe("Kernel : core %p starting\n", this);183 LIB_DEBUG_PRINT_SAFE("Kernel : core %p starting\n", this); 182 184 183 185 { … … 185 187 preemption_scope scope = { this }; 186 188 187 __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);189 LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this); 188 190 189 191 thread_desc * readyThread = NULL; … … 211 213 } 212 214 213 __cfaabi_dbg_print_safe("Kernel : core %p stopping\n", this);215 LIB_DEBUG_PRINT_SAFE("Kernel : core %p stopping\n", this); 214 216 } 215 217 216 218 V( this->terminated ); 217 219 218 __cfaabi_dbg_print_safe("Kernel : core %p terminated\n", this);220 LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this); 219 221 } 220 222 … … 290 292 processorCtx_t proc_cor_storage = { proc, &info }; 291 293 292 __cfaabi_dbg_print_safe("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base);294 LIB_DEBUG_PRINT_SAFE("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base); 293 295 294 296 //Set global state … … 297 299 298 300 //We now have a proper context from which to schedule threads 299 __cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);301 LIB_DEBUG_PRINT_SAFE("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx); 300 302 301 303 // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't … … 308 310 309 311 // Main routine of the core returned, the core is now fully terminated 310 __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, proc->runner);312 LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner); 311 313 312 314 return NULL; … … 314 316 315 317 void start(processor * this) { 316 __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);318 LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this); 317 319 318 320 pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this ); 319 321 320 __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);322 LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this); 321 323 } 322 324 … … 332 334 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); 333 335 334 lock( this_processor->cltr->ready_queue_lock __cfaabi_dbg_ctx2 );336 lock( this_processor->cltr->ready_queue_lock DEBUG_CTX2 ); 335 337 append( this_processor->cltr->ready_queue, thrd ); 336 338 unlock( this_processor->cltr->ready_queue_lock ); … … 341 343 thread_desc * nextThread(cluster * this) { 342 344 verify( disable_preempt_count > 0 ); 343 lock( this->ready_queue_lock __cfaabi_dbg_ctx2 );345 lock( this->ready_queue_lock DEBUG_CTX2 ); 344 346 thread_desc * head = pop_head( this->ready_queue ); 345 347 unlock( this->ready_queue_lock ); … … 353 355 suspend(); 354 356 verify( disable_preempt_count > 0 ); 355 enable_interrupts( __cfaabi_dbg_ctx);357 enable_interrupts( DEBUG_CTX ); 356 358 } 357 359 … … 365 367 verify( disable_preempt_count > 0 ); 366 368 367 enable_interrupts( __cfaabi_dbg_ctx);369 enable_interrupts( DEBUG_CTX ); 368 370 } 369 371 … … 379 381 verify( disable_preempt_count > 0 ); 380 382 381 enable_interrupts( __cfaabi_dbg_ctx);383 enable_interrupts( DEBUG_CTX ); 382 384 } 383 385 … … 393 395 verify( disable_preempt_count > 0 ); 394 396 395 enable_interrupts( __cfaabi_dbg_ctx);397 enable_interrupts( DEBUG_CTX ); 396 398 } 397 399 … … 406 408 verify( disable_preempt_count > 0 ); 407 409 408 enable_interrupts( __cfaabi_dbg_ctx);410 enable_interrupts( DEBUG_CTX ); 409 411 } 410 412 … … 421 423 verify( disable_preempt_count > 0 ); 422 424 423 enable_interrupts( __cfaabi_dbg_ctx);425 enable_interrupts( DEBUG_CTX ); 424 426 } 425 427 … … 439 441 // Kernel boot procedures 440 442 void kernel_startup(void) { 441 __cfaabi_dbg_print_safe("Kernel : Starting\n");443 LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n"); 442 444 443 445 // Start by initializing the main thread … … 448 450 (*mainThread){ &info }; 449 451 450 __cfaabi_dbg_print_safe("Kernel : Main thread ready\n");452 LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n"); 451 453 452 454 // Initialize the main cluster … … 454 456 (*mainCluster){}; 455 457 456 __cfaabi_dbg_print_safe("Kernel : main cluster ready\n");458 LIB_DEBUG_PRINT_SAFE("Kernel : main cluster ready\n"); 457 459 458 460 // Initialize the main processor and the main processor ctx … … 481 483 482 484 // THE SYSTEM IS NOW COMPLETELY RUNNING 483 __cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");484 485 enable_interrupts( __cfaabi_dbg_ctx);485 LIB_DEBUG_PRINT_SAFE("Kernel : Started\n--------------------------------------------------\n\n"); 486 487 enable_interrupts( DEBUG_CTX ); 486 488 } 487 489 488 490 void kernel_shutdown(void) { 489 __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");491 LIB_DEBUG_PRINT_SAFE("\n--------------------------------------------------\nKernel : Shutting down\n"); 490 492 491 493 disable_interrupts(); … … 511 513 ^(mainThread){}; 512 514 513 __cfaabi_dbg_print_safe("Kernel : Shutdown complete\n");515 LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n"); 514 516 } 515 517 … … 521 523 // abort cannot be recursively entered by the same or different processors because all signal handlers return when 522 524 // the globalAbort flag is true. 523 lock( kernel_abort_lock __cfaabi_dbg_ctx2 );525 lock( kernel_abort_lock DEBUG_CTX2 ); 524 526 525 527 // first task to abort ? … … 546 548 547 549 int len = snprintf( abort_text, abort_text_size, "Error occurred while executing task %.256s (%p)", thrd->self_cor.name, thrd ); 548 __ cfaabi_dbg_bits_write( abort_text, len );550 __lib_debug_write( abort_text, len ); 549 551 550 552 if ( thrd != this_coroutine ) { 551 553 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine->name, this_coroutine ); 552 __ cfaabi_dbg_bits_write( abort_text, len );554 __lib_debug_write( abort_text, len ); 553 555 } 554 556 else { 555 __ cfaabi_dbg_bits_write( ".\n", 2 );557 __lib_debug_write( ".\n", 2 ); 556 558 } 557 559 } 558 560 559 561 extern "C" { 560 void __ cfaabi_dbg_bits_acquire() {561 lock( kernel_debug_lock __cfaabi_dbg_ctx2 );562 } 563 564 void __ cfaabi_dbg_bits_release() {562 void __lib_debug_acquire() { 563 lock( kernel_debug_lock DEBUG_CTX2 ); 564 } 565 566 void __lib_debug_release() { 565 567 unlock( kernel_debug_lock ); 566 568 } … … 580 582 581 583 void P(semaphore & this) { 582 lock( this.lock __cfaabi_dbg_ctx2 );584 lock( this.lock DEBUG_CTX2 ); 583 585 this.count -= 1; 584 586 if ( this.count < 0 ) { … … 596 598 void V(semaphore & this) { 597 599 thread_desc * thrd = NULL; 598 lock( this.lock __cfaabi_dbg_ctx2 );600 lock( this.lock DEBUG_CTX2 ); 599 601 this.count += 1; 600 602 if ( this.count <= 0 ) {
Note:
See TracChangeset
for help on using the changeset viewer.