AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
callout.h
Go to the documentation of this file.
1
#ifndef _SYS_CALLOUT_H
2
#define _SYS_CALLOUT_H
3
4
#include <
core/system.h
>
5
6
/*
7
* Callouts (sys/callout.c): functions called later, at a given time. The
8
* caller owns the structure, so arming one allocates nothing and can't
9
* fail.
10
*/
11
13
struct
callout
{
14
uint64_t
when
;
/* when to call it, in arch_rtime_ns() time */
15
void (*
fn
)(
void
*
arg
);
16
void
*
arg
;
17
struct
callout
*
next
;
18
struct
callout_list
*
list
;
/* the list it's on, while it's pending */
19
int
pending
;
20
};
21
24
struct
callout_list
{
25
struct
callout
*
head
;
26
};
27
28
/* Calls fn(arg) in `ns` nanoseconds, from the timer's interrupt. A
29
* callout that was armed already moves to the new time. */
30
void
callout_set
(
struct
callout
*c,
uint64_t
ns,
void
(*
fn
)(
void
*),
void
*
arg
);
31
32
/* The same, but called from whoever runs `list` (callout_list_run()). */
33
void
callout_set_on
(
struct
callout_list
*
list
,
struct
callout
*c,
uint64_t
ns,
34
void
(*
fn
)(
void
*),
void
*
arg
);
35
36
/* Disarms a callout, if it wasn't called yet. */
37
void
callout_stop
(
struct
callout
*c);
38
39
/* Calls the callouts of `list` that are due at `now`. */
40
void
callout_list_run
(
struct
callout_list
*
list
,
uint64_t
now);
41
42
/* Returns when the first callout of `list` is due, or 0 if none is
43
* armed. */
44
uint64_t
callout_list_next
(
struct
callout_list
*
list
);
45
46
/* Calls the timer's callouts that are due, on each tick. */
47
void
callout_run
(
uint64_t
now);
48
49
#endif
/* ! _SYS_CALLOUT_H */
callout_set
void callout_set(struct callout *c, uint64_t ns, void(*fn)(void *), void *arg)
Sets a callout on the timer's list: fn(arg) will be called from the timer interrupt once ns ns have p...
Definition
callout.c:74
callout_run
void callout_run(uint64_t now)
Calls the timer's callouts that are due, from the timer interrupt.
Definition
callout.c:131
callout_list_run
void callout_list_run(struct callout_list *list, uint64_t now)
Calls the callouts of a list that are due, taking each off the list first.
Definition
callout.c:86
callout_list_next
uint64_t callout_list_next(struct callout_list *list)
Finds when the first callout of a list is due.
Definition
callout.c:115
callout_stop
void callout_stop(struct callout *c)
Cancels a callout, if it is pending.
Definition
callout.c:23
callout_set_on
void callout_set_on(struct callout_list *list, struct callout *c, uint64_t ns, void(*fn)(void *), void *arg)
Sets a callout on a list: fn(arg) will be called once ns ns have passed, by whoever runs the list.
Definition
callout.c:50
system.h
uint64_t
unsigned long long int uint64_t
Definition
stddef.h:23
callout_list
A list of callouts called from one context: the timer's interrupt (callout_set()),...
Definition
callout.h:24
callout_list::head
struct callout * head
Definition
callout.h:25
callout
A function to call later, with its argument.
Definition
callout.h:13
callout::arg
void * arg
Definition
callout.h:16
callout::fn
void(*) fn(void *arg)
Definition
callout.h:15
callout::list
struct callout_list * list
Definition
callout.h:18
callout::next
struct callout * next
Definition
callout.h:17
callout::when
uint64_t when
Definition
callout.h:14
callout::pending
int pending
Definition
callout.h:19
list
A list: its first and last nodes, and how many there are.
Definition
list.h:37
kernel
include
sys
callout.h
Generated by
1.18.0