source: src/libcfa/concurrency/alarm.h @ 2873b737

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 2873b737 was c81ebf9, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

More work done on preemption in cforall, next step disabling interrupts at the correct places

  • Property mode set to 100644
File size: 2.2 KB
Line 
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
20#include <stdbool.h>
21
22#include "assert"
23
24typedef unsigned long int __cfa_time_t;
25
26struct thread_desc;
27struct processor;
28
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
42struct alarm_node_t {
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
46
47        union {
48                thread_desc * thrd;     // thrd who created event
49                processor * proc;               // proc who created event
50        };
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
54};
55
56typedef alarm_node_t ** __alarm_it_t;
57
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 );
61
62struct alarm_list_t {
63        alarm_node_t * head;
64        __alarm_it_t tail;
65};
66
67static inline void ?{}( alarm_list_t * this ) {
68        this->head = 0;
69        this->tail = &this->head;
70}
71
72void insert( alarm_list_t * this, alarm_node_t * n );
73alarm_node_t * pop( alarm_list_t * this );
74
75void register_self  ( alarm_node_t * this );
76void unregister_self( alarm_node_t * this );
77
78#endif
79
80// Local Variables: //
81// mode: CFA //
82// tab-width: 6 //
83// End: //
Note: See TracBrowser for help on using the repository browser.