Subversion Repositories shark

Rev

Details | 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
/**
23
 ------------
24
 CVS :        $Id: model.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $
25
 
26
 File:        $File$
27
 Revision:    $Revision: 1.1.1.1 $
28
 Last update: $Date: 2002-03-29 14:12:51 $
29
 ------------
30
 
31
 This file contains the definitions of the task and resource models.
32
 
33
**/
34
 
35
/*
36
 * Copyright (C) 2000 Paolo Gai
37
 *
38
 * This program is free software; you can redistribute it and/or modify
39
 * it under the terms of the GNU General Public License as published by
40
 * the Free Software Foundation; either version 2 of the License, or
41
 * (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
51
 *
52
 */
53
 
54
#ifndef __KERNEL_MODEL_H__
55
#define __KERNEL_MODEL_H__
56
 
57
#include "ll/ll.h"
58
 
59
 
60
/* -----------------------------------------------------------------------
61
   -----------------------------------------------------------------------
62
   -----------------------------------------------------------------------
63
   -----------------------------------------------------------------------
64
   TASK MODELS
65
   -----------------------------------------------------------------------
66
   -----------------------------------------------------------------------
67
   -----------------------------------------------------------------------
68
   ----------------------------------------------------------------------- */
69
 
70
 
71
/* -----------------------------------------------------------------------
72
   TASK_MODELS: the base struct
73
   ----------------------------------------------------------------------- */
74
 
75
/*+
76
 TASK_MODEL
77
 
78
 IMPORTANT: this structure shall not be used by the end-user!!!
79
 
80
 This structure is only used to group together a set of optional
81
 parameters describing the task model. This structure is passed
82
 to the task_create primitive.
83
 
84
 The control field is used to set special task processing
85
 functions.
86
 
87
 Currently it supports:
88
 
89
 - USE_FPU     bit
90
   If the hw architecture is not smart enough to allow automatic
91
   FPU context switch, this information is used at the VM level
92
   to perform transparently the preemption of a FPU-task
93
 
94
 - NO_KILL     bit
95
   If this bit is set, the task can't be killed via the task_kill
96
   function. To make a task unkillable for short periods of time,
97
   use the cancellability functions instead.
98
 
99
 - NO_PREEMPT  bit
100
   If this bit is set, the task can't be preempted. To set/reset it,
101
   use the primitive task_preempt/task_no_preempt
102
 
103
 - SYSTEM_TASK bit
104
   If this bit is set, the task is a system task. The whole system exit
105
   only when all the non-system tasks are terminated.
106
 
107
 - JET_ENABLED bit
108
   If this bit is set the Generic Kernel records the Job Execution Times
109
   for the task. See the jet_XXX functions...
110
 
111
 - TASK_JOINABLE bit
112
   If this bit is set the task is joinable with task_join, otherwise the
113
   task is detached...
114
 
115
 - STACKADDR_SPECIFIED bit
116
   This bit is set when the task was created if we specify in the model
117
   the stack address. When the task ends, if this bi is set, the stack
118
   is not freed.
119
 
120
 
121
 - KILL_*      bits
122
   These bits are used to memorize the cancelability state of the task.
123
 
124
 - CONTROL_CAP bit
125
   This flag has to be set in the scheduling modules (NOT by the end-user)
126
   only if the kernel has to check the capacity for the task. The kernel
127
   uses only the avail_time field of the process descriptor.
128
 
129
 - TASK_DOING_SIGNALS bit
130
   It is an internal flag used with signal handling. It is set only when
131
   the task is executing a signal handler
132
 
133
 - FREEZE_ACTIVATION
134
   If this bit is set, the task_activate primitive doesn't activate any task;
135
   instead, it increment a counter. See task_[un]block_activations in kern.c
136
 
137
 - WAIT_FOR_JOIN
138
   The flag is set when the task terminates; the descriptor is not
139
   freed because we wait a task_join
140
 
141
 - DESCRIPTOR_DISCARDED
142
   This bit is set when the task descriptor is discarded by task_createn
143
   (the wait_for_join flag is set and the task was inserted in the free
144
   queue by a scheduling level). The task will be reinserted into the
145
   free queue by task_join...
146
 
147
 All the models redefines the TASK_MODEL structure
148
 - adding new fields if needed
149
 - using a unique number in the pclass variable
150
 
151
 When the user wants to create a task, he must specify a task model.
152
 First, he have to define a XXX_TASK_MODEL, then he must initialize it with
153
 a XXX_task_default_model.
154
 
155
 Then, he can specify some attributes that characterize the model.
156
 
157
 Not all the fields of a task model are mandatory, but a scheduling level
158
 or an ahard server may require some of them.
159
 For example, if the user wants to create an ahard tasks, he may specify
160
 a wcet. The wcet is not required by a Deferrable Server, but it is mandatory
161
 for a TBS!!!.
162
 
163
+*/
164
 
