Subversion Repositories shark

Rev

Rev 3 | Rev 79 | Go to most recent revision | 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
/**
23
 ------------
38 pj 24
 CVS :        $Id: model.h,v 1.2 2003-01-07 17:12:19 pj Exp $
2 pj 25
 
26
 File:        $File$
38 pj 27
 Revision:    $Revision: 1.2 $
28
 Last update: $Date: 2003-01-07 17:12:19 $
2 pj 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"
38 pj 58
#include "kernel/types.h"
2 pj 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;
38 pj 168
    LEVEL   level;
2 pj 169
    size_t  stacksize;
170
    void    *stackaddr;
171
    WORD    group;
172
    void    *arg;
173
    DWORD   control;
174
} TASK_MODEL;
175
 
176
/*+ Value for the control field, It is set if +*/
177
#define USE_FPU              0x0001 /*+ the task use FPU registers +*/
178
#define NO_KILL              0x0002 /*+ the task isn't killable at all +*/
179
#define NO_PREEMPT           0x0004 /*+ the task isn't preemptable +*/
180
#define SYSTEM_TASK          0x0008 /*+ the task is a system task. +*/
181
#define JET_ENABLED          0x0010 /*+ execution time monitoring enabled +*/
182
#define TASK_JOINABLE        0x0020 /*+ the task is joinable (see task_join)+*/
183
#define STACKADDR_SPECIFIED  0x0040 /*+ the stackaddr was specified +*/
184
#define TRACE_TASK          0x20000 /*+ the task must be traced +*/
185
 
186
/*+ flags contained in the control field, usettables from the models: +*/
187
#define KILLED_ON_CONDITION  0x0080 /*+ the task is killed but it is waiting
188
                                        to die because it must reaquire
189
                                        the mutex +*/
190
#define KILL_ENABLED         0x0100 /*+ cancelability enabled +*/
191
#define KILL_DEFERRED        0x0200 /*+ cancelability type deferred/async. +*/
192
#define KILL_REQUEST         0x0400 /*+ kill issued but not executed +*/
193
#define CONTROL_CAP          0x0800 /*+ Capacity control enabled +*/
194
#define TASK_DOING_SIGNALS   0x1000 /*+ see kern_deliver_pending_signals
195
                                        in signal.c +*/
196
#define FREEZE_ACTIVATION    0x2000 /*+ see task_block_activation in kern.c +*/
197
 
198
/* flags used in the implementation of the task_join */
199
#define WAIT_FOR_JOIN        0x4000 /*+ the task is terminated, but the
200
                                        descriptor is not freed because we wait
201
                                        a task_join +*/
202
#define DESCRIPTOR_DISCARDED 0x8000 /*+ the task descriptor is discarded by
203
                                        task_createn because the wait_for_join
204
                                        flag is set and it was inserted in the
205
                                        free queue by a scheduling level +*/
206
 
207
/* flag used in the implementation of the sig_timedwait */
208
#define SIGTIMEOUT_EXPIRED   0x10000 /*+ if the sigwait timer expires this
209
                                        flag is set... +*/
210
 
211
 
212
/* Some macros to set various task-model parameters */
213
#define task_default_model(m,p) (m).pclass = (p), \
38 pj 214
                                (m).level = 0; \
2 pj 215
                                (m).stacksize = 4096, \
216
                                (m).stackaddr = NULL, \
217
                                (m).group = 0, \
218
                                (m).arg = NULL,\
219
                                (m).control = 0
38 pj 220
#define task_def_level(m,l)     (m).level = (l)
2 pj 221
#define task_def_arg(m,a)       (m).arg = (a)
222
#define task_def_stack(m,s)     (m).stacksize = (s)
223
#define task_def_stackaddr(m,s) (m).stackaddr = (s)
224
#define task_def_group(m,g)     (m).group = (g)
225
#define task_def_usemath(m)     (m).control |= USE_FPU
226
#define task_def_system(m)      (m).control |= SYSTEM_TASK
227
#define task_def_nokill(m)      (m).control |= NO_KILL
228
#define task_def_ctrl_jet(m)    (m).control |= JET_ENABLED
229
#define task_def_joinable(m)    (m).control |= TASK_JOINABLE
230
#define task_def_unjoinable(m)  (m).control &= ~TASK_JOINABLE
231
#define task_def_trace(m)       (m).control |= TRACE_TASK
232
#define task_def_notrace(m)     (m).control &= ~TRACE_TASK
233
 
