source: src/libcfa/concurrency/alarm.h @ 8cb529e

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 8cb529e was 8cb529e, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Preemption now properly(?) use si_code in addition to si_value

  • Property mode set to 100644
File size: 2.3 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#include <stdint.h>
22
23#include "assert"
24
25typedef uint64_t __cfa_time_t;
26
27struct thread_desc;
28struct processor;
29
30//=============================================================================================
31// Clock logic
32//=============================================================================================
33
34#define TIMEGRAN 1_000_000_000L                         // nanosecond granularity, except for timeval
35
36__cfa_time_t __kernel_get_time();
37void __kernel_set_timer( __cfa_time_t alarm );
38
39//=============================================================================================
40// Alarm logic
41//=============================================================================================
42
43struct alarm_node_t {
44        __cfa_time_t alarm;             // time when alarm goes off
45        __cfa_time_t period;            // if > 0 => period of alarm
46        alarm_node_t * next;            // intrusive link list field
47
48        union {
49                thread_desc * thrd;     // thrd who created event
50                processor * proc;               // proc who created event
51        };
52
53        bool set                :1;             // whether or not the alarm has be registered
54        bool kernel_alarm       :1;             // true if this is not a user defined alarm
55};
56
57typedef alarm_node_t ** __alarm_it_t;
58
59void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
60void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
61void ^?{}( alarm_node_t * this );
62
63struct alarm_list_t {
64        alarm_node_t * head;
65        __alarm_it_t tail;
66};
67
68static inline void ?{}( alarm_list_t * this ) {
69        this->head = 0;
70        this->tail = &this->head;
71}
72
73void insert( alarm_list_t * this, alarm_node_t * n );
74alarm_node_t * pop( alarm_list_t * this );
75
76void register_self  ( alarm_node_t * this );
77void unregister_self( alarm_node_t * this );
78
79#endif
80
81// Local Variables: //
82// mode: CFA //
83// tab-width: 6 //
84// End: //
Note: See TracBrowser for help on using the repository browser.