Subversion Repositories shark

Rev

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

Rev Author Line No. Line
2 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
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/*
22
 * Copyright (C) 2000 Massimiliano Giorgi
23
 *
24
 * This program is free software; you can redistribute it and/or modify
25
 * it under the terms of the GNU General Public License as published by
26
 * the Free Software Foundation; either version 2 of the License, or
27
 * (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37
 *
38
 */
39
 
40
/*
671 giacomo 41
 * CVS :        $Id: bd_edf.c,v 1.3 2004-05-25 10:02:01 giacomo Exp $
2 pj 42
 *
43
 * File:        $File$
671 giacomo 44
 * Revision:    $Revision: 1.3 $
45
 * Last update: $Date: 2004-05-25 10:02:01 $
2 pj 46
 */
47
 
48
#include <modules/bd_edf.h>
49
 
50
#include <ll/ll.h>
51
#include <ll/string.h>
52
#include <ll/stdio.h>
53
#include <kernel/const.h>
54
#include <sys/types.h>
55
#include <kernel/var.h>
56
#include <kernel/func.h>
57
#include <kernel/assert.h>
58
 
59
static int mylevel=-1;
60
 
61
typedef struct TAGbd_edf_resource_des
62
{
63
  resource_des rd;
64
  TIME dl[MAX_PROC];
65
} bd_edf_resource_des;
66
 
38 pj 67
static int res_register(RLEVEL l, PID p, RES_MODEL *r)
2 pj 68
{
69
  bd_edf_resource_des *m=(bd_edf_resource_des*)(resource_table[l]);
38 pj 70
  BDEDF_RES_MODEL *rm;
71
 
72
  if (r->rclass!=BDEDF_RCLASS)
73
    return -1;
74
  if (r->level && r->level !=l)
75
    return -1;
76
 
77
  rm=(BDEDF_RES_MODEL*)r;
2 pj 78
  assertk(mylevel==l);
79
  m->dl[p]=rm->dl;
38 pj 80
 
81
  return 0;
2 pj 82
}
83
 
84
static void res_detach(RLEVEL l, PID p)
85
{
86
  bd_edf_resource_des *m=(bd_edf_resource_des*)(resource_table[l]);
87
  assertk(mylevel==l);
88
  m->dl[p]=0;
89
}
90
 
38 pj 91
RLEVEL BD_EDF_register_module(void)
2 pj 92
{
93
  RLEVEL l;
94
  bd_edf_resource_des *m;
95
  int i;
96
 
97
  /* request an entry in the level_table */
98
  l=resource_alloc_descriptor();
99
 
100
  /* alloc the space needed for the EDF_level_des */
101
  m=(bd_edf_resource_des*)kern_alloc(sizeof(bd_edf_resource_des));
102
 
103
  /* update the level_table with the new entry */
104
  resource_table[l]=(resource_des*)m;
105
 
106
  /* fill the resource_des descriptor */
107
  m->rd.rtype=DEFAULT_RTYPE;
108
  m->rd.res_register=res_register;
109
  m->rd.res_detach=res_detach;
110
 
111
  for (i=0;i<MAX_PROC;i++) m->dl[i]=MAX_TIME;
112
 
113
  assertk(mylevel==-1);
114
  mylevel=l;
38 pj 115
 
116
  return l;
2 pj 117
}
118
 
119
TIME bd_edf_getdl(void)
120
{
121
  bd_edf_resource_des *m;
122
  if (mylevel==-1) return MAX_TIME;
123
  m=(bd_edf_resource_des*)(resource_table[mylevel]);
124
  if (m->dl[exec_shadow]==MAX_TIME) return MAX_TIME;
125
  return m->dl[exec_shadow]+sys_gettime(NULL);
126
}