234
 
235
 
236
 
237
/* -----------------------------------------------------------------------
238
   PCLASS values
239
   ----------------------------------------------------------------------- */
240
 
38 pj 241
/* These are the value for the pclass field */
2 pj 242
 
38 pj 243
#define DUMMY_PCLASS        0
244
#define HARD_PCLASS         1
245
#define SOFT_PCLASS         2
246
#define NRT_PCLASS          3
247
#define JOB_PCLASS          4
2 pj 248
 
249
 
250
/* -----------------------------------------------------------------------
251
   Useful stuffs
252
   ----------------------------------------------------------------------- */
253
 
254
#define PERIODIC       0
255
#define APERIODIC      1
256
 
257
#define SAVE_ARRIVALS  0
258
#define SKIP_ARRIVALS  1
259
 
260
 
261
 
262
/* -----------------------------------------------------------------------
263
   DUMMY_TASK_MODEL: model used only for the dummy task
264
   ----------------------------------------------------------------------- */
265
 
266
/*+ the dummy task doesn't add any new field +*/
267
typedef TASK_MODEL DUMMY_TASK_MODEL;
268
 
269
#define dummy_task_default_model(m) task_default_model(m,DUMMY_PCLASS)
270
#define dummy_task_def_level(m,l)   task_def_level(m,l)
271
#define dummy_task_def_system(m)    task_def_system(m)
272
#define dummy_task_def_nokill(m)    task_def_nokill(m)
273
#define dummy_task_def_ctrl_jet(m)  task_def_ctrl_jet(m)
274
 
275
 
276
 
277
 
278
 
279
 
280
/* -----------------------------------------------------------------------
281
   HARD_TASK_MODEL: hard Tasks
282
   ----------------------------------------------------------------------- */
283
 
284
/*  A Hard Task model can be used to model periodic and sporadic tasks.
285
    These tasks are usually guaranteed basing on their minimum interarrival
286
    time (mit) and wcet, and may have a relative deadline.
287
 
288
    A hard task can raise these exceptions:
289
    XDEADLINE_MISS XWCET_VIOLATION XACTIVATION
290
 
291
    The default model sets wcet, mit and relative deadline to 0, and
292
    the periodicity to PERIODIC.
293
*/
294
 
295
typedef struct {
296
  TASK_MODEL t;
297
  TIME mit;
298
  TIME drel;
299
  TIME wcet;
300
  int periodicity;
301
} HARD_TASK_MODEL;
302
 
303
#define hard_task_default_model(m)                             \
304
                        task_default_model((m).t,HARD_PCLASS), \
305
                        (m).mit         = 0,                   \
306
                        (m).drel        = 0,                   \
307
                        (m).wcet        = 0,                   \
308
                        (m).periodicity = PERIODIC
309
#define hard_task_def_level(m,l)    task_def_level((m).t,l)
310
#define hard_task_def_arg(m,a)      task_def_arg((m).t,a)
311
#define hard_task_def_stack(m,s)    task_def_stack((m).t,s)
312
#define hard_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
313
#define hard_task_def_group(m,g)    task_def_group((m).t,g)
314
#define hard_task_def_usemath(m)    task_def_usemath((m).t)
315
#define hard_task_def_system(m)     task_def_system((m).t)
316
#define hard_task_def_nokill(m)     task_def_nokill((m).t)
317
#define hard_task_def_ctrl_jet(m)   task_def_ctrl_jet((m).t)
318
#define hard_task_def_mit(m,p)      (m).mit = (p)
319
#define hard_task_def_drel(m,d)     (m).drel = (d)
320
#define hard_task_def_wcet(m,w)     (m).wcet = (w)
321
#define hard_task_def_periodic(m)   (m).periodicity = PERIODIC
322
#define hard_task_def_aperiodic(m)  (m).periodicity = APERIODIC
323
#define hard_task_def_joinable(m)   task_def_joinable((m).t)
324
#define hard_task_def_unjoinable(m) task_def_unjoinable((m).t)
325
#define hard_task_def_trace(m)      task_def_trace((m).t)
326
#define hard_task_def_notrace(m)    task_def_notrace((m).t)
327
 
