Changeset 78da4ab for libcfa/src/concurrency/kernel/startup.cfa
- Timestamp:
- Feb 19, 2021, 1:47:09 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4f762d3
- Parents:
- b44959f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
rb44959f r78da4ab 104 104 KERNEL_STORAGE($thread, mainThread); 105 105 KERNEL_STORAGE(__stack_t, mainThreadCtx); 106 KERNEL_STORAGE(io_context, main PollerThread);106 KERNEL_STORAGE(io_context, mainIoContext); 107 107 KERNEL_STORAGE(__scheduler_RWLock_t, __scheduler_lock); 108 108 #if !defined(__CFA_NO_STATISTICS__) … … 231 231 __kernel_io_startup(); 232 232 233 io_context * mainio = (io_context *)&storage_mainIoContext; 234 (*mainio){ *mainCluster }; 235 233 236 // Add the main thread to the ready queue 234 237 // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread … … 243 246 // THE SYSTEM IS NOW COMPLETELY RUNNING 244 247 245 246 // SKULLDUGGERY: The constructor for the mainCluster will call alloc with a dimension of 0247 // malloc *can* return a non-null value, we should free it if that is the case248 free( mainCluster->io.ctxs );249 250 // Now that the system is up, finish creating systems that need threading251 mainCluster->io.ctxs = (io_context *)&storage_mainPollerThread;252 mainCluster->io.cnt = 1;253 (*mainCluster->io.ctxs){ *mainCluster };254 255 248 __cfadbg_print_safe(runtime_core, "Kernel : Started\n--------------------------------------------------\n\n"); 256 249 … … 263 256 static void __kernel_shutdown(void) { 264 257 //Before we start shutting things down, wait for systems that need threading to shutdown 265 ^(*mainCluster->io.ctxs){}; 266 mainCluster->io.cnt = 0; 267 mainCluster->io.ctxs = 0p; 258 io_context * mainio = (io_context *)&storage_mainIoContext; 259 ^(*mainio){}; 268 260 269 261 /* paranoid */ verify( __preemption_enabled() ); … … 486 478 pending_preemption = false; 487 479 480 this.io.ctx = 0p; 481 this.io.lock = false; 482 488 483 #if !defined(__CFA_NO_STATISTICS__) 489 484 print_stats = 0; … … 584 579 threads{ __get }; 585 580 581 io.arbiter = create(); 582 io.params = io_params; 583 586 584 doregister(this); 587 585 … … 596 594 ready_mutate_unlock( last_size ); 597 595 enable_interrupts_noPoll(); // Don't poll, could be in main cluster 598 599 600 this.io.cnt = num_io;601 this.io.ctxs = aalloc(num_io);602 for(i; this.io.cnt) {603 (this.io.ctxs[i]){ this, io_params };604 }605 596 } 606 597 607 598 void ^?{}(cluster & this) { 608 for(i; this.io.cnt) { 609 ^(this.io.ctxs[i]){ true }; 610 } 611 free(this.io.ctxs); 599 destroy(this.io.arbiter); 612 600 613 601 // Lock the RWlock so no-one pushes/pops while we are changing the queue
Note: See TracChangeset
for help on using the changeset viewer.