Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1102 → Rev 1094

/demos/trunk/oldexamples/kernel/makefile
7,7 → 7,7
endif
include $(BASE)/config/config.mk
 
PROGS= testc testd teste testf testg
PROGS= test4 test5 test6 test7 test8 testa testc testd teste testf testg
PROGS+= testh testi testj testk testl testm testn testo testp
PROGS+= testq testr tests testu testw testz testss
PROGS+= ptest1 ptest2 ptest3 ptest4 ptest5 ptest6 sysend
15,6 → 15,18
 
include $(BASE)/config/example.mk
 
test4:
make -f $(SUBMAKE) BASE=$(BASE) BASE=$(BASE) APP=test4 INIT=init1.o OTHEROBJS=
test5:
make -f $(SUBMAKE) BASE=$(BASE) APP=test5 INIT=init1.o OTHEROBJS=
test6:
make -f $(SUBMAKE) BASE=$(BASE) APP=test6 INIT=init2.o OTHEROBJS=
test7:
make -f $(SUBMAKE) BASE=$(BASE) APP=test7 INIT=init2.o OTHEROBJS=
test8:
make -f $(SUBMAKE) BASE=$(BASE) APP=test8 INIT=init2.o OTHEROBJS=
testa:
make -f $(SUBMAKE) BASE=$(BASE) APP=testa INIT=init3.o OTHEROBJS=
testc:
make -f $(SUBMAKE) BASE=$(BASE) APP=testc INIT=init4.o OTHEROBJS=
testd:
/demos/trunk/oldexamples/kernel/test7.ori
0,0 → 1,244
/*
* 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: test7.ori,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 $
------------
 
Test Number 7:
 
this is a part of the classic Hartik demo Aster.
 
It checks:
- jet functions
- The EDF level with many task, with almost full bandwidth used
 
**/
 
/*
* 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"
 
int num_aster = 0;
#define ASTER_LIM 60
#define DISPLAY_MAX 15
#define ASTER_MAX 70
#define STAT_Y 9
 
//#define PER_WCET 6200
//#define CLOCK_WCET 100
//#define ASTER_WCET 100
#define PER_WCET 20000
#define CLOCK_WCET 1000
#define ASTER_WCET 1000
 
TASK asteroide(void)
{
int i;
int y = rand() % 7 + 1;
 
int load1,j;
 
char s[2];
 
s[0] = '*'; s[1] = 0;
 
/*for (;;)*/ {
i = 1;
while (i < ASTER_LIM) {
load1 = 10000; // 5000 + rand()%5000;
for (j=0; j<load1; j++) {
s[0] = '*' + rand() % 100;
puts_xy(i,y,rand()%15+1,s);
}
 
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
}
num_aster--;
return 0;
}
 
TASK aster()
{
PID p;
 
HARD_TASK_MODEL m;
int r;
int x; // adaptive bandwidth...
 
hard_task_default_model(m);
hard_task_def_wcet(m,PER_WCET);
hard_task_def_ctrl_jet(m);
 
x = 64;
 
srand(7);
while (1) {
if (num_aster < ASTER_MAX) {
r = (rand() % 200);
 
hard_task_def_arg(m,(void *)((rand() % 7)+1));
hard_task_def_mit(m, (x+r)*1000);
p = task_create("aaa",asteroide,&m,NULL);
if (p == -1)
{
if (x < 500 && errno != ENO_AVAIL_TASK) x += 1;
printf_xy(62,3,WHITE,"adapt=%3u err=%d",freedesc,errno);
}
else {
num_aster++;
printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno);
task_activate(p);
x /= 2;
if (x<50) x = 50;
}
}
task_endcycle();
}
}
 
TASK clock()
{
int s = 0, m = 0;
 
while(1) {
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
 
if (++s > 59) {
s = 0;
m++;
}
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
}
}
 
 
 
/* we consider the first ASTER_MAX + 2 tasks from the PID 2
and plot on the screen the elapsed times... */
TASK jetcontrol()
{
int i; /* a counter */
TIME sum, max, curr, last[5];
int nact;
int j; /* the elements set by jet_gettable */
PID p;
 
 
kern_cli();
printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5");
kern_sti();
 
for (;;) {
for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) {
if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue;
 
for (j=0; j<5; j++) last[j] = 0;
jet_gettable(p, &last[0], 5);
kern_cli();
printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d",
p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]);
kern_sti();
i++;
}
}
}
 
