source: src/libcfa/concurrency/alarm.h@ 5688056

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 5688056 was 8cb529e, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

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

  • Property mode set to 100644
File size: 2.3 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>
[8cb529e]21#include <stdint.h>
[c81ebf9]22
[6cff9f3]23#include "assert"
24
[8cb529e]25typedef uint64_t __cfa_time_t;
[6cff9f3]26
27struct thread_desc;
28struct processor;
29
[c81ebf9]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
[6cff9f3]43struct alarm_node_t {
[c81ebf9]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
[6cff9f3]47
48 union {
49 thread_desc * thrd; // thrd who created event
50 processor * proc; // proc who created event
51 };
[c81ebf9]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
[6cff9f3]55};
56
57typedef alarm_node_t ** __alarm_it_t;
58
[c81ebf9]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 );
[6cff9f3]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
[c81ebf9]76void register_self ( alarm_node_t * this );
77void unregister_self( alarm_node_t * this );
78
[6cff9f3]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.