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: slshtest.c,v 1.1.1.1 2004-05-24 17:54:50 giacomo Exp $
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 17:54:50 $
------------
Slot shifting test
**/
/*
* Copyright (C) 2000 Paolo Gai and Tomas Lennvall
*
* 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/config.h>
#include "kernel/kern.h"
#include "slsh.h"
#include "drivers/keyb.h"
/* a slot length of 100 ms */
#define SLOT_LENGTH 100000
TASK static1(void)
{
int i = 0;
kern_printf("Static1\n");
while(sys_gettime(NULL) < 10000) i++;
return 0;
}
TASK static2(void)
{
int i = 0;
kern_printf("Static2\n");
while(sys_gettime(NULL) < 10000) i++;
return 0;
}
TASK static3(void)
{
kern_printf("Static3\n");
return 0;
}
void my_end(KEY_EVT *e)
{
sys_end();
}
int main(int argc, char** argv)
{
STATIC_TASK_MODEL s;
// HARD_TASK_MODEL h_aper;
// SOFT_TASK_MODEL u;
PID p1,p2,p3;
struct timespec x;
KEY_EVT emerg;
kern_cli();
x.tv_sec=5;
kern_event_post(&x,(void (*)(void *))sys_end,NULL);
kern_sti();
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,my_end);
/* set som variables in the scheduling level */
SLSH_set_interval(0, 0, 8, 5);
SLSH_set_interval(0, 8, 17, 7);
SLSH_set_interval(0, 17, 20, 1);
SLSH_set_variables(0, SLOT_LENGTH);
static_task_default_model(s);
static_task_def_group(s, 1);
/* define time i ms */
/* static1 task */
static_task_def_est(s, 0);
static_task_def_dabs(s, 800000);
static_task_def_wcet(s, 500000);
static_task_def_interval(s, 0);
kern_printf("In main, before task creation\n");
p1 = task_create("Static 1", static1, &s, NULL);
if(p1 == NIL)
kern_printf("Cannot create: Static1!\n");
/* Static2 task */
static_task_def_est(s, 800000);
static_task_def_dabs(s, 1700000);
static_task_def_wcet(s, 700000);
static_task_def_interval(s, 1);
p2 = task_create("Static 2", static2, &s, NULL);
if(p2 == NIL)
kern_printf("Cannot create: Static2!\n");
/* Static3 task */
static_task_def_est(s, 1700000);
static_task_def_dabs(s, 2000000);
static_task_def_wcet(s, 100000);
static_task_def_interval(s, 2);
p3 = task_create("Static3", static3, &s, NULL);
if(p3 == NIL)
kern_printf("Cannot create: Static3!\n");
/* End task */
/*hard_task_default_model(h_aper);
hard_task_def_wcet(h_aper, 100000);
*/
kern_printf("After task creation\n");
group_activate(1);
return 0;
}