int main(int argc, char **argv)
{
PID p1,p2,p3; //,p4,p5,p6;
HARD_TASK_MODEL m;
NRT_TASK_MODEL m_nrt;
 
hard_task_default_model(m);
hard_task_def_wcet(m,ASTER_WCET);
hard_task_def_mit(m,10000);
hard_task_def_group(m,1);
hard_task_def_ctrl_jet(m);
 
nrt_task_default_model(m_nrt);
nrt_task_def_group(m_nrt,1);
nrt_task_def_ctrl_jet(m_nrt);
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
exit(-1);
}
 
hard_task_def_mit(m,500000);
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
exit(-1);
}
 
p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
if (p2 == -1) {
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
exit(-1);
}
 
group_activate(1);
 
{
struct timespec t;
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
} while (t.tv_sec < 6);
}
//sys_status(SCHED_STATUS);
sys_end();
return 0;
}
 
/demos/trunk/oldexamples/kernel/testa.c
0,0 → 1,308
/*
* 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: testa.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 $
------------
 
Test Number 10 (A):
 
this is a part of the classic Hartik demo Aster.
 
it is based on test 7, with the use of TBS to serve a set of aperiodic
tasks.
 
There are APER_MAX tasks sleeping, and when an asteroide task finish
the current activation, it activate also an aperiodic task chosen
randomly (if the task chosen is already active, the task_activate do
nothing!)
 
 
**/
 
/*
* 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"
 
int num_aster = 0;
#define ASTER_LIM 60
#define DISPLAY_MAX 15
#define ASTER_MAX 70
#define STAT_Y 9
 
#define APER_MAX 8
 
#define PER_WCET 6200
#define APER_WCET 18400
#define CLOCK_WCET 200
#define ASTER_WCET 200
 
#define APER_REP 22000
 
PID aper_table[APER_MAX];
 
TASK asteroide(void)
{
int i;
int y = rand() % 7 + 1;
 
int load1,j;
 
char s[2];
 
s[0] = '*'; s[1] = 0;
 
/*for (;;)*/ {
i = 1;
while (i < ASTER_LIM) {
load1 = 10000; //8000 + rand()%2000;
for (j=0; j<load1; j++) {
s[0] = '*' + rand() % 100;
puts_xy(i,y,rand()%15+1,s);
}
 
task_activate(aper_table[rand()%APER_MAX]);
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
}
num_aster--;
return 0;
}
 
TASK aper_asteroid(void *a)
{
int i;
int y = rand() % 7 + 1;
 
int load1,j;
int c;
 
char s[2];
 
c = (int)a;
s[0] = '*'; s[1] = 0;
 
for (;;) {
i = 1;
while (i < ASTER_LIM) {
load1 = APER_REP; //8000 + rand()%2000;
for (j=0; j<load1; j++) {
s[0] = '*' + rand() % 100;
puts_xy(i,y,rand()%15+1,s);
}
s[0] = c;
puts_xy(i,y,rand()%15+1,s);
 
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
}
}
 
TASK aster()
{
PID p;
 
HARD_TASK_MODEL m;
int r;
int x; // adaptive bandwidth...
 
hard_task_default_model(m);
hard_task_def_wcet(m,PER_WCET);
hard_task_def_ctrl_jet(m);
 
x = 64;
 
srand(7);
while (1) {
if (num_aster < ASTER_MAX) {
r = (rand() % 200);
 
hard_task_def_arg(m,(void *)((rand() % 7)+1));
hard_task_def_mit(m, (x+r)*1000);
p = task_create("aaa",asteroide,&m,NULL);
if (p == -1)
{
if (x < 500 && errno != ENO_AVAIL_TASK) x += 1;
printf_xy(62,3,WHITE,"adapt=%3u err=%d",freedesc,errno);
}
else {
num_aster++;
printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno);
task_activate(p);
x /= 2;
if (x<50) x = 50;
}
}
task_endcycle();
}
}
 
TASK clock()
{
int s = 0, m = 0;
 
while(1) {
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
 
if (++s > 59) {
s = 0;
m++;
}
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
}
}
 
 
 
/* we consider the first ASTER_MAX + 2 tasks from the PID 2
and plot on the screen the elapsed times... */
TASK jetcontrol()
{
int i; /* a counter */
TIME sum, max, curr, last[5];
int nact;
int j; /* the elements set by jet_gettable */
PID p;
 
 
kern_cli();
printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5");
kern_sti();
 
for (;;) {
for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) {
if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue;
 
for (j=0; j<5; j++) last[j] = 0;
jet_gettable(p, &last[0], 5);
kern_cli();
printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d",
p, (int)sum/(nact==0 ? 1 : nact), (int)max, (int)nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]);
kern_sti();
i++;
}
task_endcycle();
}
}
 
