Subversion Repositories shark

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

/*
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
 *
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
 *               Gerardo Lamastra <gerardo@sssup.it>
 *
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
 * (see authors.txt for full list of hartik's authors)
 *
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
 *
 * http://www.sssup.it
 * http://retis.sssup.it
 * http://hartik.sssup.it
 */


/**
 ------------
 CVS :        $Id: perf1.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $

 File:        $File$
 Revision:    $Revision: 1.1.1.1 $
 Last update: $Date: 2002-09-02 09:37:48 $
 ------------

 Performance test 1:

 there is one RR task that is preempted N_EDF times by an EDF task.

 the test prints the differences of the execution time.

 the test have to be compiled with the one shot timer, and it does not
 use any init file.

**/


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



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

#define TIMESPEC_N        100
#define RR_N       1000000000
#define EDF_N            2500


TIME __kernel_register_levels__(void *arg)
{
  struct multiboot_info *mb = (struct multiboot_info *)arg;

  EDF_register_level(EDF_ENABLE_ALL);
  RR_register_level(1000*1000*1000, RR_MAIN_NO, mb);
  RR_register_level(10000, RR_MAIN_YES, mb);
  dummy_register_level();

  return 300;
}

void *crash_RR(void *arg);
void *crash_EDF(void *arg);

void *__init__(void *arg)
{
    int i;

    PID p1,p2;

    HARD_TASK_MODEL m_hard;
    NRT_TASK_MODEL  m_nrt;

    TIME t[TIMESPEC_N];

    // JET data
    TIME sum, max, curr;
    int nact;



    hard_task_default_model(m_hard);
    hard_task_def_mit      (m_hard,2000);
    hard_task_def_wcet     (m_hard,1000);
    hard_task_def_group    (m_hard,1);
    hard_task_def_ctrl_jet (m_hard);

    nrt_task_default_model (m_nrt);
    nrt_task_def_group     (m_nrt,1);
    nrt_task_def_ctrl_jet  (m_nrt);

    p1 = task_create("crash_EDF",crash_EDF,&m_hard,NULL);
    if (p1 == -1) {
        perror("Could not create task <crask_EDF> ...");
        sys_end();
    }

    p2 = task_create("crash_RR",crash_RR,&m_nrt,NULL);
    if (p2 == -1) {
        perror("Could not create task <crask_RR> ...");
        sys_end();
    }

    kern_cli();
    /* timespec read time */
    for (i=0; i<TIMESPEC_N; i++) {
      t[i] = ll_gettime(TIME_EXACT, NULL);
    }
    kern_sti();

    kern_printf("\n");
    for (i=0; i<TIMESPEC_N; i++) {
      kern_printf("%d: %ld Û", i, t[i]);
    }
    kern_printf("\n");

    task_activate(p2);

    jet_getstat(p2, &sum, &max, &nact, &curr);
    kern_printf("RR test (alone): sum=%ld, max=%ld, nact=%d, curr=%ld\n",
                sum, max, nact, curr);
    jet_delstat(p2);

    group_activate(1);

    jet_getstat(p2, &sum, &max, &nact, &curr);
    kern_printf("\nRR test  : sum=%ld, max=%ld, nact=%d, curr=%ld\n",
                sum, max, nact, curr);
    jet_getstat(p1, &sum, &max, &nact, &curr);
    kern_printf("EDF test : sum=%ld, max=%ld, nact=%d, curr=%ld\n",
                sum, max, nact, curr);

    sys_end();

    return 0;
}

void *crash_RR(void *arg)
{
  int i;

  for (;;) {
    for (i=0; i<RR_N; i++);
    task_sleep();
  }
  return 0;
}

void *crash_EDF(void *arg)
{
  int i;

  for (;;) {
    for (i=0; i<EDF_N; i++)
      task_endcycle();
    task_sleep();
  }
  return 0;
}

// not used!!!
int main(int argc, char **argv)
{
  return 0;
}