328
 
329
 
330
/* -----------------------------------------------------------------------
331
   SOFT_TASK_MODEL: Soft Tasks
332
   ----------------------------------------------------------------------- */
333
 
334
/*  A Soft Task model can be used to model periodic and aperiodic tasks
335
    usually not guaranteed or guaranteed basing on their period and mean
336
    execution time (met). A Soft task can also record pending activations if
337
    the arrivals are set to SAVE.
338
 
339
    A wcet field is also present for those servers that need if (i.e., TBS)
340
 
341
    The default model sets met, period and wcet to 0, the periodicity to
342
    PERIODIC and the arrivals to SAVE.
343
 
344
    A Soft Task don't raise any exception.
345
*/
346
 
347
typedef struct {
348
  TASK_MODEL t;
349
  TIME period;
350
  TIME met;
351
  TIME wcet;
352
  int periodicity;
353
  int arrivals;
354
} SOFT_TASK_MODEL;
355
 
356
#define soft_task_default_model(m)                             \
357
                        task_default_model((m).t,SOFT_PCLASS), \
358
                        (m).period      = 0,                   \
359
                        (m).met         = 0,                   \
360
                        (m).wcet        = 0,                   \
361
                        (m).periodicity = PERIODIC,            \
362
                        (m).arrivals    = SAVE_ARRIVALS
363
#define soft_task_def_level(m,l)       task_def_level((m).t,l)
364
#define soft_task_def_arg(m,a)         task_def_arg((m).t,a)
365
#define soft_task_def_stack(m,s)       task_def_stack((m).t,s)
366
#define soft_task_def_stackaddr(m,s)   task_def_stackaddr((m).t,s)
367
#define soft_task_def_group(m,g)       task_def_group((m).t,g)
368
#define soft_task_def_usemath(m)       task_def_usemath((m).t)
369
#define soft_task_def_system(m)        task_def_system((m).t)
370
#define soft_task_def_nokill(m)        task_def_nokill((m).t)
371
#define soft_task_def_ctrl_jet(m)      task_def_ctrl_jet((m).t)
372
#define soft_task_def_period(m,p)      (m).period = (p)
373
#define soft_task_def_met(m,d)         (m).met = (d)
374
#define soft_task_def_wcet(m,w)        (m).wcet = (w)
375
#define soft_task_def_periodic(m)      (m).periodicity = PERIODIC
376
#define soft_task_def_aperiodic(m)     (m).periodicity = APERIODIC
377
#define soft_task_def_save_arrivals(m) (m).arrivals    = SAVE_ARRIVALS
378
#define soft_task_def_skip_arrivals(m) (m).arrivals    = SKIP_ARRIVALS
379
#define soft_task_def_joinable(m)      task_def_joinable((m).t)
380
#define soft_task_def_unjoinable(m)    task_def_unjoinable((m).t)
381
#define soft_task_def_trace(m)         task_def_trace((m).t)
382
#define soft_task_def_notrace(m)       task_def_notrace((m).t)
383
 
384
/* -----------------------------------------------------------------------
385
   NRT_TASK_MODEL: Non Realtime Tasks
386
   ----------------------------------------------------------------------- */
387
 