int main(int argc, char **argv)
{
PID p1,p2;//,p3,p4,p5,p6;
HARD_TASK_MODEL m;
NRT_TASK_MODEL m_nrt;
SOFT_TASK_MODEL m_aper;
int i;
 
hard_task_default_model(m);
hard_task_def_wcet(m,ASTER_WCET);
hard_task_def_mit(m,10000);
hard_task_def_group(m,1);
hard_task_def_ctrl_jet(m);
 
nrt_task_default_model(m_nrt);
nrt_task_def_group(m_nrt,1);
nrt_task_def_ctrl_jet(m_nrt);
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
}
 
hard_task_def_mit(m,500000);
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
l1_exit(-1);
}
 
soft_task_default_model(m_aper);
soft_task_def_wcet(m_aper,APER_WCET);
soft_task_def_ctrl_jet(m_aper);
soft_task_def_system(m_aper);
soft_task_def_aperiodic(m_aper);
 
soft_task_def_level(m_aper, 2);
aper_table[0] = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (aper_table[0] == -1) {
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
l1_exit(-1);
}
 
for (i=1; i<APER_MAX; i++) {
soft_task_def_level(m_aper, i/4 + 2);
soft_task_def_arg(m_aper, (void *)(i/4 ? 'Û' : '±'));
aper_table[i] = task_create("aper",aper_asteroid,&m_aper,NULL);
if (aper_table[i] == -1) {
perror("test7.c(main): Could not create task <aper> ...");
sys_end();
l1_exit(-1);
}
}
 
 
group_activate(1);
 
{
struct timespec t;
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
} while (t.tv_sec < 6);
}
//sys_status(SCHED_STATUS);
sys_end();
return 0;
}
 
/demos/trunk/oldexamples/kernel/test4.c
0,0 → 1,67
/*
* 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: test4.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 $
------------
 
Test Number 4:
 
this test is a simple main() function
 
This test has to be compiled with init1.c, that introduce 2 RR levels
with a timeslice of 300us (!)
 
This test can be useful to test functions like
 
perror
 
**/
 
/*
* 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"
 
int main(int argc, char **argv)
{
errno = EUNVALID_KILL; kern_printf("code: %d ",errno); perror("EUNVALID_KILL");
errno = EINVAL; kern_printf("code: %d ",errno); perror("EINVAL");
errno = ENOMEDIUM; kern_printf("code: %d ",errno); perror("ENOMEDIUM");
 
return 0;
}
/demos/trunk/oldexamples/kernel/test5.c
0,0 → 1,165
/*
* 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: test5.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 $
------------
 
Test Number 5:
 
this test is a simple main() function with one other task
 
This test has to be compiled with init1.c, that introduce 2 RR levels
with a timeslice of 300us (!)
 
This test can be useful to test functions like
 
sigemptyset
sigaddset
hartik_deliver_pending_signals
sys_end
task_sigmask
sigaction
sigqueue
task_signal
 
 
**/
 
/*
* 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"
 
 
TASK pippo()
{
struct timespec t;
 
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
 
} while (t.tv_nsec <= 20000000L);
cli(); kern_printf("pippo"); sti();
return 0;
}
 
void catchit(int signo, siginfo_t *info, void *extra)
{
kern_printf("\nÛ exec_shadow= %d signo=%d code=%d value=%d p=%d Û\n",
exec_shadow,
info->si_signo, info->si_code,
info->si_value.sival_int, info->si_task);
}
 
 
void catchit2(int signo)
{
kern_printf("\nSignal %d: AAARRRRRRGGGGHHHH!!!!\n",signo);
}
 
int main(int argc, char **argv)
{
struct timespec t;
NRT_TASK_MODEL m;
PID p2;
 
sigset_t newmask;
sigset_t oldmask;
struct sigaction action;
union sigval sval;
 
 
/* Set the signal action */
action.sa_flags = SA_SIGINFO;
action.sa_sigaction = catchit;
action.sa_handler = 0;
action.sa_mask = 0;
 
if (sigaction(SIGUSR1, &action, NULL) == -1) {
perror("Errore");
return -1;
}
 
action.sa_flags = 0;
action.sa_handler = catchit2;
// action.sa_sigaction = SIG_DFL;
 
if (sigaction(SIGILL, &action, NULL) == -1) {
perror("Errore");
return -1;
}
 
