Changes in src/libcfa/concurrency/kernel.c [e60e0dc:d6ff3ff]
- File:
-
- 1 edited
-
src/libcfa/concurrency/kernel.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel.c
re60e0dc rd6ff3ff 47 47 KERNEL_STORAGE(cluster, systemCluster); 48 48 KERNEL_STORAGE(system_proc_t, systemProcessor); 49 KERNEL_STORAGE(event_kernel_t, event_kernel);50 49 KERNEL_STORAGE(thread_desc, mainThread); 51 50 KERNEL_STORAGE(machine_context_t, mainThreadCtx); … … 53 52 cluster * systemCluster; 54 53 system_proc_t * systemProcessor; 55 event_kernel_t * event_kernel;56 54 thread_desc * mainThread; 57 55 … … 133 131 this->cltr = cltr; 134 132 (&this->terminated){ 0 }; 135 this-> do_terminate= false;133 this->is_terminated = false; 136 134 this->preemption_alarm = NULL; 135 this->preemption = default_preemption(); 137 136 this->pending_preemption = false; 138 137 … … 143 142 this->cltr = cltr; 144 143 (&this->terminated){ 0 }; 145 this-> do_terminate= false;144 this->is_terminated = false; 146 145 this->preemption_alarm = NULL; 146 this->preemption = default_preemption(); 147 147 this->pending_preemption = false; 148 148 this->kernel_thread = pthread_self(); … … 156 156 157 157 void ?{}(system_proc_t * this, cluster * cltr, processorCtx_t * runner) { 158 (&this->alarms){}; 159 (&this->alarm_lock){}; 160 this->pending_alarm = false; 161 158 162 (&this->proc){ cltr, runner }; 159 }160 161 void ?{}(event_kernel_t * this) {162 (&this->alarms){};163 (&this->lock){};164 163 165 164 verify( validate( &this->alarms ) ); … … 167 166 168 167 void ^?{}(processor * this) { 169 if( ! this-> do_terminate) {168 if( ! this->is_terminated ) { 170 169 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", this); 171 this-> do_terminate= true;170 this->is_terminated = true; 172 171 P( &this->terminated ); 173 172 pthread_join( this->kernel_thread, NULL ); … … 177 176 void ?{}(cluster * this) { 178 177 ( &this->ready_queue ){}; 179 ( &this->ready_queue_lock ){}; 180 181 this->preemption = default_preemption(); 178 ( &this->lock ){}; 182 179 } 183 180 … … 202 199 203 200 thread_desc * readyThread = NULL; 204 for( unsigned int spin_count = 0; ! this-> do_terminate; spin_count++ )201 for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ ) 205 202 { 206 203 readyThread = nextThread( this->cltr ); … … 346 343 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); 347 344 348 lock( &systemProcessor->proc.cltr-> ready_queue_lock DEBUG_CTX2 );345 lock( &systemProcessor->proc.cltr->lock DEBUG_CTX2 ); 349 346 append( &systemProcessor->proc.cltr->ready_queue, thrd ); 350 unlock( &systemProcessor->proc.cltr-> ready_queue_lock );347 unlock( &systemProcessor->proc.cltr->lock ); 351 348 352 349 verify( disable_preempt_count > 0 ); … … 355 352 thread_desc * nextThread(cluster * this) { 356 353 verify( disable_preempt_count > 0 ); 357 lock( &this-> ready_queue_lock DEBUG_CTX2 );354 lock( &this->lock DEBUG_CTX2 ); 358 355 thread_desc * head = pop_head( &this->ready_queue ); 359 unlock( &this-> ready_queue_lock );356 unlock( &this->lock ); 360 357 verify( disable_preempt_count > 0 ); 361 358 return head; … … 473 470 systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtxStorage }; 474 471 475 // Initialize the event kernel476 event_kernel = (event_kernel_t *)&event_kernelStorage;477 event_kernel{};478 479 472 // Add the main thread to the ready queue 480 473 // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread … … 511 504 // When its coroutine terminates, it return control to the mainThread 512 505 // which is currently here 513 systemProcessor->proc. do_terminate= true;506 systemProcessor->proc.is_terminated = true; 514 507 suspend(); 515 508
Note:
See TracChangeset
for help on using the changeset viewer.