Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1663 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/**
20
 ------------
21
 CVS :        $Id: mymod.c,v 1.1 2004-07-05 14:17:12 pj Exp $
22
 
23
 File:        $File$
24
 Revision:    $Revision: 1.1 $
25
 Last update: $Date: 2004-07-05 14:17:12 $
26
 ------------
27
**/
28
 
29
/*
30
 * Copyright (C) 2001 by Paolo Gai
31
 *
32
 * This program is free software; you can redistribute it and/or modify
33
 * it under the terms of the GNU General Public License as published by
34
 * the Free Software Foundation; either version 2 of the License, or
35
 * (at your option) any later version.
36
 *
37
 * This program is distributed in the hope that it will be useful,
38
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40
 * GNU General Public License for more details.
41
 *
42
 * You should have received a copy of the GNU General Public License
43
 * along with this program; if not, write to the Free Software
44
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45
 *
46
 */
47
 
48
 
49
#include "mymod.h"
50
#include <ll/string.h>
51
#include <kernel/model.h>
52
#include <kernel/descr.h>
53
#include <kernel/var.h>
54
#include <kernel/func.h>
55
 
56
// other include files if needed
57
 
58
// NOTE: NO GLOBAL OR STATIC VARIABLES!!! 
59
// (put them inside the level descriptor!)
60
 
61
/* Statuses used in the level */
62
#define MYMOD_READY         MODULE_STATUS_BASE    
63
#define MYMOD_WAIT          MODULE_STATUS_BASE+3  
64
#define MYMOD_IDLE          MODULE_STATUS_BASE+4  
65
 
66
/* the level redefinition for the Module */
67
typedef struct {
68
  level_des l;     /* the standard level descriptor          */
69
 
70
  int myvar[100];  /* other local (private) variables of the module */
71
 
72
} MYMOD_level_des;
73
 
74
// example of OSLib event
75
static void MYMOD_timer_deadline(void *par)
76
{
77
  // usually the void *par is a pointer to a structure or a PID
78
  // if it is a PID, you can do that to retrieve it and the correspondent
79
  // level descriptor
80
  PID p = (PID) par;
81
  MYMOD_level_des *lev;
82
 
83
  lev = (MYMOD_level_des *)level_table[proc_table[p].task_level];
84
 
85
  // now you know the PID of the task and the level descriptor
86
  // ... so, you know all the things you need
87
}
88
 
89
static int MYMOD_level_accept_task_model(LEVEL l, TASK_MODEL *m)
90
{
91
  // your code here
92
  return 0; // dummy number
93
}
94
 
95
static int MYMOD_level_accept_guest_model(LEVEL l, TASK_MODEL *m)
96
{
97
  // your code here
98
  return 0; // dummy number
99
}
100
 
101
static void MYMOD_level_status(LEVEL l)
102
{
103
}
104
 
105
/* The scheduler only gets the first task in the queue */
106
static PID MYMOD_level_scheduler(LEVEL l)
107
{
108
  return 0; // dummy number
109
}
110
 
111
/* The on-line guarantee is enabled only if the appropriate flag is set... */
112
static int MYMOD_level_guarantee(LEVEL l, bandwidth_t *freebandwidth)
113
{
114
  return 0; // dummy number
115
}
116
 
117
static int MYMOD_task_create(LEVEL l, PID p, TASK_MODEL *m)
118
{
119
  return 0; // dummy number
120
}
121
 
122
static void MYMOD_task_detach(LEVEL l, PID p)
123
{
124
}
125
 
126
static int MYMOD_task_eligible(LEVEL l, PID p)
127
{
128
  return 0; // dummy number
129
}
130
 
131
static void MYMOD_task_dispatch(LEVEL l, PID p, int nostop)
132
{
133
}
134
 
135
static void MYMOD_task_epilogue(LEVEL l, PID p)
136
{
137
}
138
 
139
static void MYMOD_task_activate(LEVEL l, PID p)
140
{
141
}
142
 
143
static void MYMOD_task_insert(LEVEL l, PID p)
144
{
145
}
146
 
147
static void MYMOD_task_extract(LEVEL l, PID p)
148
{
149
}
150
 
151
static void MYMOD_task_endcycle(LEVEL l, PID p)
152
{
153
}
154
 
155
static void MYMOD_task_end(LEVEL l, PID p)
156
{
157
}
158
 
159
static void MYMOD_task_sleep(LEVEL l, PID p)
160
{
161
}
162
 
163
static void MYMOD_task_delay(LEVEL l, PID p, TIME usdelay)
164
{
165
}
166
 
167
static int MYMOD_guest_create(LEVEL l, PID p, TASK_MODEL *m)
168
{
169
  return 0; // dummy number
170
}
171
 
172
static void MYMOD_guest_detach(LEVEL l, PID p)
173
{
174
}
175
 
176
static void MYMOD_guest_dispatch(LEVEL l, PID p, int nostop)
177
{
178
}
179
 