165
 
166
typedef struct {
167
    WORD    pclass;
168
    size_t  stacksize;
169
    void    *stackaddr;
170
    WORD    group;
171
    void    *arg;
172
    DWORD   control;
173
} TASK_MODEL;
174
 
175
/*+ Value for the control field, It is set if +*/
176
#define USE_FPU              0x0001 /*+ the task use FPU registers +*/
177
#define NO_KILL              0x0002 /*+ the task isn't killable at all +*/
178
#define NO_PREEMPT           0x0004 /*+ the task isn't preemptable +*/
179
#define SYSTEM_TASK          0x0008 /*+ the task is a system task. +*/
180
#define JET_ENABLED          0x0010 /*+ execution time monitoring enabled +*/
181
#define TASK_JOINABLE        0x0020 /*+ the task is joinable (see task_join)+*/
182
#define STACKADDR_SPECIFIED  0x0040 /*+ the stackaddr was specified +*/
183
#define TRACE_TASK          0x20000 /*+ the task must be traced +*/
184
 
185
/*+ flags contained in the control field, usettables from the models: +*/
186
#define KILLED_ON_CONDITION  0x0080 /*+ the task is killed but it is waiting
187
                                        to die because it must reaquire
188
                                        the mutex +*/
189
#define KILL_ENABLED         0x0100 /*+ cancelability enabled +*/
190
#define KILL_DEFERRED        0x0200 /*+ cancelability type deferred/async. +*/
191
#define KILL_REQUEST         0x0400 /*+ kill issued but not executed +*/
192
#define CONTROL_CAP          0x0800 /*+ Capacity control enabled +*/
193
#define TASK_DOING_SIGNALS   0x1000 /*+ see kern_deliver_pending_signals
194
                                        in signal.c +*/
195
#define FREEZE_ACTIVATION    0x2000 /*+ see task_block_activation in kern.c +*/
196
 
197
/* flags used in the implementation of the task_join */
198
#define WAIT_FOR_JOIN        0x4000 /*+ the task is terminated, but the
199
                                        descriptor is not freed because we wait
200
                                        a task_join +*/
201
#define DESCRIPTOR_DISCARDED 0x8000 /*+ the task descriptor is discarded by
202
                                        task_createn because the wait_for_join
203
                                        flag is set and it was inserted in the
204
                                        free queue by a scheduling level +*/
205
 
206
/* flag used in the implementation of the sig_timedwait */
207
#define SIGTIMEOUT_EXPIRED   0x10000 /*+ if the sigwait timer expires this
208
                                        flag is set... +*/
209
 
210
 
211
/* Some macros to set various task-model parameters */
212
#define task_default_model(m,p) (m).pclass = (p), \
213
                                (m).stacksize = 4096, \
214
                                (m).stackaddr = NULL, \
215
                                (m).group = 0, \
216
                                (m).arg = NULL,\
217
                                (m).control = 0
218
#define task_def_level(m,l)     (m).pclass = ((m).pclass & 0xFF00) | \
219
                                             ((l) & 0xFF)