/* create another task */
nrt_task_default_model(m);
nrt_task_def_level(m,1);
nrt_task_def_group(m,1);
 
p2 = task_create("pippo", pippo, &m, NULL);
if (p2 == NIL)
{ kern_printf("Can't create pippo task...\n"); return 1; }
 
group_activate(1);
 
/* block the signal for the main task */
sigemptyset(&newmask);
sigaddset(&newmask,SIGUSR1);
task_sigmask(SIG_BLOCK, &newmask, &oldmask);
 
sval.sival_int = 123;
sigqueue(0,SIGUSR1,sval);
sval.sival_int = 999;
sigqueue(0,SIGUSR1,sval);
 
cli();kern_printf("\n()()()()\n"); sti();
 
task_signal(0 /* main */, SIGILL);
 
NULL_TIMESPEC(&t);
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
 
} while (t.tv_nsec <= 50000000L);
 
cli();kern_printf("\n()*********()\n"); sti();
 
return 0;
}
/demos/trunk/oldexamples/kernel/test6.c
0,0 → 1,465
/*
* 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: test6.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 $
------------
 
Test Number 6:
 
this is a part of the classic Hartik demo Aster.
 
It checks:
- EDF module
. periodic tasks
- an high number of task executing concurrently
 
**/
 
/*
* 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
*
*/
 
/*
Well, this is only a stupid demo which intend to show many
HARTIK+ capabilities; the application is structured in the followig
way: there is an ASTER task wich randomly creates some ASTEROID tasks
which are displayed into the first window; each task is HARD/PERIODIC
and auto-kills itself when it reaches the window end!
An other couple of tasks, TITLE & PUT give an example of port
communication facility; the server task creates the port, the client
task connect to it and uses the server to accomplish some stuff.
Port can be declared READ/WRITE and can model ONE-TO-ONE communication
or MANY-TO-ONE communication.
Finally a second couple of tasks realizes a communiation through CABs;
each time a key is pressed, the ascii code is posted into the CAB by the
CCC task while the second task, WRITE, displays it on the screen and
perform other silly actions.
Finally a CLOCK task is implemented to test system clock.
Please note that usually the HARTIK+ application is made up of a task
group which interacts among them, while the main() function, which
became a task itself when the kernel is activated, is suspended until
the system is ready to terminate; the MAIN task can also be used to make
other background activities, but it should not be killed; when the
application terminates, the control is passed to MAIN which kills
everybody, shut down the system and can handle other operations using
the services available with the previou operating system (I.E. the DOS).
If you need to manage sudden abort/exception you should install your own
exception handler and raise it through the exc_raise() primitive to
make the system abort safely!
Remember that the exit functions posted through sys_atexit() will be
executed in both cases, to allow clean system shutdown.
*/
 
//#include <string.h>
//#include <stdlib.h>
 
//#include "hartik.h"
 
//#define __VPAGING__
/* #define __TRACE__ */
 
//#ifdef __TRACE__
//#include "sys\log.h"
//#endif
 
//#include "keyb.h"
//#include "cons.h"
//#include "crtwin.h"
 
#include "kernel/kern.h"
 
 
int num_aster = 0;
#define ASTER_LIM 67
#define ASTER_MAX 90
 
//CAB cc;
//BYTE esc = FALSE;
 
