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: valmodel.h,v 1.1 2004-07-05 14:17:18 pj Exp $ |
||
22 | |||
23 | File: $File$ |
||
24 | Revision: $Revision: 1.1 $ |
||
25 | Last update: $Date: 2004-07-05 14:17:18 $ |
||
26 | ------------ |
||
27 | **/ |
||
28 | |||
29 | /* |
||
30 | * Copyright (C) 2001 Paolo Gai and Tomas Lenvall |
||
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 | #ifndef __VALMODEL_H__ |
||
49 | #define __VALMODEL_H__ |
||
50 | |||
51 | #include <kernel/types.h> |
||
52 | #include <kernel/model.h> |
||
53 | |||
54 | /* |
||
55 | * Registration functions |
||
56 | * |
||
57 | * |
||
58 | * Note that the module that will handle the aperiodic tasks should also |
||
59 | * support group creation. To support group creation you need a function |
||
60 | * that have to be called for "accept" the task. The test application |
||
61 | * will ensure you that the crunch_taskaccepted function will be called. |
||
62 | * |
||
63 | * The periodic tasks will be created as usual, with task_create. |
||
64 | * |
||
65 | * Please look at the template that you can use to create your own |
||
66 | * Scheduling Module (it should be distributed with this file. |
||
67 | */ |
||
68 | |||
69 | |||
70 | /* |
||
71 | * This function will be called into the __kernel_register_modules__ |
||
72 | * function in the middle of the registration of the Modules. |
||
73 | * You can do what you want here. |
||
74 | * |
||
75 | * In particular, you should register some scheduling Modules |
||
76 | * that will be capable to handle these two task models: |
||
77 | * - HARD_TASK_MODEL: periodic tasks with wcet and period != 0 |
||
78 | * - VALUE_TASK_MODEL: aperiodic tasks with wcet, reldline, and values |
||
79 | */ |
||
80 | void crunch_register_models(struct multiboot_info *mb); |
||
81 | |||
82 | |||
83 | /* |
||
84 | * This function will be used by the test application to accept value tasks. |
||
85 | * It returns 1 if the task p is accepted, 0 if not. |
||
86 | */ |
||
87 | int crunch_taskaccepted(PID p); |
||
88 | |||
89 | /* |
||
90 | * This function just returns the accumulated value by the scheduling |
||
91 | * modules. |
||
92 | */ |
||
93 | int crunch_getvalue(); |
||
94 | |||
95 | |||
96 | /* ----------------------------------------------------------------------- |
||
97 | VALUE_TASK_MODEL: elastic hard Tasks |
||
98 | ----------------------------------------------------------------------- */ |
||
99 | |||
100 | /* |
||
101 | * this is the Value Task Model that has been used in the |
||
102 | * Lab assignments of the Advanced Real-Time Course in |
||
103 | * the Malardalens University, Sweden |
||
104 | * |
||
105 | * This is an aperiodic task with deadline and wcet. |
||
106 | * if the task run to completion the Module gains some value points |
||
107 | * if it cannot be run it will loose some (penalty) points |
||
108 | */ |
||
109 | |||
110 | // a random unused number |
||
111 | #define VALUE_PCLASS 0x6900 |
||
112 | |||
113 | typedef struct { |
||
114 | TASK_MODEL t; |
||
115 | TIME wcet; // the worst case execution time of the task |
||
116 | TIME dline; // relative deadline |
||
117 | DWORD value; // the value gained if the task runs to completion |
||
118 | DWORD penalty; // the penalty gained if the task does not finish |
||
119 | } VALUE_TASK_MODEL; |
||
120 | |||
121 | #define value_task_default_model(m) \ |
||
122 | task_default_model((m).t,VALUE_PCLASS), \ |
||
123 | (m).wcet = 0, \ |
||
124 | (m).dline = 0, \ |
||
125 | (m).value = 0, \ |
||
126 | (m).penalty = 0 |
||
127 | #define value_task_def_level(m,l) task_def_level((m).t,l) |
||
128 | #define value_task_def_arg(m,a) task_def_arg((m).t,a) |
||
129 | #define value_task_def_stack(m,s) task_def_stack((m).t,s) |
||
130 | #define value_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s) |
||
131 | #define value_task_def_group(m,g) task_def_group((m).t,g) |
||
132 | #define value_task_def_usemath(m) task_def_usemath((m).t) |
||
133 | #define value_task_def_system(m) task_def_system((m).t) |
||
134 | #define value_task_def_nokill(m) task_def_nokill((m).t) |
||
135 | #define value_task_def_ctrl_jet(m) task_def_ctrl_jet((m).t) |
||
136 | #define value_task_def_wcet(m,w) (m).wcet = (w) |
||
137 | #define value_task_def_dline(m,d) (m).dline = (d) |
||
138 | #define value_task_def_value(m,v) (m).value = (v) |
||
139 | #define value_task_def_penalty(m,p) (m).penalty = (p) |
||
140 | #define value_task_def_joinable(m) task_def_joinable((m).t) |
||
141 | #define value_task_def_unjoinable(m) task_def_unjoinable((m).t) |
||
142 | |||
143 | #endif |