- Timestamp:
- May 17, 2018, 3:25:12 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, with_gc
- Children:
- a83ffa4
- Parents:
- e9a7e90b
- Location:
- src/libcfa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
re9a7e90b rb1a4300 37 37 38 38 void __kernel_set_timer( Duration alarm ) { 39 verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%luns)", alarm.tv); 39 40 setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL ); 40 41 } … … 68 69 } 69 70 70 __cfaabi_dbg_debug_do( bool validate( alarm_list_t * this ) { 71 #if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__)) 72 bool validate( alarm_list_t * this ) { 71 73 alarm_node_t ** it = &this->head; 72 74 while( (*it) ) { … … 75 77 76 78 return it == this->tail; 77 }) 79 } 80 #endif 78 81 79 82 static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) { -
src/libcfa/concurrency/preemption.c
re9a7e90b rb1a4300 91 91 //Loop throught every thing expired 92 92 while( node = get_expired( alarms, currtime ) ) { 93 // __cfaabi_dbg_print_buffer_decl( " KERNEL: preemption tick.\n" ); 93 94 94 95 // Check if this is a kernel … … 103 104 Duration period = node->period; 104 105 if( period > 0 ) { 106 // __cfaabi_dbg_print_buffer_local( " KERNEL: alarm period is %lu.\n", period.tv ); 105 107 node->alarm = currtime + period; // Alarm is periodic, add currtime to it (used cached current time) 106 108 insert( alarms, node ); // Reinsert the node for the next time it triggers … … 112 114 113 115 // If there are still alarms pending, reset the timer 114 if( alarms->head ) { __kernel_set_timer( alarms->head->alarm - currtime ); } 116 if( alarms->head ) { 117 __cfaabi_dbg_print_buffer_decl( " KERNEL: @%lu(%lu) resetting alarm to %lu.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv); 118 Duration delta = alarms->head->alarm - currtime; 119 Duration caped = max(delta, 50`us); 120 // itimerval tim = { caped }; 121 // __cfaabi_dbg_print_buffer_local( " Values are %lu, %lu, %lu %lu.\n", delta.tv, caped.tv, tim.it_value.tv_sec, tim.it_value.tv_usec); 122 123 __kernel_set_timer( caped ); 124 } 115 125 } 116 126 … … 335 345 if( !preemption_ready() ) { return; } 336 346 337 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p ).\n", kernelTLS.this_processor, kernelTLS.this_thread);347 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", kernelTLS.this_processor, kernelTLS.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) ); 338 348 339 349 // Sync flag : prevent recursive calls to the signal handler … … 377 387 case EAGAIN : 378 388 case EINTR : 389 {__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );} 379 390 continue; 380 391 case EINVAL : -
src/libcfa/time
re9a7e90b rb1a4300 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // time -- 8 // 6 // 7 // time -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Mar 14 23:18:57 2018 … … 12 12 // Last Modified On : Sat Apr 14 17:48:23 2018 13 13 // Update Count : 636 14 // 14 // 15 15 16 16 #pragma once … … 91 91 static inline int64_t ?`w( Duration dur ) { return dur.tv / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); } 92 92 93 static inline Duration max( Duration lhs, Duration rhs ) { return (lhs.tv < rhs.tv) ? rhs : lhs;} 94 static inline Duration min( Duration lhs, Duration rhs ) { return !(rhs.tv < lhs.tv) ? lhs : rhs;} 95 93 96 94 97 //######################### C timeval #########################
Note: See TracChangeset
for help on using the changeset viewer.