source: src/libcfa/concurrency/alarm.h @ 242a902

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 242a902 was 242a902, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Convert more library files to use references

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[6cff9f3]1//                              -*- Mode: CFA -*-
2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
8// alarm.h --
9//
10// Author           : Thierry Delisle
11// Created On       : Fri Jun 2 11:31:25 2017
12// Last Modified By : Thierry Delisle
13// Last Modified On : --
14// Update Count     : 0
15//
16
17#ifndef ALARM_H
18#define ALARM_H
19
[c81ebf9]20#include <stdbool.h>
21
[6cff9f3]22#include "assert"
23
[c81ebf9]24typedef unsigned long int __cfa_time_t;
[6cff9f3]25
26struct thread_desc;
27struct processor;
28
[c81ebf9]29//=============================================================================================
30// Clock logic
31//=============================================================================================
32
33#define TIMEGRAN 1_000_000_000L                         // nanosecond granularity, except for timeval
34
35__cfa_time_t __kernel_get_time();
36void __kernel_set_timer( __cfa_time_t alarm );
37
38//=============================================================================================
39// Alarm logic
40//=============================================================================================
41
[6cff9f3]42struct alarm_node_t {
[c81ebf9]43        __cfa_time_t alarm;             // time when alarm goes off
44        __cfa_time_t period;            // if > 0 => period of alarm
45        alarm_node_t * next;            // intrusive link list field
[6cff9f3]46
47        union {
48                thread_desc * thrd;     // thrd who created event
49                processor * proc;               // proc who created event
50        };
[c81ebf9]51
52        bool set                :1;             // whether or not the alarm has be registered
53        bool kernel_alarm       :1;             // true if this is not a user defined alarm
[6cff9f3]54};
55
56typedef alarm_node_t ** __alarm_it_t;
57
[242a902]58void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
59void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
60void ^?{}( alarm_node_t & this );
[6cff9f3]61
62struct alarm_list_t {
63        alarm_node_t * head;
64        __alarm_it_t tail;
65};
66
[242a902]67static inline void ?{}( alarm_list_t & this ) {
68        this.head = 0;
69        this.tail = &this.head;
[6cff9f3]70}
71
72void insert( alarm_list_t * this, alarm_node_t * n );
73alarm_node_t * pop( alarm_list_t * this );
74
[c81ebf9]75void register_self  ( alarm_node_t * this );
76void unregister_self( alarm_node_t * this );
77
[6cff9f3]78#endif
79
80// Local Variables: //
81// mode: CFA //
82// tab-width: 6 //
[242a902]83// End: //
Note: See TracBrowser for help on using the repository browser.