TASK asteroide(void)
{
int i = 1;
int y = rand() % 20 + 1;
while (i < ASTER_LIM) {
puts_xy(i,y,WHITE,"*");
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
num_aster--;
return 0;
}
 
DWORD taskCreated = 0;
 
TASK aster(void)
{
PID p;
 
// MODEL m = BASE_MODEL;
HARD_TASK_MODEL m;
int r;
// WIN w;
 
// win_init(&w,0,0,ASTER_LIM,8);
// win_frame(&w,BLACK,WHITE,"Asteroids",2);
 
 
hard_task_default_model(m);
hard_task_def_wcet(m,500);
 
srand(7);
while (1) {
if (num_aster < ASTER_MAX) {
r = (rand() % 50) - 25;
 
hard_task_def_arg(m,(void *)((rand() % 7)+1));
hard_task_def_mit(m, (50+r)*1000);
p = task_create("aaa",asteroide,&m,NULL);
taskCreated++;
task_activate(p);
num_aster++;
}
 
task_endcycle();
}
}
 
TASK clock()
{
//WIN w;
int s = 0, m = 0;
 
//win_init(&w,68,0,11,2);
//win_frame(&w,BLACK,WHITE,"Clk",1);
 
while(1) {
printf_xy(70,1,WHITE,"%2d : %2d",m,s);
task_endcycle();
 
if (++s > 59) {
s = 0;
m++;
}
printf_xy(70,1,WHITE,"%2d : %2d",m,s);
task_endcycle();
}
}
 
/*
TASK title()
{
PORT t;
WIN w;
int i,pos = 77;
char msg[85],tmp[85],ss[2];
BYTE c;
win_init(&w,0,9,79,2);
win_frame(&w,BLACK,WHITE,"Title",2);
 
for (i=0; i < 77; i++) msg[i] = ' ';
msg[77] = 0;
 
t = port_connect("title",1,STREAM,READ);
 
while (1) {
port_receive(t,&c,BLOCK);
ss[0] = c;
ss[1] = 0;
strcat(msg,ss);
puts_xy(1,10,WHITE,msg);
pos++;
if (pos > 77) {
strcpy(tmp,&(msg[1]));
tmp[pos-1] = 0;
pos -= 1;
strcpy(msg,tmp);
}
task_endcycle();
}
}
 
#define STR "..................... Hartik+ ....................."\
" Guarantees hard tasks "\
" Includes soft periodic tasks "\
"TB server for decrementing the aperiodic response time "\
"SRP for both hard & soft aperiodic tasks "\
"Portability toward other compilers/system "\
"Support for different C compiler: Watcom C 16 bit & 32 bit"\
" -- GNU C (32 bit) -- Borland C (16 bit) -- MS C (16 bit)"\
" "\
"Programmers : Gerardo Lamastra (lamastra@sssup2.sssup.it) "\
" Giuseppe Lipari (lipari@sssup2.sssup.it) "\
"Alpha AXP PCI-33 porting by Antonino Casile "\
"(casile@sssup1.sssup.it) "\
"Research coordinator: Giorgio Buttazzo (giorgio@sssup1.sssup.it)"\
" "\
" "\
" "
 
static char GreetMsg[1600];
 
TASK put(void)
{
PORT p;
 
strcpy(GreetMsg,STR);
p = port_create("title",strlen(GreetMsg),1,STREAM,WRITE);
while(1) {
port_send(p,GreetMsg,BLOCK);
task_endcycle();
}
}
 
TASK ccc(void)
{
WIN w;
char *m;
 
win_init(&w,68,3,10,3);
win_frame(&w,BLACK,WHITE,"CCC",2);
puts_xy(70,4,WHITE,"Cab");
 
while(1) {
m = cab_getmes(cc);
puts_xy(72,5,WHITE,m);
cab_unget(cc,m);
task_endcycle();
}
}
TASK write()
{
BYTE c;
char *msg;
 
while (1) {
c = keyb_getchar();
if (c == ESC) {
esc = TRUE;
task_sleep();
}
else {
#ifdef __VPAGING__
if (c == 's') {
if (get_visual_page() == 0) set_visual_page(1);
else if (get_visual_page() == 1) set_visual_page(0);
}
#endif
msg = cab_reserve(cc);
msg[0] = c;
msg[1] = 0;
cab_putmes(cc,msg);
}
}
}
 
#define DELTA 200000.0
double carico(double rif,BYTE init)
{
double i;
DWORD t1 = 0,t2 = 1000;
double u;
 
i = 0.0;
do {
i += 1;
} while (i <= DELTA);
 
u = i / ((double) (t2 - t1));
 
if (init) return u;
else return (1.0 - u/rif);
}
 
void my_end(KEY_EVT *e)
{
sys_end();
cprintf("Ctrl-Brk pressed!\n");
l1_exit(1);
}
 
void res(void)
{
sys_status(NORM_STATUS|BLOCKED_STATUS|SLEEP_STATUS|IDLE_STATUS);
}
*/
 
int main(int argc, char **argv)
{
PID p1,p2; //,p3,p4,p5,p6;
HARD_TASK_MODEL m;
 
/* MODEL m = BASE_MODEL;
SYS_PARMS sp = BASE_SYS;
KEY_EVT emerg;
double rif;
 
#ifdef __TRACE__
LOG_INFO li = BASE_LOG;
log_set_limit(li,9000);
log_set_name(li,"aster.hrt");
#endif
sys_def_nocheck(sp);
sys_init(&sp);
sys_atexit(res, BEFORE_EXIT);
 
#ifdef __TRACE__
log_init(&li);
#endif
 
keyb_init(NULL);
keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,my_end);
 
#ifdef __VPAGING__
set_active_page(1);
set_visual_page(1);
#endif
CRSR_OFF();
clear();
puts_xy(0,20,WHITE,"Press ESC to exit demo.");
cc = cab_create("Cab",2,2);
*/
 
hard_task_default_model(m);
hard_task_def_mit(m,10000);
hard_task_def_wcet(m,2000);
hard_task_def_group(m,1);
// periodic_task_def_ctrl_jet(m);
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
perror("Aster.C(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
}
 
hard_task_def_mit(m,500000);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
perror("Aster.C(main): Could not create task <Clock> ...");
sys_end();
l1_exit(-1);
}
/* p3 = task_create("Title",title,SOFT,PERIODIC,50,&m);
if (p3 == -1) {
perror();
cprintf("Aster.C(main): Could not create task <Title>\n");
sys_end();
l1_exit(-1);
}
p4 = task_create("Put",put,SOFT,PERIODIC,1000,&m);
if (p4 == -1) {
perror();
cprintf("Aster.C(main): Could not create task <Put>\n");
sys_end();
l1_exit(-1);
}
p5 = task_create("Write",write,NRT,APERIODIC,10,&m);
if (p5 == -1) {
perror();
cprintf("Aster.C(main): Could not create task <Write>\n");
sys_end();
l1_exit(-1);
}
p6 = task_create("CabTask",ccc,HARD,PERIODIC,50,&m);
if (p6 == -1) {
perror();
cprintf("Aster.C(main): Could not create task <CabTask>\n");
sys_end();
l1_exit(-1);
}
#ifdef __TRACE__
log_loop();
#endif
 
task_activate(p1);
task_activate(p2);
task_activate(p3);
task_activate(p4);
task_activate(p5);
task_activate(p6);
 
group_activate(1);
 
while (!esc) {
printf_xy(0,21,WHITE,"Clock : %lu",sys_time());
}
 
#ifdef __TRACE__
log_fix();
#endif
group_kill(1);
clear();
CRSR_STD();
#ifdef __VPAGING__
set_active_page(0);
set_visual_page(0);
#endif
sys_end();
cprintf("System closed\n");
/ *
sys_status(NORM_STATUS|BLOCKED_STATUS|SLEEP_STATUS|IDLE_STATUS);
sys_status(NORM_STATUS|SLEEP_STATUS);
*/
 
group_activate(1);
 
{
struct timespec t;
do {
kern_cli();
ll_gettime(TIME_EXACT,&t);
kern_sti();
} while (t.tv_sec < 6);
}
kern_cli();
sys_status(SCHED_STATUS);
sys_end();
return 0;
}
 
