Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

/*
 * Project: S.Ha.R.K.
 *
 * Coordinators:
 *   Giorgio Buttazzo    <giorgio@sssup.it>
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *
 * Authors     :
 *   Paolo Gai           <pj@gandalf.sssup.it>
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
 *   Luca Abeni          <luca@gandalf.sssup.it>
 *   (see the web pages for full authors list)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */



/**
 ------------
 CVS :        $Id: slsh.h,v 1.1 2004-06-01 11:42:47 giacomo Exp $

 File:        $File$
 Revision:    $Revision: 1.1 $
 Last update: $Date: 2004-06-01 11:42:47 $
 ------------
  Author: Tomas Lennvall, Date: Feb 2000.

 This file contains the scheduling module for Slot shifting.

 Title:
   Slot Shifting

 Task Models Accepted:
   STATIC_TASK_MODEL - Periodic Hard tasks that are scheduled by
     an off-line scheduler, so that all guarantees regarding precedence, mutex
     deadline violation is taken care of. The tasks are in an executione schedule,
     that is the order in when they become ready. They have the following fields:
     est (earliest start time), wcet and absolute deadline.
 
   HARD_TASK_MODEL - Hard Tasks (Hard aperiodic requests)
     wcet field and drel field must be != 0. They are used to set the wcet
     and deadline of the tasks.
     periodicity field must be APERIODIC
     mit field is ignored.

  SOFT_TASK_MODEL - Soft Tasks (Unspecified tasks)
    wcet field must be != 0. periodicity filed must be APERIODIC
    period and met filed is ignored.

 Guest Models Accepted:
    NONE - Slot shifting handles all tasks by itself (at this moment).  

 Description:
   This module schedules the offline scheduled tasks according to the slot-
   shifting paradigm, dividing time into slots of a fixed length and assigning
   tasks to execute in those slots. Slot-shifting also keeps track of the free
   bandwidth in the schedule by using disjoint intervals and sc (spare capacity).
   Each interval has a sc nr that represents the free bandwidth in that interval,
   the sc can be used by hard aperiodic tasks, static tasks from later interval or
   soft aperiodic tasks. Hard aperiodic tasks are guaranteed an incorporated in
   the schedule by reduction of sc before they execute. No guarantee is
   performed on the soft aperiodic tasks, they are run when no other task wants
   to execute and sc is available.    

 Description:
  This module implements the Slot shifting algorithm, by Gerhard Fohler. Slot shifting
  schedules off-line scheduled tasks and also handles hard aperiodic requests by the
  guarantee alorithm. Slot shifting can also handle soft aperiodic tasks,
  called unspecified. That is tasks without a deadline.

 Exceptions raised:
   These exceptions are pclass-dependent...
   XDEADLINE_MISS
     If a task miss his deadline, the exception is raised.

   XWCET_VIOLATION
     If a task doesn't end the current cycle before if consume the wcet,
     an exception is raised, and the task is put in the EDF_WCET_VIOLATED
     state. To reactivate it, use EDF_task_activate via task_activate or
     manage directly the EDF data structure. Note that the exception is not
     handled properly, an XDEADLINE_MISS exeeption will also be raised at
     the period end...

 Restrictions & special features:
   - This level doesn't manage the main task.
   - At init time we can choose if the level have to activate
     . the wcet check
       (If a task require more time than declared, it is stopped and put in
        the state EDF_WCET_VIOLATED; a XWCET_VIOLATION exception is raised)
     . the task guarantee algorithm
       (when all task are created the system will check that the task_set
        will not use more than the available bandwidth)
   - The level use the priority and timespec_priority fields.
   - A function to return the used bandwidth of a level is provided.
   - The guest tasks don't provide the guest_endcycle function

**/


/*
 * Copyright (C) 2000 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 __SLSH_H__
#define __SLSH_H__

#include <ll/ll.h>
#include <kernel/config.h>
#include <sys/types.h>
#include <kernel/types.h>

#define STATIC_PCLASS       0x0500

#define SLSH_LEVELNAME          "Slot Shifting"
#define SLSH_LEVEL_CODE         5
#define SLSH_LEVEL_VERSION      1



/* -----------------------------------------------------------------------
   STATIC_TASK_MODEL: offline scheduled Tasks
   ----------------------------------------------------------------------- */

/* Offline-scheduled tasks are hard periodic tasks that have been
    scheduled before runtime. All guarantees are made by the off-
    line scheduler so the tasks are already guaranteed.
*/


typedef struct {
        TASK_MODEL t;
        TIME est;
        TIME wcet;
        TIME dabs;
        int interval;   /* used in slot shifting */
} STATIC_TASK_MODEL;

#define static_task_default_model(m)                             \
                        task_default_model((m).t,STATIC_PCLASS), \
                        (m).est         = -1,                   \
                        (m).dabs        = 0,                   \
                        (m).wcet        = 0,                   \
                        (m).interval    = -1;

#define static_task_def_level(m,l)    task_def_level((m).t,l)
#define static_task_def_arg(m,a)      task_def_arg((m).t,a)
#define static_task_def_stack(m,s)    task_def_stack((m).t,s)
#define static_task_def_group(m,g)    task_def_group((m).t,g)
#define static_task_def_usemath(m)    task_def_usemath((m).t)
#define static_task_def_system(m)     task_def_system((m).t)
#define static_task_def_nokill(m)     task_def_nokill((m).t)
#define static_task_def_ctrl_jet(m)   task_def_ctrl_jet((m).t)
#define static_task_def_est(m,p)      (m).est = (p)
#define static_task_def_dabs(m,d)     (m).dabs = (d)
#define static_task_def_wcet(m,w)     (m).wcet = (w)
#define static_task_def_interval(m,i) (m).interval = (i)
#define static_task_def_trace(m)      task_def_trace((m).t)
#define static_task_def_notrace(m)    task_def_notrace((m).t)




/*#define min(a, b) ((a) < (b) ? (a) : (b))*/

#define TIME2TIMESPEC(T, TS)                    \
(                                                               \
 ((TS).tv_sec = ((T)/1000000)),                 \
 ((TS).tv_nsec = (((T)%1000000) * 1000)),       \
 (TS)                                                           \
)


/* define the interval struct */
typedef struct {
        int start;      /* start of interval */
        int end;        /* end of interval */
        int length; /* Length of interval */
        int maxt;       /* maximum execution time in interval */
        int sc; /* spare capacity in interval */
} SLSH_interval;

/*+ Registration function: */
LEVEL SLSH_register_level();

void SLSH_set_interval(LEVEL l, int start, int end, int maxt);
void SLSH_set_variables(LEVEL l, TIME length);

#endif