- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/startup.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
rd874f59 r7dd98b6 100 100 // Other Forward Declarations 101 101 extern void __wake_proc(processor *); 102 extern int cfa_main_returned; // from interpose.cfa 102 103 103 104 //----------------------------------------------------------------------------- … … 200 201 __cfadbg_print_safe(runtime_core, "Kernel : Main cluster ready\n"); 201 202 203 // Construct the processor context of the main processor 204 void ?{}(processorCtx_t & this, processor * proc) { 205 (this.__cor){ "Processor" }; 206 this.__cor.starter = 0p; 207 this.proc = proc; 208 } 209 210 void ?{}(processor & this) with( this ) { 211 ( this.terminated ){}; 212 ( this.runner ){}; 213 init( this, "Main Processor", *mainCluster, 0p ); 214 kernel_thread = pthread_self(); 215 216 runner{ &this }; 217 __cfadbg_print_safe(runtime_core, "Kernel : constructed main processor context %p\n", &runner); 218 } 219 220 // Initialize the main processor and the main processor ctx 221 // (the coroutine that contains the processing control flow) 222 mainProcessor = (processor *)&storage_mainProcessor; 223 (*mainProcessor){}; 224 225 register_tls( mainProcessor ); 226 202 227 // Start by initializing the main thread 203 228 // SKULLDUGGERY: the mainThread steals the process main thread … … 210 235 __cfadbg_print_safe(runtime_core, "Kernel : Main thread ready\n"); 211 236 212 213 214 // Construct the processor context of the main processor215 void ?{}(processorCtx_t & this, processor * proc) {216 (this.__cor){ "Processor" };217 this.__cor.starter = 0p;218 this.proc = proc;219 }220 221 void ?{}(processor & this) with( this ) {222 ( this.terminated ){};223 ( this.runner ){};224 init( this, "Main Processor", *mainCluster, 0p );225 kernel_thread = pthread_self();226 227 runner{ &this };228 __cfadbg_print_safe(runtime_core, "Kernel : constructed main processor context %p\n", &runner);229 }230 231 // Initialize the main processor and the main processor ctx232 // (the coroutine that contains the processing control flow)233 mainProcessor = (processor *)&storage_mainProcessor;234 (*mainProcessor){};235 236 register_tls( mainProcessor );237 mainThread->last_cpu = __kernel_getcpu();238 239 237 //initialize the global state variables 240 238 __cfaabi_tls.this_processor = mainProcessor; … … 252 250 // Add the main thread to the ready queue 253 251 // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread 254 schedule_thread$(mainThread );252 schedule_thread$(mainThread, UNPARK_LOCAL); 255 253 256 254 // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX … … 271 269 272 270 static void __kernel_shutdown(void) { 271 if(!cfa_main_returned) return; 273 272 /* paranoid */ verify( __preemption_enabled() ); 274 273 disable_interrupts(); … … 486 485 link.next = 0p; 487 486 link.ts = -1llu; 488 preferred = -1u;487 preferred = ready_queue_new_preferred(); 489 488 last_proc = 0p; 490 489 #if defined( __CFA_WITH_VERIFY__ )
Note:
See TracChangeset
for help on using the changeset viewer.