388
/* A NRT task has a weight and a time slice, plus  a policy attribute.
389
   It can be used to model Round Robin, Proportional Share, POSIX,
390
   and Priority tasks.
391
 
392
   Policy and inherit is inserted in the model to support posix
393
   compliant scheduling...
394
 
395
   The default model set weight and slice to 0, policy to RR, and inherit
396
   to explicit.
397
*/
398
 
399
#define NRT_RR_POLICY   0
400
#define NRT_FIFO_POLICY 1
401
 
402
#define NRT_INHERIT_SCHED  0
403
#define NRT_EXPLICIT_SCHED 1
404
 
405
typedef struct {
406
  TASK_MODEL t;
407
  int weight;
408
  TIME slice;
409
  int arrivals;
410
  int policy;
411
  int inherit;
412
} NRT_TASK_MODEL;
413
 
414
#define nrt_task_default_model(m) task_default_model((m).t,NRT_PCLASS), \
415
                                      (m).weight   = 0,                 \
416
                                      (m).slice    = 0,                 \
417
                                      (m).arrivals = SAVE_ARRIVALS,     \
418
                                      (m).policy   = NRT_RR_POLICY,     \
419
                                      (m).inherit  = NRT_EXPLICIT_SCHED
420
#define nrt_task_def_level(m,l)       task_def_level((m).t,l)
421
#define nrt_task_def_arg(m,a)         task_def_arg((m).t,a)
422
#define nrt_task_def_stack(m,s)       task_def_stack((m).t,s)
423
#define nrt_task_def_stackaddr(m,s)   task_def_stackaddr((m).t,s)
424
#define nrt_task_def_group(m,g)       task_def_group((m).t,g)
425
#define nrt_task_def_usemath(m)       task_def_usemath((m).t)
426
#define nrt_task_def_system(m)        task_def_system((m).t)
427
#define nrt_task_def_nokill(m)        task_def_nokill((m).t)
428
#define nrt_task_def_ctrl_jet(m)      task_def_ctrl_jet((m).t)
429
#define nrt_task_def_joinable(m)      task_def_joinable((m).t)
430
#define nrt_task_def_unjoinable(m)    task_def_unjoinable((m).t)
431
#define nrt_task_def_weight(m,w)      (m).weight = (w)
432
#define nrt_task_def_slice(m,s)       (m).slice = (s)
433
#define nrt_task_def_save_arrivals(m) (m).arrivals    = SAVE_ARRIVALS
434
#define nrt_task_def_skip_arrivals(m) (m).arrivals    = SKIP_ARRIVALS
435
#define nrt_task_def_policy(m,p)      (m).policy = (p)
436
#define nrt_task_def_inherit(m,i)     (m).inherit = (i)
437
#define nrt_task_def_trace(m)         task_def_trace((m).t)
438
#define nrt_task_def_notrace(m)       task_def_notrace((m).t)
439
 
440
 
441
/* -----------------------------------------------------------------------
442
   JOB_TASK_MODEL: Job Task
443
   ----------------------------------------------------------------------- */
444
 
445
/*  This model implements a Job with an optional period and a starting
446
    deadline (for the first activation).
447
 
448
    A Job task can raise a XDEADLINE_MISS exception;
449
    if the flag noraiseexc is != 0, the exception is not raised.
450
 
451
    It represent a SINGLE job activation. Typically, a task with this
452
    model NEVER call a task_sleep or task_endcycle. Why? because it is
453
    a single activation.
454
 
455
    In fact, this model is normally used with aperiodic
456
    servers: the aperiodic server insert a guest task in another level
457
    with that model; then, when the current activation is ended (e.g. a
458
    task_sleep() is called) the level, into the XXX_task_sleep, calls
459
    the XXX_guest_end to terminate the actual activation.
460
 
461
    Note that there is no capacity control on this model.
462
    Note that the task that accept this task DOESN'T reactivate the
463
    task after a period... There is NOT a guest_endcycle defined
464
    for this model...
465
 
466
    The default model set noraiseexc and period to 0, and accept a deadline
467
*/
468
 
