Changeset ca37445 for src/libcfa/concurrency/alarm.c
- Timestamp:
- Apr 10, 2018, 3:31:07 PM (6 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:
- 33f5b57
- Parents:
- 9d1e3f7 (diff), 8ad6533 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/alarm.c
r9d1e3f7 rca37445 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 : Mon Apr 9 13:36:18 2018 13 // Update Count : 61 14 14 // 15 15 … … 26 26 #include "preemption.h" 27 27 28 29 static inline void ?{}( itimerval & this, __cfa_time_t * alarm ) with( this ) {30 it_value.tv_sec = alarm->val / (1`cfa_s).val; // seconds31 it_value.tv_usec = max( (alarm->val % (1`cfa_s).val) / (1`cfa_us).val, 1000 ); // microseconds32 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;40 }41 42 28 //============================================================================================= 43 29 // Clock logic 44 30 //============================================================================================= 45 31 46 __cfa_time_t__kernel_get_time() {32 Time __kernel_get_time() { 47 33 timespec curr; 48 clock_gettime( CLOCK_ REALTIME, &curr );49 return ( __cfa_time_t){ &curr };34 clock_gettime( CLOCK_MONOTONIC_RAW, &curr ); // CLOCK_REALTIME 35 return (Time){ curr }; 50 36 } 51 37 52 void __kernel_set_timer( __cfa_time_t alarm ) { 53 itimerval val = { &alarm }; 54 setitimer( ITIMER_REAL, &val, NULL ); 38 void __kernel_set_timer( Duration alarm ) { 39 setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL ); 55 40 } 56 41 … … 59 44 //============================================================================================= 60 45 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 ) {46 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) { 62 47 this.thrd = thrd; 63 48 this.alarm = alarm; … … 68 53 } 69 54 70 void ?{}( alarm_node_t & this, processor * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s) with( this ) {55 void ?{}( alarm_node_t & this, processor * proc, Time alarm, Duration period ) with( this ) { 71 56 this.proc = proc; 72 57 this.alarm = alarm;
Note: See TracChangeset
for help on using the changeset viewer.