220
#define task_def_arg(m,a)       (m).arg = (a)
221
#define task_def_stack(m,s)     (m).stacksize = (s)
222
#define task_def_stackaddr(m,s) (m).stackaddr = (s)
223
#define task_def_group(m,g)     (m).group = (g)
224
#define task_def_usemath(m)     (m).control |= USE_FPU
225
#define task_def_system(m)      (m).control |= SYSTEM_TASK
226
#define task_def_nokill(m)      (m).control |= NO_KILL
227
#define task_def_ctrl_jet(m)    (m).control |= JET_ENABLED
228
#define task_def_joinable(m)    (m).control |= TASK_JOINABLE
229
#define task_def_unjoinable(m)  (m).control &= ~TASK_JOINABLE
230
#define task_def_trace(m)       (m).control |= TRACE_TASK
231
#define task_def_notrace(m)     (m).control &= ~TRACE_TASK
232
 
233
 
234
 
235
 
236
/* -----------------------------------------------------------------------
237
   PCLASS values
238
   ----------------------------------------------------------------------- */
239
 
240
/*+ These are the value for the pclass field;
241
    a level l that accept a task model with pclass p
242
    accept also the alias pclass (p | l)
243
    => the LSByte MUST be 0 (256 levels maximum) +*/
244
 
245
#define DUMMY_PCLASS        0x0000
246
#define HARD_PCLASS         0x0100
247
#define SOFT_PCLASS         0x0200
248
#define NRT_PCLASS          0x0300
249
#define JOB_PCLASS          0x0400
250
 
251
 
252
/* -----------------------------------------------------------------------
253
   Useful stuffs
254
   ----------------------------------------------------------------------- */
255
 
256
#define PERIODIC       0
257
#define APERIODIC      1
258
 
259
#define SAVE_ARRIVALS  0
260
#define SKIP_ARRIVALS  1
261
 
262
 
263
 
264
/* -----------------------------------------------------------------------
265
   DUMMY_TASK_MODEL: model used only for the dummy task
266
   ----------------------------------------------------------------------- */
267
 
268
/*+ the dummy task doesn't add any new field +*/
269
typedef TASK_MODEL DUMMY_TASK_MODEL;
270
 
271
#define dummy_task_default_model(m) task_default_model(m,DUMMY_PCLASS)
272
#define dummy_task_def_level(m,l)   task_def_level(m,l)
273
#define dummy_task_def_system(m)    task_def_system(m)
274
#define dummy_task_def_nokill(m)    task_def_nokill(m)
275
#define dummy_task_def_ctrl_jet(m)  task_def_ctrl_jet(m)
276
 
277
 
278
 
279
 
280
 
281
 
282
/* -----------------------------------------------------------------------
283
   HARD_TASK_MODEL: hard Tasks
284
   ----------------------------------------------------------------------- */
285
 
286
/*  A Hard Task model can be used to model periodic and sporadic tasks.
287
    These tasks are usually guaranteed basing on their minimum interarrival
288
    time (mit) and wcet, and may have a relative deadline.
289
 
290
    A hard task can raise these exceptions:
291
    XDEADLINE_MISS XWCET_VIOLATION XACTIVATION
292
 
293
    The default model sets wcet, mit and relative deadline to 0, and
294
    the periodicity to PERIODIC.
295
*/
296
 
297
typedef struct {
298
  TASK_MODEL t;
299
  TIME mit;
300
  TIME drel;
301
  TIME wcet;
302
  int periodicity;
303
} HARD_TASK_MODEL;
304
 
305
#define hard_task_default_model(m)                             \
306
                        task_default_model((m).t,HARD_PCLASS), \
307
                        (m).mit         = 0,                   \
308
                        (m).drel        = 0,                   \
309
                        (m).wcet        = 0,                   \
310
                        (m).periodicity = PERIODIC
