Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/alarm.c

    r8ad6533 rb69ea6b  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr  9 13:36:18 2018
    13 // Update Count     : 61
     12// Last Modified On : Fri Jul 21 22:35:18 2017
     13// Update Count     : 1
    1414//
    1515
     
    2626#include "preemption.h"
    2727
     28
     29static 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
     36static 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
    2842//=============================================================================================
    2943// Clock logic
    3044//=============================================================================================
    3145
    32 Time __kernel_get_time() {
     46__cfa_time_t __kernel_get_time() {
    3347        timespec curr;
    34         clock_gettime( CLOCK_MONOTONIC_RAW, &curr );            // CLOCK_REALTIME
    35         return (Time){ curr };
     48        clock_gettime( CLOCK_REALTIME, &curr );
     49        return (__cfa_time_t){ &curr };
    3650}
    3751
    38 void __kernel_set_timer( Duration alarm ) {
    39         setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
     52void __kernel_set_timer( __cfa_time_t alarm ) {
     53        itimerval val = { &alarm };
     54        setitimer( ITIMER_REAL, &val, NULL );
    4055}
    4156
     
    4459//=============================================================================================
    4560
    46 void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) {
     61void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s ) with( this ) {
    4762        this.thrd = thrd;
    4863        this.alarm = alarm;
     
    5368}
    5469
    55 void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period ) with( this ) {
     70void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s ) with( this ) {
    5671        this.proc = proc;
    5772        this.alarm = alarm;
Note: See TracChangeset for help on using the changeset viewer.