469
typedef struct {
470
  TASK_MODEL t;
471
  TIME period;
472
  struct timespec deadline;
473
  int noraiseexc;
474
} JOB_TASK_MODEL;
475
 
476
#define job_task_default_model(m,dl)                     \
477
                  task_default_model((m).t,JOB_PCLASS),  \
478
                  (m).period = 0,                        \
479
                  TIMESPEC_ASSIGN(&((m).deadline),&(dl)),\
480
                  (m).noraiseexc = 0
481
#define job_task_def_level(m,l)     task_def_level((m).t,l)
482
#define job_task_def_arg(m,a)       task_def_arg((m).t,a)
483
#define job_task_def_stack(m,s)     task_def_stack((m).t,s)
484
#define job_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
485
#define job_task_def_group(m,g)     task_def_group((m).t,g)
486
#define job_task_def_usemath(m)     task_def_usemath((m).t)
487
#define job_task_def_system(m)      task_def_system((m).t)
488
#define job_task_def_nokill(m)      task_def_nokill((m).t)
489
#define job_task_def_ctrl_jet(m)    task_def_ctrl_jet((m).t)
490
#define job_task_def_period(m,per)  (m).period = (per)
491
#define job_task_def_deadline(m,dl) TIMESPEC_ASSIGN(&((m).deadline),&(dl))
492
#define job_task_def_noexc(m)       (m).noraiseexc = 1
493
#define job_task_def_yesexc(m)      (m).noraiseexc = 0
494
#define job_task_def_joinable(m)    task_def_joinable((m).t)
495
#define job_task_def_unjoinable(m)  task_def_unjoinable((m).t)
496
#define job_task_def_trace(m)       task_def_trace((m).t)
497
#define job_task_def_notrace(m)     task_def_notrace((m).t)
498
 
499
 
500
 
501
 
502
 
503
 
504
 
505
 
506
 
507
 
508
 
509
/* -----------------------------------------------------------------------
510
   -----------------------------------------------------------------------
511
   -----------------------------------------------------------------------
512
   -----------------------------------------------------------------------
513
   RESOURCE MODELS
514
   -----------------------------------------------------------------------
515
   -----------------------------------------------------------------------
516
   -----------------------------------------------------------------------
517
   ----------------------------------------------------------------------- */
518
 
519
 
520
 
521
 
522
 
523
 
524
 
525
/* -----------------------------------------------------------------------
526
   RTYPE values
527
   ----------------------------------------------------------------------- */
528
 
529
/* These are the values for the rtype field of a resource descriptor.
530
   The value in the rtype field is used to distinguish the interface really
531
   implemented by the resource object.
532
 
533
   For example, a mutex resource descriptor "inherit" from a resource_des
534
   and implements also all the mutex functions as "virtual", so a type field
535
   is added to the resource descriptor to distinguish witch interface is
536
   really added. +*/
537
 
538
#define DEFAULT_RTYPE     0  /*+ no fields added to resource_des +*/
539
#define MUTEX_RTYPE       1  /*+ the structure implements a mutex
540
                                 protocol, so a cast to mutex_resource_des
541
                                 is legal +*/
542
 
543
 
544
 
545
/* -----------------------------------------------------------------------
546
   RES_MODEL - the base struct
547
   ----------------------------------------------------------------------- */
548
 
549
/*+
550
 RES_MODEL
551
 
552
 This structure is used like the TASK_MODEL.
553
 It groups together a set of optional parameters describing
554
 the resource model used by a task.
555
 
556
 It contains only a field; the others are model-dependent.
557
+*/
558
 
559
typedef struct {
38 pj 560
  int rclass;        /* protocol */
561
  RLEVEL level;          /* level */
2 pj 562
} RES_MODEL;
563
 
38 pj 564
#define res_default_model(r, p)      (r).rclass = (p), (r).level = 0
565
#define res_def_level(r,l)           (r).level = (l)
2 pj 566
 
567
 
568
 