311
#define hard_task_def_level(m,l)    task_def_level((m).t,l)
312
#define hard_task_def_arg(m,a)      task_def_arg((m).t,a)
313
#define hard_task_def_stack(m,s)    task_def_stack((m).t,s)
314
#define hard_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
315
#define hard_task_def_group(m,g)    task_def_group((m).t,g)
316
#define hard_task_def_usemath(m)    task_def_usemath((m).t)
317
#define hard_task_def_system(m)     task_def_system((m).t)
318
#define hard_task_def_nokill(m)     task_def_nokill((m).t)
319
#define hard_task_def_ctrl_jet(m)   task_def_ctrl_jet((m).t)
320
#define hard_task_def_mit(m,p)      (m).mit = (p)
321
#define hard_task_def_drel(m,d)     (m).drel = (d)
322
#define hard_task_def_wcet(m,w)     (m).wcet = (w)
323
#define hard_task_def_periodic(m)   (m).periodicity = PERIODIC
324
#define hard_task_def_aperiodic(m)  (m).periodicity = APERIODIC
325
#define hard_task_def_joinable(m)   task_def_joinable((m).t)
326
#define hard_task_def_unjoinable(m) task_def_unjoinable((m).t)
327
#define hard_task_def_trace(m)      task_def_trace((m).t)
328
#define hard_task_def_notrace(m)    task_def_notrace((m).t)
329
 
330
 
331
 
332
/* -----------------------------------------------------------------------
333
   SOFT_TASK_MODEL: Soft Tasks
334
   ----------------------------------------------------------------------- */
335
 
336
/*  A Soft Task model can be used to model periodic and aperiodic tasks
337
    usually not guaranteed or guaranteed basing on their period and mean
338
    execution time (met). A Soft task can also record pending activations if
339
    the arrivals are set to SAVE.
340
 
341
    A wcet field is also present for those servers that need if (i.e., TBS)
342
 
343
    The default model sets met, period and wcet to 0, the periodicity to
344
    PERIODIC and the arrivals to SAVE.
345
 
346
    A Soft Task don't raise any exception.
347
*/
348
 
349
typedef struct {
350
  TASK_MODEL t;
351
  TIME period;
352
  TIME met;
353
  TIME wcet;
354
  int periodicity;
355
  int arrivals;
356
} SOFT_TASK_MODEL;
357
 
358
#define soft_task_default_model(m)                             \
359
                        task_default_model((m).t,SOFT_PCLASS), \
360
                        (m).period      = 0,                   \
361
                        (m).met         = 0,                   \
362
                        (m).wcet        = 0,                   \
363
                        (m).periodicity = PERIODIC,            \
364
                        (m).arrivals    = SAVE_ARRIVALS
365
#define soft_task_def_level(m,l)       task_def_level((m).t,l)
366
#define soft_task_def_arg(m,a)         task_def_arg((m).t,a)
367
#define soft_task_def_stack(m,s)       task_def_stack((m).t,s)
368
#define soft_task_def_stackaddr(m,s)   task_def_stackaddr((m).t,s)
369
#define soft_task_def_group(m,g)       task_def_group((m).t,g)
370
#define soft_task_def_usemath(m)       task_def_usemath((m).t)
371
#define soft_task_def_system(m)        task_def_system((m).t)
372
#define soft_task_def_nokill(m)        task_def_nokill((m).t)
373
#define soft_task_def_ctrl_jet(m)      task_def_ctrl_jet((m).t)
374
#define soft_task_def_period(m,p)      (m).period = (p)
375
#define soft_task_def_met(m,d)         (m).met = (d)
376
#define soft_task_def_wcet(m,w)        (m).wcet = (w)
377
#define soft_task_def_periodic(m)      (m).periodicity = PERIODIC
378
#define soft_task_def_aperiodic(m)     (m).periodicity = APERIODIC
379
#define soft_task_def_save_arrivals(m) (m).arrivals    = SAVE_ARRIVALS
380
#define soft_task_def_skip_arrivals(m) (m).arrivals    = SKIP_ARRIVALS
381
#define soft_task_def_joinable(m)      task_def_joinable((m).t)
382
#define soft_task_def_unjoinable(m)    task_def_unjoinable((m).t)
383
#define soft_task_def_trace(m)         task_def_trace((m).t)
384
#define soft_task_def_notrace(m)       task_def_notrace((m).t)
385
 