180
static void MYMOD_guest_epilogue(LEVEL l, PID p)
181
{
182
}
183
 
184
static void MYMOD_guest_activate(LEVEL l, PID p)
185
{
186
}
187
 
188
static void MYMOD_guest_insert(LEVEL l, PID p)
189
{
190
}
191
 
192
static void MYMOD_guest_extract(LEVEL l, PID p)
193
{
194
}
195
 
196
static void MYMOD_guest_endcycle(LEVEL l, PID p)
197
{
198
}
199
 
200
static void MYMOD_guest_end(LEVEL l, PID p)
201
{
202
}
203
 
204
static void MYMOD_guest_sleep(LEVEL l, PID p)
205
{
206
}
207
 
208
static void MYMOD_guest_delay(LEVEL l, PID p, TIME usdelay)
209
{
210
}
211
 
212
 
213
 
214
 
215
/* Registration functions */
216
 
217
/*+ Registration function:
218
    int flags                 the init flags ... see MYMOD.h +*/
219
void MYMOD_register_level(int flags)
220
{
221
  LEVEL l;            /* the level that we register */
222
  MYMOD_level_des *lev;  /* for readableness only */
223
  PID i;              /* a counter */
224
 
225
  /* request an entry in the level_table */
226
  l = level_alloc_descriptor();
227
 
228
  /* alloc the space needed for the MYMOD_level_des */
229
  lev = (MYMOD_level_des *)kern_alloc(sizeof(MYMOD_level_des));
230
 
231
  /* update the level_table with the new entry */
232
  level_table[l] = (level_des *)lev;
233
 
234
  /* fill the standard descriptor */
235
  strncpy(lev->l.level_name,  MYMOD_LEVELNAME, MAX_LEVELNAME);
236
  lev->l.level_code               = MYMOD_LEVEL_CODE;
237
  lev->l.level_version            = MYMOD_LEVEL_VERSION;
238
 
239
  lev->l.level_accept_task_model  = MYMOD_level_accept_task_model;
240
  lev->l.level_accept_guest_model = MYMOD_level_accept_guest_model;
241
  lev->l.level_status             = MYMOD_level_status;
242
  lev->l.level_scheduler          = MYMOD_level_scheduler;
243
  lev->l.level_guarantee          = MYMOD_level_guarantee;
244
 
245
  lev->l.task_create              = MYMOD_task_create;
246
  lev->l.task_detach              = MYMOD_task_detach;
247
  lev->l.task_eligible            = MYMOD_task_eligible;
248
  lev->l.task_dispatch            = MYMOD_task_dispatch;
249
  lev->l.task_epilogue            = MYMOD_task_epilogue;
250
  lev->l.task_activate            = MYMOD_task_activate;
251
  lev->l.task_insert              = MYMOD_task_insert;
252
  lev->l.task_extract             = MYMOD_task_extract;
253
  lev->l.task_endcycle            = MYMOD_task_endcycle;
254
  lev->l.task_end                 = MYMOD_task_end;
255
  lev->l.task_sleep               = MYMOD_task_sleep;
256
  lev->l.task_delay               = MYMOD_task_delay;
257
 
258
  lev->l.guest_create             = MYMOD_guest_create;
259
  lev->l.guest_detach             = MYMOD_guest_detach;
260
  lev->l.guest_dispatch           = MYMOD_guest_dispatch;
261
  lev->l.guest_epilogue           = MYMOD_guest_epilogue;
262
  lev->l.guest_activate           = MYMOD_guest_activate;
263
  lev->l.guest_insert             = MYMOD_guest_insert;
264
  lev->l.guest_extract            = MYMOD_guest_extract;
265
  lev->l.guest_endcycle           = MYMOD_guest_endcycle;
266
  lev->l.guest_end                = MYMOD_guest_end;
267
  lev->l.guest_sleep              = MYMOD_guest_sleep;
268
  lev->l.guest_delay              = MYMOD_guest_delay;
269
 
270
  /* fill the MYMOD descriptor part */
271
  for (i=0; i<100; i++)
272
    lev->myvar[i] = 0;
273
}
274
 
275
/*+ this function will accept or reject tasks during group creation +*/
276
int MYMOD_taskaccepted(PID p)
277
{
278
}
279
 
280
/*+ returns the current total value +*/
281
int MYMOD_getvalue(LEVEL l)
282
{
283
}
284
 
285
 
286
// put here the other interface functions added
287
 
288
 
289
 
290
 
291
/* Interface with the crunch application */
292
 
293
void crunch_register_models(struct multiboot_info *mb);
294
{
295
  // here you can register your scheduling modules
296
}
297
 
298
int crunch_taskaccepted(PID p);
299
{
300
  // here maybe you can call MYMOD_taskaccepted()!!!
301
}
302
 
303
int crunch_getvalue()
304
{
305
  // here just return the accumulated value by the modules you used
306
}
307
 
308