569
/* -----------------------------------------------------------------------
570
   RCLASS values
571
   ----------------------------------------------------------------------- */
572
 
573
/*+ These are the values for the type field in the resource models
574
    a resource level l that accept a resource model with rclass r
575
    accept also the alias pclass (p | l)
576
    => the LSByte MUST be 0 (256 levels maximum) (as for PCLASS!!!) +*/
577
 
578
#define PC_RCLASS    0x0100
579
#define SRP_RCLASS   0x0200
580
#define SRP2_RCLASS  0x0300
581
 
582
#define BDEDF_RCLASS   0x0400
583
#define BDPSCAN_RCLASS 0x0500
584
 
585
/* -----------------------------------------------------------------------
586
   PC_RES_MODEL: BlockDevice EDF resource model
587
   ----------------------------------------------------------------------- */
588
 
589
typedef struct {
590
  RES_MODEL r;
591
  TIME dl;
592
} BDEDF_RES_MODEL;
593
 
594
#define BDEDF_res_default_model(res) \
595
  res_default_model((res).r,BDEDF_RCLASS); \
596
  (res).dl=0     
597
#define BDEDF_res_def_level(res,l)  res_def_level((res).r,l)     
598
#define BDEDF_res_def_dl(res,reldl)  (res).dl=reldl
599
 
600
/* -----------------------------------------------------------------------
601
   PC_RES_MODEL: BlockDevice PSCAN resource model
602
   ----------------------------------------------------------------------- */
603
 
604
typedef struct {
605
  RES_MODEL r;
606
  int priority;
607
} BDPSCAN_RES_MODEL;
608
 
609
#define BDPSCAN_res_default_model(res) \
610
  res_default_model((res).r,BDPSCAN_RCLASS); \
611
  (res).priority=255     
612
#define BDPSCAN_res_def_level(res,l)  res_def_level((res).r,l)     
613
#define BDPSCAN_res_def_priority(res,pri)  (res).priority=pri
614
 
615
/* -----------------------------------------------------------------------
616
   PC_RES_MODEL: Priority ceiling resource model
617
   ----------------------------------------------------------------------- */
618
 
619
/* the tasks created without using this resource models are assumed to have
620
   priority = MAX_DWORD (the lowest). */
621
 
622
typedef struct {
623
  RES_MODEL r;
624
  DWORD priority;
625
} PC_RES_MODEL;
626
 
627
#define PC_res_default_model(res, prio) \
628
                                 res_default_model((res).r, PC_RCLASS); \
629
                                 (res).priority = (prio)
630
#define PC_res_def_level(res,l)  res_def_level(res,l)
631
 
632
/* -----------------------------------------------------------------------
633
   SRP_RES_MODEL: Stack Resource Policy resource model
634
   ----------------------------------------------------------------------- */
635
 
636
/* the tasks created without using this resource model are not allowed to
637
   lock any SRP mutex. if two of this models are passed to the task_create,
638
   one of them is chosen, in a nondeterministic way, so use only one of
639
   this resource model per task!!!
640
 
641
   The First SRP version uses another resource model that is embedded into
642
   the mutex structure. refer to kernel/modules/srp.c. this second resource
643
   model has the SRP2_RCLASS
644
*/
645
 
646
typedef struct {
647
  RES_MODEL r;
648
  DWORD preempt;  /* the preemption level of a task */
649
} SRP_RES_MODEL;
650
 
651
#define SRP_res_default_model(res, pre) \
652
                                 res_default_model((res).r, SRP_RCLASS); \
653
                                 (res).preempt = (pre)
654
#define SRP_res_def_level(res,l) res_def_level(res,l)
655
 
656
 
657
/* -----------------------------------------------------------------------
658
   MUTEX Attributes
659
   ----------------------------------------------------------------------- */
660
 