386
/* -----------------------------------------------------------------------
387
   NRT_TASK_MODEL: Non Realtime Tasks
388
   ----------------------------------------------------------------------- */
389
 
390
/* A NRT task has a weight and a time slice, plus  a policy attribute.
391
   It can be used to model Round Robin, Proportional Share, POSIX,
392
   and Priority tasks.
393
 
394
   Policy and inherit is inserted in the model to support posix
395
   compliant scheduling...
396
 
397
   The default model set weight and slice to 0, policy to RR, and inherit
398
   to explicit.
399
*/
400
 
401
#define NRT_RR_POLICY   0
402
#define NRT_FIFO_POLICY 1
403
 
404
#define NRT_INHERIT_SCHED  0
405
#define NRT_EXPLICIT_SCHED 1
406
 
407
typedef struct {
408
  TASK_MODEL t;
409
  int weight;
410
  TIME slice;
411
  int arrivals;
412
  int policy;
413
  int inherit;
414
} NRT_TASK_MODEL;
415
 
416
#define nrt_task_default_model(m) task_default_model((m).t,NRT_PCLASS), \
417
                                      (m).weight   = 0,                 \
418
                                      (m).slice    = 0,                 \
419
                                      (m).arrivals = SAVE_ARRIVALS,     \
420
                                      (m).policy   = NRT_RR_POLICY,     \
421
                                      (m).inherit  = NRT_EXPLICIT_SCHED
422
#define nrt_task_def_level(m,l)       task_def_level((m).t,l)
423
#define nrt_task_def_arg(m,a)         task_def_arg((m).t,a)
424
#define nrt_task_def_stack(m,s)       task_def_stack((m).t,s)
425
#define nrt_task_def_stackaddr(m,s)   task_def_stackaddr((m).t,s)
426
#define nrt_task_def_group(m,g)       task_def_group((m).t,g)
427
#define nrt_task_def_usemath(m)       task_def_usemath((m).t)
428
#define nrt_task_def_system(m)        task_def_system((m).t)
429
#define nrt_task_def_nokill(m)        task_def_nokill((m).t)
430
#define nrt_task_def_ctrl_jet(m)      task_def_ctrl_jet((m).t)
431
#define nrt_task_def_joinable(m)      task_def_joinable((m).t)
432
#define nrt_task_def_unjoinable(m)    task_def_unjoinable((m).t)
433
#define nrt_task_def_weight(m,w)      (m).weight = (w)
434
#define nrt_task_def_slice(m,s)       (m).slice = (s)
435
#define nrt_task_def_save_arrivals(m) (m).arrivals    = SAVE_ARRIVALS
436
#define nrt_task_def_skip_arrivals(m) (m).arrivals    = SKIP_ARRIVALS
437
#define nrt_task_def_policy(m,p)      (m).policy = (p)
438
#define nrt_task_def_inherit(m,i)     (m).inherit = (i)
439
#define nrt_task_def_trace(m)         task_def_trace((m).t)
440
#define nrt_task_def_notrace(m)       task_def_notrace((m).t)
441
 
442
 
443
/* -----------------------------------------------------------------------
444
   JOB_TASK_MODEL: Job Task
445
   ----------------------------------------------------------------------- */
446
 
447
/*  This model implements a Job with an optional period and a starting
448
    deadline (for the first activation).
449
 
450
    A Job task can raise a XDEADLINE_MISS exception;
451
    if the flag noraiseexc is != 0, the exception is not raised.
452
 
453
    It represent a SINGLE job activation. Typically, a task with this
454
    model NEVER call a task_sleep or task_endcycle. Why? because it is
455
    a single activation.
456
 
457
    In fact, this model is normally used with aperiodic
458
    servers: the aperiodic server insert a guest task in another level
459
    with that model; then, when the current activation is ended (e.g. a
460
    task_sleep() is called) the level, into the XXX_task_sleep, calls
461
    the XXX_guest_end to terminate the actual activation.
462
 
463
    Note that there is no capacity control on this model.
464
    Note that the task that accept this task DOESN'T reactivate the
465
    task after a period... There is NOT a guest_endcycle defined
466
    for this model...
467
 
468
    The default model set noraiseexc and period to 0, and accept a deadline
469
*/
470
 
