Subversion Repositories shark

Rev

Rev 1089 | 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     :
 *   Paolo Gai           <pj@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: test2.c,v 1.2 2003-01-07 17:10:17 pj Exp $

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

 The purpose of this test is to show that two budgets with different
 period and capacity schedules correctly.

 4 periodic tasks are involved
*/


/*
 * Copyright (C) 2002 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
 *
 */


#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "cbsstar.h"
#include "edfstar.h"
#include "modules/rr.h"
#include "modules/dummy.h"

#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"

#include "drivers/keyb.h"


// --------------------------------------------------
// --------------------------------------------------
// Init Part
// --------------------------------------------------
// --------------------------------------------------


/*+ sysyem tick in us +*/
#define TICK 0

/*+ RR tick in us +*/
#define RRTICK 10000

TIME __kernel_register_levels__(void *arg)
{
  struct multiboot_info *mb = (struct multiboot_info *)arg;
  int cbsstar_level, edfstar_level, edfstar_level2, mybudget, mybudget2;
  clear();
  EDF_register_level(EDF_ENABLE_ALL);

  cbsstar_level = CBSSTAR_register_level(3, 0);

  mybudget = CBSSTAR_setbudget(cbsstar_level, 1000, 50000);
  edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level);

  mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000);
  edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level);

  RR_register_level(RRTICK, RR_MAIN_YES, mb);
  dummy_register_level();

  cprintf("edfstar_level=%d, edfstar_level2=%d\n",
          edfstar_level,edfstar_level2);

  // for the keyboard...
  CBS_register_level(CBS_ENABLE_ALL, 0);

  SEM_register_module();

  CABS_register_module();

  return TICK;
}

TASK __init__(void *arg)
{
  struct multiboot_info *mb = (struct multiboot_info *)arg;

  KEYB_PARMS kparms = BASE_KEYB;

  HARTPORT_init();

  KEYB_init(&kparms);

  __call_main__(mb);

  return (void *)0;
}

// --------------------------------------------------
// --------------------------------------------------
// The Test
// --------------------------------------------------
// --------------------------------------------------


#include <kernel/kern.h>
#include <drivers/keyb.h>

void *star(void *arg)
{
  int i,j,z;

  for (i=0; i<100; i++) {
    for (z=0; z<5; z++) {
      for (j=0; j<60000; j++);
      cputs((char *)arg);
    }
    task_endcycle();
  }

  return NULL;
}

// version for the "slow" budget
void *slow(void *arg)
{
  int i,j,z;

  for (i=0; i<15; i++) {
    for (z=0; z<5; z++) {
      for (j=0; j<200000; j++);
      cputs((char *)arg);
    }
    task_endcycle();
  }

  return NULL;
}

void create1()
{
  HARD_TASK_MODEL m1;
  PID p1a, p1b, p1c, p1d;

  hard_task_default_model(m1);
  hard_task_def_wcet(m1, 5000);
  hard_task_def_group(m1,1);
  hard_task_def_periodic(m1);




  hard_task_def_level(m1,2);

  hard_task_def_arg(m1,(void *)".");
  hard_task_def_mit(m1,5000);
  p1a = task_create("a", slow, &m1, NULL);
  if (p1a == -1) {
    perror("Could not create task a ...");
    sys_end();
  }

  hard_task_def_arg(m1,(void *)",");
  hard_task_def_mit(m1,5000);
  p1b = task_create("b", slow, &m1, NULL);
  if (p1b == -1) {
    perror("Could not create task b ...");
    sys_end();
  }




  hard_task_def_level(m1,3);

  hard_task_def_arg(m1,(void *)"o");
  hard_task_def_mit(m1,5000);
  p1c = task_create("c", star, &m1, NULL);
  if (p1c == -1) {
    perror("Could not create task c ...");
    sys_end();
  }

  hard_task_def_arg(m1,(void *)"O");
  hard_task_def_mit(m1,5000);
  p1d = task_create("d", star, &m1, NULL);
  if (p1d == -1) {
    perror("Could not create task d ...");
    sys_end();
  }

  group_activate(1);
}

int main(int argc, char **argv)
{
  char c;

  cprintf("Hello, world!");

  create1();

  do {
    c =keyb_getch(BLOCK);
  } while (c != ESC);

  cprintf("ESC pressed!");

  sys_end();

  return 0;
}