Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1333 | giacomo | 1 | |
2 | /* |
||
3 | * Project: S.Ha.R.K. |
||
4 | * |
||
5 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * |
||
7 | * |
||
8 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
9 | * |
||
10 | * http://www.sssup.it |
||
11 | * http://retis.sssup.it |
||
12 | * http://shark.sssup.it |
||
13 | */ |
||
14 | |||
15 | /* |
||
16 | * Copyright (C) 2000 Paolo Gai |
||
17 | * |
||
18 | * This program is free software; you can redistribute it and/or modify |
||
19 | * it under the terms of the GNU General Public License as published by |
||
20 | * the Free Software Foundation; either version 2 of the License, or |
||
21 | * (at your option) any later version. |
||
22 | * |
||
23 | * This program is distributed in the hope that it will be useful, |
||
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
26 | * GNU General Public License for more details. |
||
27 | * |
||
28 | * You should have received a copy of the GNU General Public License |
||
29 | * along with this program; if not, write to the Free Software |
||
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
31 | * |
||
32 | */ |
||
33 | |||
34 | #include "chimera.h" |
||
35 | |||
36 | struct action_event *first_action_event = NULL; |
||
37 | |||
38 | int insert_action_event(struct action_event *e) { |
||
39 | |||
40 | struct action_event *t = first_action_event, *k = NULL; |
||
41 | |||
42 | SYS_FLAGS f; |
||
43 | |||
44 | f = kern_fsave(); |
||
45 | |||
46 | if (!t) { |
||
47 | |||
48 | first_action_event = e; |
||
49 | e->next = NULL; |
||
50 | kern_frestore(f); |
||
51 | return 0; |
||
52 | |||
53 | } |
||
54 | |||
55 | while(t) { |
||
56 | if (TIMESPEC_A_LT_B(&e->time,&t->time)) |
||
57 | break; |
||
58 | k = t; |
||
59 | t = t->next; |
||
60 | } |
||
61 | |||
62 | t = k->next; |
||
63 | k->next = e; |
||
64 | e->next = t; |
||
65 | |||
66 | t = first_action_event; |
||
67 | |||
68 | while(t) { |
||
69 | cprintf("Time %d:%d\n",t->time.tv_sec,t->time.tv_nsec); |
||
70 | t = t->next; |
||
71 | } |
||
72 | |||
73 | kern_frestore(f); |
||
74 | |||
75 | return 0; |
||
76 | |||
77 | } |
||
78 | |||
79 | int delete_action_event(struct action_event *e) { |
||
80 | |||
81 | struct action_event *t = first_action_event; |
||
82 | |||
83 | SYS_FLAGS f; |
||
84 | |||
85 | if (!t) return -1; |
||
86 | |||
87 | f = kern_fsave(); |
||
88 | |||
89 | if (t == e) { |
||
90 | |||
91 | first_action_event = t->next; |
||
92 | kern_frestore(f); |
||
93 | return 0; |
||
94 | |||
95 | } |
||
96 | |||
97 | while(t) { |
||
98 | if (t->next == e) |
||
99 | break; |
||
100 | t = t->next; |
||
101 | } |
||
102 | |||
103 | if (t) { |
||
104 | t->next = e->next; |
||
105 | kern_frestore(f); |
||
106 | return 0; |
||
107 | } |
||
108 | |||
109 | kern_frestore(f); |
||
110 | |||
111 | return -1; |
||
112 | |||
113 | } |
||
114 | |||
115 | struct action_event * get_first_old_event(struct timespec *time) { |
||
116 | |||
117 | struct action_event *t = first_action_event; |
||
118 | SYS_FLAGS f; |
||
119 | |||
120 | if (!t) return NULL; |
||
121 | |||
122 | f = kern_fsave(); |
||
123 | |||
124 | if (TIMESPEC_A_GT_B(time,&(t->time))) { |
||
125 | first_action_event = t->next; |
||
126 | kern_frestore(f); |
||
127 | return t; |
||
128 | } |
||
129 | |||
130 | kern_frestore(f); |
||
131 | return NULL; |
||
132 | |||
133 | } |