471
typedef struct {
472
  TASK_MODEL t;
473
  TIME period;
474
  struct timespec deadline;
475
  int noraiseexc;
476
} JOB_TASK_MODEL;
477
 
478
#define job_task_default_model(m,dl)                     \
479
                  task_default_model((m).t,JOB_PCLASS),  \
480
                  (m).period = 0,                        \
481
                  TIMESPEC_ASSIGN(&((m).deadline),&(dl)),\
482
                  (m).noraiseexc = 0
483
#define job_task_def_level(m,l)     task_def_level((m).t,l)
484
#define job_task_def_arg(m,a)       task_def_arg((m).t,a)
485
#define job_task_def_stack(m,s)     task_def_stack((m).t,s)
486
#define job_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
487
#define job_task_def_group(m,g)     task_def_group((m).t,g)
488
#define job_task_def_usemath(m)     task_def_usemath((m).t)
489
#define job_task_def_system(m)      task_def_system((m).t)
490
#define job_task_def_nokill(m)      task_def_nokill((m).t)
491
#define job_task_def_ctrl_jet(m)    task_def_ctrl_jet((m).t)
492
#define job_task_def_period(m,per)  (m).period = (per)
493
#define job_task_def_deadline(m,dl) TIMESPEC_ASSIGN(&((m).deadline),&(dl))
494
#define job_task_def_noexc(m)       (m).noraiseexc = 1
495
#define job_task_def_yesexc(m)      (m).noraiseexc = 0
496
#define job_task_def_joinable(m)    task_def_joinable((m).t)
497
#define job_task_def_unjoinable(m)  task_def_unjoinable((m).t)
498
#define job_task_def_trace(m)       task_def_trace((m).t)
499
#define job_task_def_notrace(m)     task_def_notrace((m).t)
500
 
501
 
502
 
503
 
504
 
505
 
506
 
507
 
508
 
509
 
510
 
511
/* -----------------------------------------------------------------------
512
   -----------------------------------------------------------------------
513
   -----------------------------------------------------------------------
514
   -----------------------------------------------------------------------
515
   RESOURCE MODELS
516
   -----------------------------------------------------------------------
517
   -----------------------------------------------------------------------
518
   -----------------------------------------------------------------------
519
   ----------------------------------------------------------------------- */
520
 
521
 
522
 
523
 
524
 
525
 
526
 
527
/* -----------------------------------------------------------------------
528
   RTYPE values
529
   ----------------------------------------------------------------------- */
530
 
531
/* These are the values for the rtype field of a resource descriptor.
532
   The value in the rtype field is used to distinguish the interface really
533
   implemented by the resource object.
534
 
535
   For example, a mutex resource descriptor "inherit" from a resource_des
536
   and implements also all the mutex functions as "virtual", so a type field
537
   is added to the resource descriptor to distinguish witch interface is
538
   really added. +*/
539
 
540
#define DEFAULT_RTYPE     0  /*+ no fields added to resource_des +*/
541
#define MUTEX_RTYPE       1  /*+ the structure implements a mutex
542
                                 protocol, so a cast to mutex_resource_des
543
                                 is legal +*/
544
 
545
 
546
 
547
/* -----------------------------------------------------------------------
548
   RES_MODEL - the base struct
549
   ----------------------------------------------------------------------- */
550
 
551
/*+
552
 RES_MODEL
553
 
554
 This structure is used like the TASK_MODEL.
555
 It groups together a set of optional parameters describing
556
 the resource model used by a task.
557
 
558
 It contains only a field; the others are model-dependent.
559
+*/
560
 
561
typedef struct {
562
  int rclass;        // protocollo a cui si riferisce il modello di task
563
} RES_MODEL;
564
 
565
#define res_default_model(r, p)      (r).rclass = (p)
566
#define res_def_level(r,l)           (r).rclass = ((r).rclass & 0xFF00) | (l)
567
 