/demos/trunk/oldexamples/kernel/test7.c
0,0 → 1,253
/*
* 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: test7.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 $
------------
 
Test Number 7:
 
this is a part of the classic Hartik demo Aster.
 
It checks:
- jet functions
- The EDF level with many task, with almost full bandwidth used
 
**/
 
/*
* 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"
 
int num_aster = 0;
#define ASTER_LIM 60
#define DISPLAY_MAX 15
#define ASTER_MAX 70
#define STAT_Y 9
 
// first numbers for wcet and periods are for a 486/25, the others for a
// celeron 366
 
#define PER_WCET 13000 /*6200*/
#define CLOCK_WCET 1200 /* 100*/
#define ASTER_WCET 1200 /* 100*/
 
#define ASTER_MEAN_PERIOD 64 /*64*/
 
#define END_TEST_TIME 50
 
TASK asteroide(void)
{
int i;
int y = rand() % 7 + 1;
 
int load1,j;
 
char s[2];
 
s[0] = '*'; s[1] = 0;
 
/*for (;;)*/ {
i = 1;
while (i < ASTER_LIM) {
load1 = 1000; //10000; // 5000 + rand()%5000;
for (j=0; j<load1; j++) {
s[0] = '*' + rand() % 100;
puts_xy(i,y,rand()%15+1,s);
}
 
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
}
num_aster--;
return 0;
}
 
TASK aster()
{
PID p;
 
HARD_TASK_MODEL m;
int r;
int x; // adaptive bandwidth...
 
hard_task_default_model(m);
hard_task_def_wcet(m,PER_WCET);
hard_task_def_ctrl_jet(m);
 
x = ASTER_MEAN_PERIOD;
 
srand(7);
while (1) {
if (num_aster < ASTER_MAX) {
r = (rand() % 200);
 
hard_task_def_arg(m,(void *)((rand() % 7)+1));
hard_task_def_mit(m, (x+r)*1000);
p = task_create("aaa",asteroide,&m,NULL);
if (p == -1)
{
if (x < 500 && errno != ENO_AVAIL_TASK) x += 1;
printf_xy(62,3,WHITE,"adapt=%3u err=%d",freedesc,errno);
}
else {
num_aster++;
printf_xy(62,3,WHITE,"adapt=%3u ",x);//,errno);
task_activate(p);
x /= 2;
if (x<50) x = 50;
}
}
task_endcycle();
}
}
 
TASK clock()
{
int s = 0, m = 0;
 
while(1) {
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
 
if (++s > 59) {
s = 0;
m++;
}
printf_xy(62,1,WHITE,"%2d:%2d ast=%d",m,s, num_aster);
printf_xy(62,2,WHITE,"U=%12u",EDF_usedbandwidth(0));
task_endcycle();
}
}
 
 
 
/* we consider the first ASTER_MAX + 2 tasks from the PID 2
and plot on the screen the elapsed times... */
TASK jetcontrol()
{
int i; /* a counter */
TIME sum, max, curr, last[5];
int nact;
int j; /* the elements set by jet_gettable */
PID p;
 
 
kern_cli();
printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5");
kern_sti();
 
for (;;) {
for (i=0,p=0; i<DISPLAY_MAX+5 && p<MAX_PROC; p++) {
if (jet_getstat(p, &sum, &max, &nact, &curr) == -1) continue;
 
for (j=0; j<5; j++) last[j] = 0;
jet_gettable(p, &last[0], 5);
kern_cli();
printf_xy(0,STAT_Y+i+1,WHITE,"%-3d ³ %-6d ³ %-6d ³ %-4d ³ %-7d ³ %-5d ³ %-5d ³ %-5d ³ %-5d ³ %-5d",
p, (int)sum/(nact==0 ? 1 : nact), (int)max, nact, (int)curr, (int)last[0], (int)last[1], (int)last[2], (int)last[3], (int)last[4]);
kern_sti();
i++;
}
}
}
 
int main(int argc, char **argv)
{
PID p1,p2,p3; //,p4,p5,p6;
HARD_TASK_MODEL m;
NRT_TASK_MODEL m_nrt;
 
hard_task_default_model(m);
hard_task_def_wcet(m,ASTER_WCET);
hard_task_def_mit(m,10000);
hard_task_def_group(m,1);
hard_task_def_ctrl_jet(m);
 
nrt_task_default_model(m_nrt);
nrt_task_def_group(m_nrt,1);
nrt_task_def_ctrl_jet(m_nrt);
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
}
 
hard_task_def_mit(m,500000);
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
l1_exit(-1);
}
 
