Subversion Repositories shark

Rev

Rev 1630 | Rev 1642 | 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"
#include "modules/elastic.h"

extern unsigned int usleep(unsigned int usec); // include file?

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, e4;
  PID el_pid1, el_pid2, el_pid3, el_pid4;
  struct timespec t;

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

  cprintf("Creating elastic task with Tmin = 100000, Tmax = 500000, C = 30000, E = 1\n");
  elastic_task_default_model(e1);
  elastic_task_def_period(e1, 100000, 500000);
  elastic_task_def_wcet(e1, 30000);
  elastic_task_def_param(e1, 1, 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, Tmax = 500000, C = 160000, E = 2\n");
  elastic_task_default_model(e2);
  elastic_task_def_period(e2, 200000, 500000);
  elastic_task_def_wcet(e2, 160000);
  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);

  usleep(500000);

  ELASTIC_set_period(el_pid2, 210000);


  /*
  cprintf("\nCreating elastic task with Tmin = 300000, Tmax = 500000, C = 90000, E = 1\n");
  elastic_task_default_model(e3);
  elastic_task_def_period(e3, 300000, 500000);
  elastic_task_def_wcet(e3, 90000);
  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);

  cprintf("\nCreating elastic task with Tmin = 50000, Tmax = 500000, C = 24000, E = 0\n");
  elastic_task_default_model(e4);
  elastic_task_def_period(e4, 50000, 500000);
  elastic_task_def_wcet(e4, 24000);
  elastic_task_def_param(e4, 0, PERIOD_SCALING);
  elastic_task_def_arg(e4, (void *)4);
  el_pid4 = task_create("Elastic4",elastic_test,&e4,NULL);
  if (el_pid4 == NIL) {
    cprintf("ERROR: Cannot create Elastic4\n");
    sys_end();
  }
  task_activate(el_pid4);
  */

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

}