Subversion Repositories shark

Rev

Rev 1086 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
 *               Paolo Gai <pj@hartik.sssup.it>
 *
 * Authors     : Marco Caccamo and Paolo Gai
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */


/**
 ------------
 CVS :        $Id: cbs_ft.h,v 1.2 2003-01-07 17:10:16 pj Exp $

 File:        $File$
 Revision:    $Revision: 1.2 $
 Last update: $Date: 2003-01-07 17:10:16 $
 ------------

 This file contains the server CBS_FT

 Read CBS_FT.h for further details.

**/


/*
 * Copyright (C) 2000 Marco Caccamo and Paolo Gai
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


#ifndef __CBS_FT__
#define __CBS_FT__



#include <ll/string.h>
#include <kernel/model.h>
#include <kernel/descr.h>
#include <kernel/var.h>
#include <kernel/func.h>
#include <kernel/trace.h>






/*+ flags... +*/
#define CBS_FT_ENABLE_GUARANTEE      1  /*+ Task Guarantee enabled +*/
#define CBS_FT_ENABLE_ALL            1

#define CBS_FT_FAILED_GUARANTEE      8  /*+ used in the module, unsettable
                                         in EDF_register_level... +*/


#define PRIMARY 1
#define BACKUP 2
#define FT_PCLASS 0x0700 // Nuova classe di task, quelli fault_tolerant

#define CBS_FT_LEVELNAME "CBSFT base"
#define CBS_FT_LEVEL_CODE 110
#define CBS_FT_LEVEL_VERSION 1


/* The Fault-Tolerant Task model extends the base task model
   This model cannot be APERIODIC, only PERIODIC tasks are allowed.
   A faut-tolerant application is composed by two different tasks (primary and
   backup). The backup task is characterized by its WCET and its type (BACKUP).
   The primary task must define the task period, its average execution time
   (used as sort of prediction in order to recharge the budget using the
   capacity cash queue!), the budget (budget / period = U that is, the
   bandwidth assigned to the fault-tolerant application), its type (PRIMARY)
   and finally the PID of the corresponding backup task.        */

   
typedef struct {
  TASK_MODEL t;
 
  TIME wcetB;   // WCET of the backup job (BACKUP TASK ONLY)

  TIME execP;   // average exec. time of the primary job (PRIMARY TASK ONLY)

  TIME period;  // period of the fault-tolerant task (PRIMARY TASK ONLY)

  int  budget;  // amount of guaranteed capacity  (PRIMARY TASK ONLY)

  char type;    // PRIMARY or BACKUP

  PID backup;   // (PRIMARY TASK ONLY)
 
} FT_TASK_MODEL;


#define ft_task_default_model(m)                        \
        task_default_model((m).t,FT_PCLASS),            \
        (m).period = 0,                                \
        (m).wcetB = 0,                                  \
        (m).execP = 0,                                   \
        (m).budget = 0,                                 \
        (m).type = BACKUP,                              \
        (m).backup = NIL


#define ft_task_def_level(m,l) task_def_level((m).t,l)
#define ft_task_def_arg(m,a)   task_def_arg((m).t,a)
#define ft_task_def_stack(m,s) task_def_stack((m).t,s)
#define ft_task_def_stackaddr(m,s) task_def_stackaddr((m).t,s)
#define ft_task_def_usemath(m)    task_def_usemath((m).t)
#define ft_task_def_ctrl_jet(m)   task_def_ctrl_jet((m).t)
#define ft_task_def_group(m,g)   task_def_group((m).t,g)
#define ft_task_def_period(m,o) (m).period = (o)
#define ft_task_def_budget(m,o)   (m).budget = (o)
#define ft_task_def_backup(m)   (m).type = BACKUP
#define ft_task_def_primary(m)   (m).type = PRIMARY
#define ft_task_def_backup_task(m,b)   (m).backup = b
#define ft_task_def_backup_wcet(m,b) (m).wcetB = b
#define ft_task_def_primary_exec(m,b) (m).execP = b    

/************************************************************************/
LEVEL CBS_FT_register_level(int flags, LEVEL master);


bandwidth_t CBS_FT_usedbandwidth(LEVEL l);



/* This function notifies to a primary task that the task itself has to
   suspend its execution (the task has to suspend itself with a
   task_endcycle()   */

char CBS_FT_Checkpoint(void);



/* This function sets the checkpoint flag! hence, at the next checkpoint,
   that is:

   if (CBS_FT_Checkpoint()) {
       task_endcycle();
       continue;
   }

   the primary task will suspend itself switching to the backup task */

void CBS_FT_Primary_Abort(void);

/***************************************************************************/




#endif