p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
if (p2 == -1) {
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
l1_exit(-1);
}
 
group_activate(1);
 
{
struct timespec t;
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
} while (t.tv_sec < END_TEST_TIME);
}
//sys_status(SCHED_STATUS);
kern_printf("ora chiamo sys_end\n");
sys_end();
kern_printf("ho chiamato sys_end\n");
return 0;
}
 
 
 
 
/demos/trunk/oldexamples/kernel/test8.c
0,0 → 1,81
/*
* 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: test8.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 $
------------
 
Test Number 8:
 
timer test
 
**/
 
/*
* 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"
 
#define NT 10
 
int main(int argc, char **argv)
{
 
struct timespec t[NT];
int i;
 
kern_printf("Test di correttezza ll_gettime(). dura 1 secondo. ");
 
for (i=0; i<NT; i++) NULL_TIMESPEC(&t[i]);
 
do {
for (i=0; i<NT-1; i++) t[i+1] = t[i];
 
kern_cli();
ll_gettime(TIME_EXACT, &t[0]);
kern_sti();
 
if (TIMESPEC_A_LT_B(&t[0],&t[1])) {
for (i=0; i<NT; i++)
kern_printf("%d %ld\n",i, t[i].tv_nsec);
sys_end();
}
} while (t[0].tv_sec < 1);
 
return 0;
}
 
/demos/trunk/oldexamples/kernel/test9.c
0,0 → 1,234
/*
* 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: test9.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 $
------------
 
Test Number 9:
 
same as Test 7, with 8 TBS tasks running
 
TBS test
 
**/
 
