Changeset 8cb529e for src/libcfa/concurrency
- Timestamp:
- Jul 14, 2017, 12:20:57 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- eb2fe4f
- Parents:
- 4ec769c
- Location:
- src/libcfa/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
r4ec769c r8cb529e 43 43 44 44 void __kernel_set_timer( __cfa_time_t alarm ) { 45 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : set timer to %l u\n", (__cfa_time_t)alarm );45 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Kernel : set timer to %llu\n", (__cfa_time_t)alarm ); 46 46 itimerval val; 47 47 val.it_value.tv_sec = alarm / TIMEGRAN; // seconds 48 val.it_value.tv_usec = (alarm % TIMEGRAN) / ( TIMEGRAN / 1_000_000L); // microseconds48 val.it_value.tv_usec = max( (alarm % TIMEGRAN) / ( TIMEGRAN / 1_000_000L ), 1000 ); // microseconds 49 49 val.it_interval.tv_sec = 0; 50 50 val.it_interval.tv_usec = 0; -
src/libcfa/concurrency/alarm.h
r4ec769c r8cb529e 19 19 20 20 #include <stdbool.h> 21 #include <stdint.h> 21 22 22 23 #include "assert" 23 24 24 typedef u nsigned long int __cfa_time_t;25 typedef uint64_t __cfa_time_t; 25 26 26 27 struct thread_desc; -
src/libcfa/concurrency/preemption.c
r4ec769c r8cb529e 66 66 67 67 void tick_preemption() { 68 // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Ticking preemption\n" );69 70 68 alarm_list_t * alarms = &systemProcessor->alarms; 71 69 __cfa_time_t currtime = __kernel_get_time(); 70 71 // LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Ticking preemption @ %llu\n", currtime ); 72 72 while( alarms->head && alarms->head->alarm < currtime ) { 73 73 alarm_node_t * node = pop(alarms); … … 83 83 verify( validate( alarms ) ); 84 84 85 if( node->period > 0 ) { 86 node->alarm = currtime + node->period; 85 __cfa_time_t period = node->period; 86 if( period > 0 ) { 87 node->alarm = currtime + period; 88 // LIB_DEBUG_PRINT_BUFFER_LOCAL( STDERR_FILENO, "Reinsert %p @ %llu (%llu + %llu)\n", node, node->alarm, currtime, period ); 87 89 insert( alarms, node ); 88 90 } … … 101 103 102 104 void update_preemption( processor * this, __cfa_time_t duration ) { 103 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : %p updating preemption to %l u\n", this, duration );105 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, "Processor : %p updating preemption to %llu\n", this, duration ); 104 106 105 107 alarm_node_t * alarm = this->preemption_alarm; … … 273 275 siginfo_t info; 274 276 int sig = sigwaitinfo( &mask, &info ); 275 if( sig < 0 ) {276 abortf( "internal error, sigwait" ); 277 }278 else if( sig == SIGALRM)277 assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int); 278 279 LIB_DEBUG_PRINT_SAFE("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int ); 280 switch( info.si_code ) 279 281 { 280 LIB_DEBUG_PRINT_SAFE("Kernel : Caught signal %d (%d)\n", sig, info.si_value.sival_int ); 281 if( info.si_value.sival_int == 0 ) 282 { 283 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n"); 284 lock( &systemProcessor->alarm_lock DEBUG_CTX2 ); 285 tick_preemption(); 286 unlock( &systemProcessor->alarm_lock ); 287 } 288 else if( info.si_value.sival_int == 1 ) 289 { 290 break; 291 } 292 } 293 else 294 { 295 LIB_DEBUG_PRINT_SAFE("Kernel : Unexpected signal %d (%d)\n", sig, info.si_value.sival_int); 296 } 297 } 298 282 case SI_TIMER: 283 case SI_KERNEL: 284 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n"); 285 lock( &systemProcessor->alarm_lock DEBUG_CTX2 ); 286 tick_preemption(); 287 unlock( &systemProcessor->alarm_lock ); 288 break; 289 case SI_QUEUE: 290 goto EXIT; 291 } 292 } 293 294 EXIT: 299 295 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n"); 300 296 return NULL;
Note: See TracChangeset
for help on using the changeset viewer.