41f85acefc739c1c31869ca5c857db20bd7abe5e
[akaros.git] / kern / include / devalarm.h
1 /* Copyright (c) 2013 The Regents of the University of California
2  * Barret Rhoden <brho@cs.berkeley.edu>
3  * See LICENSE for details.
4  *
5  * Alarm device includes (needed for the linkage to struct proc) */
6
7 #pragma once
8
9 #include <sys/queue.h>
10 #include <kref.h>
11 #include <alarm.h>
12 #include <atomic.h>
13 #include <fdtap.h>
14 #include <rendez.h>
15
16 struct proc_alarm {
17         TAILQ_ENTRY(proc_alarm)         link;
18         int                                                     id;
19         bool                                            armed;
20         bool                                            should_stop;
21         struct kref                                     kref;
22         struct alarm_waiter                     a_waiter;
23         struct cond_var                         cv;
24         struct proc                                     *proc;
25         struct fdtap_slist                      fd_taps;
26         unsigned long                           period;
27         unsigned long                           count;
28 };
29 TAILQ_HEAD(proc_alarm_list, proc_alarm);
30
31 struct proc_alarm_set {
32         struct proc_alarm_list          list;
33         spinlock_t                                      lock;
34         struct timer_chain                      *tchain;
35         int                                                     id_counter;
36 };
37
38 void devalarm_init(struct proc *p);