568
 
569
 
570
/* -----------------------------------------------------------------------
571
   RCLASS values
572
   ----------------------------------------------------------------------- */
573
 
574
/*+ These are the values for the type field in the resource models
575
    a resource level l that accept a resource model with rclass r
576
    accept also the alias pclass (p | l)
577
    => the LSByte MUST be 0 (256 levels maximum) (as for PCLASS!!!) +*/
578
 
579
#define PC_RCLASS    0x0100
580
#define SRP_RCLASS   0x0200
581
#define SRP2_RCLASS  0x0300
582
 
583
#define BDEDF_RCLASS   0x0400
584
#define BDPSCAN_RCLASS 0x0500
585
 
586
/* -----------------------------------------------------------------------
587
   PC_RES_MODEL: BlockDevice EDF resource model
588
   ----------------------------------------------------------------------- */
589
 
590
typedef struct {
591
  RES_MODEL r;
592
  TIME dl;
593
} BDEDF_RES_MODEL;
594
 
595
#define BDEDF_res_default_model(res) \
596
  res_default_model((res).r,BDEDF_RCLASS); \
597
  (res).dl=0     
598
#define BDEDF_res_def_level(res,l)  res_def_level((res).r,l)     
599
#define BDEDF_res_def_dl(res,reldl)  (res).dl=reldl
600
 
601
/* -----------------------------------------------------------------------
602
   PC_RES_MODEL: BlockDevice PSCAN resource model
603
   ----------------------------------------------------------------------- */
604
 
605
typedef struct {
606
  RES_MODEL r;
607
  int priority;
608
} BDPSCAN_RES_MODEL;
609
 
610
#define BDPSCAN_res_default_model(res) \
611
  res_default_model((res).r,BDPSCAN_RCLASS); \
612
  (res).priority=255     
613
#define BDPSCAN_res_def_level(res,l)  res_def_level((res).r,l)     
614
#define BDPSCAN_res_def_priority(res,pri)  (res).priority=pri
615
 
616
/* -----------------------------------------------------------------------
617
   PC_RES_MODEL: Priority ceiling resource model
618
   ----------------------------------------------------------------------- */
619
 
620
/* the tasks created without using this resource models are assumed to have
621
   priority = MAX_DWORD (the lowest). */
622
 
623
typedef struct {
624
  RES_MODEL r;
625
  DWORD priority;
626
} PC_RES_MODEL;
627
 
628
#define PC_res_default_model(res, prio) \
629
                                 res_default_model((res).r, PC_RCLASS); \
630
                                 (res).priority = (prio)
631
#define PC_res_def_level(res,l)  res_def_level(res,l)
632
 
633
/* -----------------------------------------------------------------------
634
   SRP_RES_MODEL: Stack Resource Policy resource model
635
   ----------------------------------------------------------------------- */
636
 
637
/* the tasks created without using this resource model are not allowed to
638
   lock any SRP mutex. if two of this models are passed to the task_create,
639
   one of them is chosen, in a nondeterministic way, so use only one of
640
   this resource model per task!!!
641
 
642
   The First SRP version uses another resource model that is embedded into
643
   the mutex structure. refer to kernel/modules/srp.c. this second resource
644
   model has the SRP2_RCLASS
645
*/
646
 
647
typedef struct {
648
  RES_MODEL r;
649
  DWORD preempt;  /* the preemption level of a task */
650
} SRP_RES_MODEL;
651
 
652
#define SRP_res_default_model(res, pre) \
653
                                 res_default_model((res).r, SRP_RCLASS); \
654
                                 (res).preempt = (pre)
655
#define SRP_res_def_level(res,l) res_def_level(res,l)
656
 
657
 
658
/* -----------------------------------------------------------------------
659
   MUTEX Attributes
660
   ----------------------------------------------------------------------- */
661
 
