Subversion Repositories shark

Rev

Rev 1628 | Rev 1630 | 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@gandalf.sssup.it>
 *
 * Authors     :
 *   Giacomo Guidi       <giacomo@gandalf.sssup.ti>
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://shark.sssup.it
 */


/*
 * 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
 */


#include "kernel/kern.h"

TASK elastic_test(void *arg) {

  int nbr = (int)arg;

  while(1) {
    cprintf("%d.", nbr);
    task_endcycle();
  }
}

int main(int argc, char **argv)
{
  ELASTIC_TASK_MODEL e1, e2, e3;
  PID el_pid1, el_pid2, el_pid3;

  cprintf("Elastic Task Demo (U=0.5 in initfile.c)\n");

  cprintf("Creating elastic task with Tmin = 100000, C = 20000, E = 0\n");
  elastic_task_default_model(e1);
  elastic_task_def_period(e1, 100000, 100000);
  elastic_task_def_wcet(e1, 20000);
  elastic_task_def_param(e2, 0, PERIOD_SCALING);
  elastic_task_def_arg(e1, (void *)1);
  el_pid1 = task_create("Elastic1",elastic_test,&e1,NULL);
  if (el_pid1 == NIL) {
    cprintf("ERROR: Cannot create Elastic1\n");
    sys_end();
  }
  task_activate(el_pid1);

  cprintf("\nCreating elastic task with Tmin = 200000, C = 80000, E = 2\n");
  elastic_task_default_model(e2);
  elastic_task_def_period(e2, 200000, 400000);
  elastic_task_def_wcet(e2, 80000);
  elastic_task_def_param(e2, 2, PERIOD_SCALING);
  elastic_task_def_arg(e2, (void *)2);
  el_pid2 = task_create("Elastic2",elastic_test,&e2,NULL);
  if (el_pid2 == NIL) {
    cprintf("ERROR: Cannot create Elastic2\n");
    sys_end();
  }
  task_activate(el_pid2);

  cprintf("\nCreating elastic task with Tmin = 400000, C = 40000, E = 1\n");
  elastic_task_default_model(e3);
  elastic_task_def_period(e3, 400000, 2000000);
  elastic_task_def_wcet(e3, 40000);
  elastic_task_def_param(e3, 1, PERIOD_SCALING);
  elastic_task_def_arg(e3, (void *)3);
  el_pid3 = task_create("Elastic3",elastic_test,&e3,NULL);
  if (el_pid3 == NIL) {
    cprintf("ERROR: Cannot create Elastic3\n");
    sys_end();
  }
  task_activate(el_pid3);

 
  /* Exit at time t = 5.0 */
  struct timespec t;
  t.tv_sec = 5;
  t.tv_nsec = 0;
  kern_event_post(&t, (void(*)(void*))sys_end, NULL);
  while(1);
  return 0;

}