Changeset 2a84d06d for src/libcfa/concurrency/alarm.c
- Timestamp:
- Mar 27, 2018, 5:22:58 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:
- 43725bd
- Parents:
- af1ed1ad
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
raf1ed1ad r2a84d06d 10 10 // Created On : Fri Jun 2 11:31:25 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 22:35:18 201713 // Update Count : 112 // Last Modified On : Tue Mar 27 14:12:11 2018 13 // Update Count : 41 14 14 // 15 15 … … 27 27 28 28 29 static inline void ?{}( itimerval & this, __cfa_time_t * alarm ) with( this ) { 30 it_value.tv_sec = alarm->val / (1`cfa_s).val; // seconds 31 it_value.tv_usec = max( (alarm->val % (1`cfa_s).val) / (1`cfa_us).val, 1000 ); // microseconds 32 it_interval.tv_sec = 0; 33 it_interval.tv_usec = 0; 34 } 35 36 static inline void ?{}( __cfa_time_t & this, timespec * curr ) { 37 uint64_t secs = curr->tv_sec; 38 uint64_t nsecs = curr->tv_nsec; 39 this.val = from_s(secs).val + nsecs; 29 static inline void ?{}( itimerval & this, Duration alarm ) with( this ) { 30 it_value { alarm }; // seconds, microseconds 31 it_interval{ 0 }; 40 32 } 41 33 … … 44 36 //============================================================================================= 45 37 46 __cfa_time_t__kernel_get_time() {38 Time __kernel_get_time() { 47 39 timespec curr; 48 clock_gettime( CLOCK_ REALTIME, &curr );49 return ( __cfa_time_t){ &curr };40 clock_gettime( CLOCK_MONOTONIC_RAW, &curr ); // CLOCK_REALTIME 41 return (Time){ curr }; 50 42 } 51 43 52 void __kernel_set_timer( __cfa_time_t alarm ) { 53 itimerval val = { &alarm }; 54 setitimer( ITIMER_REAL, &val, NULL ); 44 void __kernel_set_timer( Duration alarm ) { 45 setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL ); 55 46 } 56 47 … … 59 50 //============================================================================================= 60 51 61 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s) with( this ) {52 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) { 62 53 this.thrd = thrd; 63 54 this.alarm = alarm; … … 68 59 } 69 60 70 void ?{}( alarm_node_t & this, processor * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s) with( this ) {61 void ?{}( alarm_node_t & this, processor * proc, Time alarm, Duration period ) with( this ) { 71 62 this.proc = proc; 72 63 this.alarm = alarm;
Note: See TracChangeset
for help on using the changeset viewer.