Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Paolo Gai <pj@hartik.sssup.it>
6
 *
7
 * Authors     : Marco Caccamo and Paolo Gai
8
 *
9
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
10
 *
11
 * http://www.sssup.it
12
 * http://retis.sssup.it
13
 * http://shark.sssup.it
14
 */
15
 
16
/**
17
 ------------
1123 pj 18
 CVS :        $Id: cbs_ft.h,v 1.2 2003-01-07 17:10:16 pj Exp $
1085 pj 19
 
20
 File:        $File$
1123 pj 21
 Revision:    $Revision: 1.2 $
22
 Last update: $Date: 2003-01-07 17:10:16 $
1085 pj 23
 ------------
24
 
25
 This file contains the server CBS_FT
26
 
27
 Read CBS_FT.h for further details.
28
 
29
**/
30
 
31
/*
32
 * Copyright (C) 2000 Marco Caccamo and Paolo Gai
33
 *
34
 * This program is free software; you can redistribute it and/or modify
35
 * it under the terms of the GNU General Public License as published by
36
 * the Free Software Foundation; either version 2 of the License, or
37
 * (at your option) any later version.
38
 *
39
 * This program is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42
 * GNU General Public License for more details.
43
 *
44
 * You should have received a copy of the GNU General Public License
45
 * along with this program; if not, write to the Free Software
46
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
47
 *
48
 */
49
 
50
#ifndef __CBS_FT__
51
#define __CBS_FT__
52
 
53
 
54
 
55
#include <ll/string.h>
56
#include <kernel/model.h>
57
#include <kernel/descr.h>
58
#include <kernel/var.h>
59
#include <kernel/func.h>
1123 pj 60
#include <kernel/trace.h>
1085 pj 61
 
62
 
63
 
64
 
65
 
66
 
67
/*+ flags... +*/
68
#define CBS_FT_ENABLE_GUARANTEE      1  /*+ Task Guarantee enabled +*/
69
#define CBS_FT_ENABLE_ALL            1
70
 
71
#define CBS_FT_FAILED_GUARANTEE      8  /*+ used in the module, unsettable
72
                                         in EDF_register_level... +*/
73
 
74
 
75
#define PRIMARY 1
76
#define BACKUP 2
77
#define FT_PCLASS 0x0700 // Nuova classe di task, quelli fault_tolerant
78
 
79
#define CBS_FT_LEVELNAME "CBSFT base"
80
#define CBS_FT_LEVEL_CODE 110
81
#define CBS_FT_LEVEL_VERSION 1
82
 
83
 
84
/* The Fault-Tolerant Task model extends the base task model
85
   This model cannot be APERIODIC, only PERIODIC tasks are allowed.
86
   A faut-tolerant application is composed by two different tasks (primary and
87
   backup). The backup task is characterized by its WCET and its type (BACKUP).
88
   The primary task must define the task period, its average execution time
89
   (used as sort of prediction in order to recharge the budget using the
90
   capacity cash queue!), the budget (budget / period = U that is, the
91
   bandwidth assigned to the fault-tolerant application), its type (PRIMARY)
92
   and finally the PID of the corresponding backup task.        */
93
 
94
typedef struct {
95
  TASK_MODEL t;
96
 
97
  TIME wcetB;   // WCET of the backup job (BACKUP TASK ONLY)
98
 
99
  TIME execP;   // average exec. time of the primary job (PRIMARY TASK ONLY)
100
 
101
  TIME period;  // period of the fault-tolerant task (PRIMARY TASK ONLY)
102
 
103
  int  budget;  // amount of guaranteed capacity  (PRIMARY TASK ONLY) 
104
 
105
  char type;    // PRIMARY or BACKUP
106
 
107
  PID backup;   // (PRIMARY TASK ONLY)
108
 
109
} FT_TASK_MODEL;
110
 
111
 
112
#define ft_task_default_model(m)                        \
113
        task_default_model((m).t,FT_PCLASS),            \
114
        (m).period = 0,                                \
115
        (m).wcetB = 0,                                  \
116
        (m).execP = 0,                                   \
117
        (m).budget = 0,                                 \
118
        (m).type = BACKUP,                              \
119
        (m).backup = NIL
120
 
121
#define ft_task_def_level(m,l) task_def_level((m).t,l)
122
#define ft_task_def_arg(m,a)   task_def_arg((m).t,a)
123
#define ft_task_def_stack(m,s) task_def_stack((m).t,s)
124
#define ft_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
125
#define ft_task_def_usemath(m)    task_def_usemath((m).t)
126
#define ft_task_def_ctrl_jet(m)   task_def_ctrl_jet((m).t)
127
#define ft_task_def_group(m,g)   task_def_group((m).t,g)
128
#define ft_task_def_period(m,o) (m).period = (o)
129
#define ft_task_def_budget(m,o)   (m).budget = (o)
130
#define ft_task_def_backup(m)   (m).type = BACKUP
131
#define ft_task_def_primary(m)   (m).type = PRIMARY
132
#define ft_task_def_backup_task(m,b)   (m).backup = b
133
#define ft_task_def_backup_wcet(m,b) (m).wcetB = b
134
#define ft_task_def_primary_exec(m,b) (m).execP = b     
135
 
136
/************************************************************************/
1123 pj 137
LEVEL CBS_FT_register_level(int flags, LEVEL master);
1085 pj 138
 
139
 
140
bandwidth_t CBS_FT_usedbandwidth(LEVEL l);
141
 
142
 
143
 
144
/* This function notifies to a primary task that the task itself has to
145
   suspend its execution (the task has to suspend itself with a
146
   task_endcycle()   */
147
char CBS_FT_Checkpoint(void);
148
 
149
 
150
 
151
/* This function sets the checkpoint flag! hence, at the next checkpoint,
152
   that is:
153
 
154
   if (CBS_FT_Checkpoint()) {
155
       task_endcycle();
156
       continue;
157
   }
158
 
159
   the primary task will suspend itself switching to the backup task */
160
void CBS_FT_Primary_Abort(void);
161
 
162
/***************************************************************************/
163
 
164
 
165
 
166
 
167
#endif