Rev 1333 | Go to most recent revision | Details | Compare with Previous | 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 | |||
1334 | giacomo | 46 | e->status = EVT_STATUS_WAIT; |
47 | |||
1333 | giacomo | 48 | if (!t) { |
49 | |||
50 | first_action_event = e; |
||
51 | e->next = NULL; |
||
52 | kern_frestore(f); |
||
53 | return 0; |
||
54 | |||
55 | } |
||
56 | |||
57 | while(t) { |
||
58 | if (TIMESPEC_A_LT_B(&e->time,&t->time)) |
||
59 | break; |
||
60 | k = t; |
||
61 | t = t->next; |
||
62 | } |
||
63 | |||
64 | t = k->next; |
||
65 | k->next = e; |
||
66 | e->next = t; |
||
67 | |||
68 | t = first_action_event; |
||
69 | |||
70 | kern_frestore(f); |
||
71 | |||
72 | return 0; |
||
73 | |||
74 | } |
||
75 | |||
76 | int delete_action_event(struct action_event *e) { |
||
77 | |||
78 | struct action_event *t = first_action_event; |
||
79 | |||
80 | SYS_FLAGS f; |
||
81 | |||
82 | if (!t) return -1; |
||
83 | |||
84 | f = kern_fsave(); |
||
85 | |||
86 | if (t == e) { |
||
87 | |||
88 | first_action_event = t->next; |
||
89 | kern_frestore(f); |
||
90 | return 0; |
||
91 | |||
92 | } |
||
93 | |||
94 | while(t) { |
||
95 | if (t->next == e) |
||
96 | break; |
||
97 | t = t->next; |
||
98 | } |
||
99 | |||
100 | if (t) { |
||
101 | t->next = e->next; |
||
102 | kern_frestore(f); |
||
103 | return 0; |
||
104 | } |
||
105 | |||
106 | kern_frestore(f); |
||
107 | |||
108 | return -1; |
||
109 | |||
110 | } |
||
111 | |||
112 | struct action_event * get_first_old_event(struct timespec *time) { |
||
113 | |||
114 | struct action_event *t = first_action_event; |
||
115 | SYS_FLAGS f; |
||
116 | |||
117 | if (!t) return NULL; |
||
118 | |||
119 | f = kern_fsave(); |
||
120 | |||
121 | if (TIMESPEC_A_GT_B(time,&(t->time))) { |
||
122 | first_action_event = t->next; |
||
1334 | giacomo | 123 | t->status = EVT_STATUS_EXEC; |
1333 | giacomo | 124 | kern_frestore(f); |
125 | return t; |
||
126 | } |
||
127 | |||
128 | kern_frestore(f); |
||
129 | return NULL; |
||
130 | |||
131 | } |