662
/*+
663
  MUTEX ATTRIBUTES
664
 
665
  A mutexattr object act as the task model for the tasks in the system:
666
  It specifies the particular options used by a protocol.
667
 
668
  From this basic attribute object many other objects can be derived
669
  as done for the TASK_MODEL. These objects are used to initialize a mutex
670
  with a specified protocol.
671
+*/
672
typedef struct {
673
  int mclass;      /* the protocol type... */
674
} mutexattr_t;
675
 
676
#define mutexattr_default(a, c)  (a).mclass = (c)
677
 
678
 
679
/* -----------------------------------------------------------------------
680
   MCLASS values
681
   ----------------------------------------------------------------------- */
682
 
683
/*+ These are the value for the mclass field;
684
    a mutex level l that accept a task model with mclass m
685
    accept also the alias mclass (m | l)
686
    => the LSByte MUST be 0 (256 levels maximum) +*/
687
 
688
#define NPP_MCLASS      0x0100
689
#define PI_MCLASS       0x0200
690
#define PC_MCLASS       0x0300
691
#define SRP_MCLASS      0x0400
692
#define NOP_MCLASS      0x0500
693
#define NOPM_MCLASS     0x0600
694
 
695
/* -----------------------------------------------------------------------
696
   PI_mutexattr_t: Priority Inheritance Mutex Attribute
697
   ----------------------------------------------------------------------- */
698
 
699
typedef mutexattr_t PI_mutexattr_t;
700
 
701
#define PI_MUTEXATTR_INITIALIZER {PI_MCLASS}
702
#define PI_mutexattr_default(a)  mutexattr_default(a, PI_MCLASS)
703
 
704
/* -----------------------------------------------------------------------
705
   NPP_mutexattr_t: Non Preemptive Protocol Mutex Attribute
706
   ----------------------------------------------------------------------- */
707
 
708
typedef mutexattr_t NPP_mutexattr_t;
709
 
710
#define NPP_MUUEXATTR_INITIALIZER {NPP_MCLASS}
711
#define NPP_mutexattr_default(a)  mutexattr_default(a, NPP_MCLASS)
712
 
713
/* -----------------------------------------------------------------------
714
   PC_mutexattr_t: Priority Ceiling Mutex Attribute
715
   ----------------------------------------------------------------------- */
716
 
717
typedef struct {
718
  mutexattr_t a;
719
  DWORD ceiling;
720
} PC_mutexattr_t;
721
 
722
#define PC_MUTEXATTR_INITIALIZER {{PC_MCLASS},MAX_DWORD}
723
#define PC_mutexattr_default(at,c)  mutexattr_default((at).a, PC_MCLASS); \
724
                                    (at).ceiling = (c)
725
 
726
/* -----------------------------------------------------------------------
727
   SRP_mutexattr_t: Stack Resource Policy Mutex Attribute
728
   ----------------------------------------------------------------------- */
729
 
730
typedef mutexattr_t SRP_mutexattr_t;
731
 
732
#define SRP_MUTEXATTR_INITIALIZER {SRP_MCLASS}
733
#define SRP_mutexattr_default(a)  mutexattr_default(a, SRP_MCLASS)
734
 
735
/* -----------------------------------------------------------------------
736
   NOP_mutexattr_t: No Protocol Mutex Attribute
737
   ----------------------------------------------------------------------- */
738
 
739
typedef mutexattr_t NOP_mutexattr_t;
740
 
741
#define NOP_MUTEXATTR_INITIALIZER {NOP_MCLASS}
742
#define NOP_mutexattr_default(a)  mutexattr_default(a, NOP_MCLASS)
743
 
744
/* -----------------------------------------------------------------------
745
   NOPM_mutexattr_t: No Protocol Multiple lock Mutex Attribute
746
   ----------------------------------------------------------------------- */
747
 
748
typedef mutexattr_t NOPM_mutexattr_t;
749
 
750
#define NOPM_MUTEXATTR_INITIALIZER {NOPM_MCLASS}
751
#define NOPM_mutexattr_default(a)  mutexattr_default(a, NOPM_MCLASS)
752
 
753
 
754
#endif /* __MODEL_H__ */
755