/*
* 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"
 
#if !defined(__TEST1__)
THE TEST REQUIRE THE DEFINITION __TEST1__ IN CONFIG.C
#endif
 
struct timespec s_stime[10000];
struct timespec s_send[10000];
TIME s_curr[10000];
PID s_PID[10000];
int useds=0;
int testactive=1;
 
TASK pippo()
{
int i;
struct timespec t;
int last = 0;
 
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
} while (t.tv_nsec <= 30000000L);
}
 
TASK pippo2()
{
int i;
struct timespec t;
int last = 0;
 
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
 
} while (t.tv_nsec <= 30000000L);
}
 
TASK asteroide(void)
{
int i;
int y = rand() % 7 + 15;
 
int load1,j;
 
char s[2];
 
s[0] = '*'; s[1] = 0;
 
/*for (;;)*/ {
i = 1;
while (i < 60) {
load1 = 10000; //8000 + rand()%2000;
for (j=0; j<load1; j++) {
s[0] = '*' + rand() % 100;
puts_xy(i,y,rand()%15+1,s);
}
 
task_endcycle();
 
if (i==7) testactive = 0;
 
puts_xy(i,y,WHITE," ");
i++;
}
}
//num_aster--;
}
 
TASK aper(void *a)
{
int i;
int y;
 
int load1,j;
 
char s[2];
 
y = (int) a;
 
s[0] = '*'; s[1] = 0;
 
/*for (;;)*/ {
i = 1;
while (i < 60) {
load1 = 100000; //8000 + rand()%2000;
for (j=0; j<load1; j++) {
s[0] = '*' + rand() % 100;
puts_xy(i,y,rand()%15+1,s);
}
 
task_sleep();
 
puts_xy(i,y,WHITE," ");
i++;
}
}
//num_aster--;
}
 
 
int main(int argc, char **argv)
{
struct timespec t;
int i;
NRT_TASK_MODEL m;
HARD_TASK_MODEL m_per;
SOFT_TASK_MODEL m_aper;
PID p1, p2, p3, p4, p5;
int k=1;
 
srand(7);
 
nrt_task_default_model(m);
nrt_task_def_group(m,1);
 
p1 = task_create("pippo", pippo, &m, NULL);
if (p1 == NIL)
{ kern_printf("Can't create pippo task...\n"); sys_end(); }
 
p2 = task_create("pippo2", pippo2, &m, NULL);
if (p2 == NIL)
{ kern_printf("Can't create pippo2 task...\n"); sys_end(); }
 
hard_task_default_model(m_per);
hard_task_def_wcet(m_per,6200);
hard_task_def_mit(m_per,15000);
hard_task_def_group(m_per,1);
p3 = task_create("asteroide", asteroide, &m_per, NULL);
if (p3 == NIL)
{ kern_printf("Can't create asteroide task...\n"); sys_end(); }
 
soft_task_default_model(m_aper);
soft_task_def_wcet(m_aper,62000);
soft_task_def_group(m_aper,1);
soft_task_def_system(m_aper);
soft_task_def_arg(m_aper, 14);
soft_task_def_aperiodic(m_aper);
p4 = task_create("aper", aper, &m_aper, NULL);
if (p4 == NIL)
{ kern_printf("Can't create aper task...%d \n",errno); sys_end(); }
 
soft_task_def_arg(m_aper, 13);
p5 = task_create("aper", aper, &m_aper, NULL);
if (p5 == NIL)
{ kern_printf("Can't create aper(2) task...\n"); sys_end(); }
 
soft_task_def_arg(m_aper, 12);
p5 = task_create("aper", aper, &m_aper, NULL);
if (p5 == NIL)
{ kern_printf("Can't create aper(2) task...\n"); sys_end(); }
 
soft_task_def_arg(m_aper, 11);
p5 = task_create("aper", aper, &m_aper, NULL);
if (p5 == NIL)
{ kern_printf("Can't create aper(2) task...\n"); sys_end(); }
 
// kern_printf("p1=%d p2=%d p3=%d p4=%d\n",p1,p2,p3,p4);
group_activate(1);
 
 
// task_kill(p2);
 
NULL_TIMESPEC(&t);
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
 
// task_kill(p3);
} while (t.tv_sec < 1);
testactive = 0;
/*
kern_printf("FINE MAIN time=%d useds=%d\n",ll_gettime(TIME_EXACT,NULL),useds);
for (i=0; i<useds; i++)
kern_printf("%6d: pid %-9d stime %-9d reschedule %-9d avail %-9d\n",i,
s_PID[i], s_stime[i].tv_nsec, s_send[i].tv_nsec, s_curr[i]);
*/
return 0;
}