Changeset 8e4aa05 for libcfa/src/concurrency/kernel/startup.cfa
- Timestamp:
- Mar 4, 2021, 7:40:25 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 77d601f
- Parents:
- 342af53 (diff), a5040fe (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 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r342af53 r8e4aa05 22 22 extern "C" { 23 23 #include <limits.h> // PTHREAD_STACK_MIN 24 #include <sys/eventfd.h> // eventfd 24 25 #include <sys/mman.h> // mprotect 25 26 #include <sys/resource.h> // getrlimit … … 89 90 extern void __kernel_alarm_startup(void); 90 91 extern void __kernel_alarm_shutdown(void); 91 extern void __kernel_io_startup (void);92 extern void __kernel_io_shutdown(void);93 92 94 93 //----------------------------------------------------------------------------- … … 102 101 KERNEL_STORAGE($thread, mainThread); 103 102 KERNEL_STORAGE(__stack_t, mainThreadCtx); 104 KERNEL_STORAGE(io_context, mainPollerThread);105 103 KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock); 106 104 #if !defined(__CFA_NO_STATISTICS__) … … 198 196 199 197 void ?{}(processor & this) with( this ) { 200 ( this.idle ){}; 201 ( this.terminated ){ 0 }; 198 ( this.terminated ){}; 202 199 ( this.runner ){}; 203 200 init( this, "Main Processor", *mainCluster ); … … 226 223 __kernel_alarm_startup(); 227 224 228 // Start IO229 __kernel_io_startup();230 231 225 // Add the main thread to the ready queue 232 226 // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread … … 241 235 // THE SYSTEM IS NOW COMPLETELY RUNNING 242 236 243 244 // SKULLDUGGERY: The constructor for the mainCluster will call alloc with a dimension of 0245 // malloc *can* return a non-null value, we should free it if that is the case246 free( mainCluster->io.ctxs );247 248 // Now that the system is up, finish creating systems that need threading249 mainCluster->io.ctxs = (io_context *)&storage_mainPollerThread;250 mainCluster->io.cnt = 1;251 (*mainCluster->io.ctxs){ *mainCluster };252 253 237 __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n"); 254 238 … … 260 244 261 245 static void __kernel_shutdown(void) { 262 //Before we start shutting things down, wait for systems that need threading to shutdown263 ^(*mainCluster->io.ctxs){};264 mainCluster->io.cnt = 0;265 mainCluster->io.ctxs = 0p;266 267 246 /* paranoid */ verify( __preemption_enabled() ); 268 247 disable_interrupts(); … … 282 261 // Disable preemption 283 262 __kernel_alarm_shutdown(); 284 285 // Stop IO286 __kernel_io_shutdown();287 263 288 264 // Destroy the main processor and its context in reverse order of construction … … 484 460 pending_preemption = false; 485 461 462 this.io.ctx = 0p; 463 this.io.pending = false; 464 this.io.dirty = false; 465 466 this.idle = eventfd(0, 0); 467 if (idle < 0) { 468 abort("KERNEL ERROR: PROCESSOR EVENTFD - %s\n", strerror(errno)); 469 } 470 486 471 #if !defined(__CFA_NO_STATISTICS__) 487 472 print_stats = 0; … … 524 509 // Finally we don't need the read_lock any more 525 510 unregister((__processor_id_t*)&this); 511 512 close(this.idle); 526 513 } 527 514 528 515 void ?{}(processor & this, const char name[], cluster & _cltr) { 529 ( this.idle ){}; 530 ( this.terminated ){ 0 }; 516 ( this.terminated ){}; 531 517 ( this.runner ){}; 532 518 … … 549 535 __wake_proc( &this ); 550 536 551 P( terminated );537 wait( terminated ); 552 538 /* paranoid */ verify( active_processor() != &this); 553 539 } … … 582 568 threads{ __get }; 583 569 570 io.arbiter = create(); 571 io.params = io_params; 572 584 573 doregister(this); 585 574 … … 594 583 ready_mutate_unlock( last_size ); 595 584 enable_interrupts_noPoll(); // Don't poll, could be in main cluster 596 597 598 this.io.cnt = num_io;599 this.io.ctxs = aalloc(num_io);600 for(i; this.io.cnt) {601 (this.io.ctxs[i]){ this, io_params };602 }603 585 } 604 586 605 587 void ^?{}(cluster & this) { 606 for(i; this.io.cnt) { 607 ^(this.io.ctxs[i]){ true }; 608 } 609 free(this.io.ctxs); 588 destroy(this.io.arbiter); 610 589 611 590 // Lock the RWlock so no-one pushes/pops while we are changing the queue … … 736 715 } 737 716 738 739 717 #if defined(__CFA_WITH_VERIFY__) 740 718 static bool verify_fwd_bck_rng(void) {
Note:
See TracChangeset
for help on using the changeset viewer.