661
/*+
662
  MUTEX ATTRIBUTES
663
 
664
  A mutexattr object act as the task model for the tasks in the system:
665
  It specifies the particular options used by a protocol.
666
 
667
  From this basic attribute object many other objects can be derived
668
  as done for the TASK_MODEL. These objects are used to initialize a mutex
669
  with a specified protocol.
670
+*/
671
typedef struct {
672
  int mclass;      /* the protocol type... */
673
} mutexattr_t;
674
 
675
#define mutexattr_default(a, c)  (a).mclass = (c)
676
 
677
 
678
/* -----------------------------------------------------------------------
679
   MCLASS values
680
   ----------------------------------------------------------------------- */
681
 
682
/*+ These are the value for the mclass field;
683
    a mutex level l that accept a task model with mclass m
684
    accept also the alias mclass (m | l)
685
    => the LSByte MUST be 0 (256 levels maximum) +*/
686
 
687
#define NPP_MCLASS      0x0100
688
#define PI_MCLASS       0x0200
689
#define PC_MCLASS       0x0300
690
#define SRP_MCLASS      0x0400
691
#define NOP_MCLASS      0x0500
692
#define NOPM_MCLASS     0x0600
693
 
694
/* -----------------------------------------------------------------------
695
   PI_mutexattr_t: Priority Inheritance Mutex Attribute
696
   ----------------------------------------------------------------------- */
697
 
698
typedef mutexattr_t PI_mutexattr_t;
699
 
700
#define PI_MUTEXATTR_INITIALIZER {PI_MCLASS}
701
#define PI_mutexattr_default(a)  mutexattr_default(a, PI_MCLASS)
702
 
703
/* -----------------------------------------------------------------------
704
   NPP_mutexattr_t: Non Preemptive Protocol Mutex Attribute
705
   ----------------------------------------------------------------------- */
706
 
707
typedef mutexattr_t NPP_mutexattr_t;
708
 
709
#define NPP_MUUEXATTR_INITIALIZER {NPP_MCLASS}
710
#define NPP_mutexattr_default(a)  mutexattr_default(a, NPP_MCLASS)
711
 
712
/* -----------------------------------------------------------------------
713
   PC_mutexattr_t: Priority Ceiling Mutex Attribute
714
   ----------------------------------------------------------------------- */
715
 
716
typedef struct {
717
  mutexattr_t a;
718
  DWORD ceiling;
719
} PC_mutexattr_t;
720
 
721
#define PC_MUTEXATTR_INITIALIZER {{PC_MCLASS},MAX_DWORD}
722
#define PC_mutexattr_default(at,c)  mutexattr_default((at).a, PC_MCLASS); \
723
                                    (at).ceiling = (c)
724
 
725
/* -----------------------------------------------------------------------
726
   SRP_mutexattr_t: Stack Resource Policy Mutex Attribute
727
   ----------------------------------------------------------------------- */
728
 
729
typedef mutexattr_t SRP_mutexattr_t;
730
 
731
#define SRP_MUTEXATTR_INITIALIZER {SRP_MCLASS}
732
#define SRP_mutexattr_default(a)  mutexattr_default(a, SRP_MCLASS)
733
 
734
/* -----------------------------------------------------------------------
735
   NOP_mutexattr_t: No Protocol Mutex Attribute
736
   ----------------------------------------------------------------------- */
737
 
738
typedef mutexattr_t NOP_mutexattr_t;
739
 
740
#define NOP_MUTEXATTR_INITIALIZER {NOP_MCLASS}
741
#define NOP_mutexattr_default(a)  mutexattr_default(a, NOP_MCLASS)
742
 
743
/* -----------------------------------------------------------------------
744
   NOPM_mutexattr_t: No Protocol Multiple lock Mutex Attribute
745
   ----------------------------------------------------------------------- */
746
 
747
typedef mutexattr_t NOPM_mutexattr_t;
748
 
749
#define NOPM_MUTEXATTR_INITIALIZER {NOPM_MCLASS}
750
#define NOPM_mutexattr_default(a)  mutexattr_default(a, NOPM_MCLASS)
751
 
752
 
753
#endif /* __MODEL_H__ */
754