Subversion Repositories shark

Rev

Rev 1334 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1333 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *
6
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
7
 *
8
 * http://www.sssup.it
9
 * http://retis.sssup.it
10
 * http://shark.sssup.it
11
 */
12
 
13
#include "chimera.h"
14
 
15
struct action_event *first_action_event = NULL;
16
 
17
int insert_action_event(struct action_event *e) {
18
 
19
  struct action_event *t = first_action_event, *k = NULL;
20
 
21
  SYS_FLAGS f;
22
 
23
  f = kern_fsave();
24
 
1334 giacomo 25
  e->status = EVT_STATUS_WAIT;
26
 
1333 giacomo 27
  if (!t) {
28
 
29
        first_action_event = e;
30
        e->next = NULL;
31
        kern_frestore(f);
32
        return 0;
33
 
34
  }
35
 
36
  while(t) {
37
        if (TIMESPEC_A_LT_B(&e->time,&t->time))
38
                break;
39
        k = t;
40
        t = t->next;
41
  }
42
 
43
  t = k->next;
44
  k->next = e;
45
  e->next = t;
46
 
47
  t = first_action_event;
48
 
49
  kern_frestore(f);
50
 
51
  return 0;
52
 
53
}
54
 
55
int delete_action_event(struct action_event *e) {
56
 
57
  struct action_event *t = first_action_event;
58
 
59
  SYS_FLAGS f;
60
 
61
  if (!t) return -1;
62
 
63
  f = kern_fsave();
64
 
65
  if (t == e) {
66
 
67
        first_action_event = t->next;
68
        kern_frestore(f);
69
        return 0;
70
 
71
  }
72
 
73
  while(t) {
74
        if (t->next == e)
75
                break;
76
        t = t->next;
77
  }
78
 
79
  if (t) {
80
        t->next = e->next;
81
        kern_frestore(f);
82
        return 0;
83
  }        
84
 
85
  kern_frestore(f);
86
 
87
  return -1;
88
 
89
}
90
 
91
struct action_event * get_first_old_event(struct timespec *time) {
92
 
93
  struct action_event *t = first_action_event;
94
  SYS_FLAGS f;
95
 
96
  if (!t) return NULL;
97
 
98
  f = kern_fsave();
99
 
100
  if (TIMESPEC_A_GT_B(time,&(t->time))) {
101
    first_action_event = t->next;
1334 giacomo 102
    t->status = EVT_STATUS_EXEC;
1333 giacomo 103
    kern_frestore(f);
104
    return t;
105
  }
106
 
107
  kern_frestore(f);
108
  return NULL;
109
 
110
}