Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1376 → Rev 1377

/demos/trunk/base/aster8.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster8.c,v 1.2 2003-01-07 17:10:15 pj Exp $
* CVS : $Id: aster8.c,v 1.3 2004-04-17 11:36:13 giacomo Exp $
 
Test for Sporadic Server (ss):
 
52,8 → 52,11
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/ss.h"
#include "drivers/keyb.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
int num_aster = 0;
#define EDF_LEV 0
#define CBS_LEV 1
96,7 → 99,60
#endif
 
PID p1,p2,p3,p4,p5;
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
return 0;
}
 
int device_drivers_close() {
 
KEYB26_close();
 
INPUT26_close();
 
return 0;
 
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
 
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
 
sys_end();
 
return NULL;
 
}
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
 
shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
sys_end();
}
 
}
 
TASK asteroide(void)
{
int i;
242,7 → 298,6
{
PID p;
 
// HARD_TASK_MODEL m;
SOFT_TASK_MODEL m_soft;
int r;
int x; // adaptive bandwidth...
249,37 → 304,14
 
srand(7);
 
/* periodic_task_default_model(m,0,PER_WCET);
periodic_task_def_ctrl_jet(m);
for (x=0; x<PER_MAX; x++) {
r = (rand() % 200);
periodic_task_def_period(m, (64+r)*1000);
p = task_create("per",asteroide,&m,NULL);
if (p!=-1) task_activate(p);
}
*/
 
soft_task_default_model(m_soft);
soft_task_def_met(m_soft,SOFT_MET);
soft_task_def_ctrl_jet(m_soft);
// soft_task_def_aperiodic(m_soft);
 
x = 128; //64;
 
while (1) {
/* {
PID p;
int x;
p = level_table[0]->level_scheduler(0);
printf_xy(1,8,WHITE," ");
 
x = 0;
do {
printf_xy(3*x+1,8,WHITE,"%3d",p);
p = proc_table[p].next;
x++;
} while (p != NIL);
}
*/
if (num_aster < ASTER_MAX) {
r = (rand() % 200);
 
379,7 → 411,7
 
void fine(KEY_EVT *e)
{
sys_end();
task_activate(shutdown_task_PID);
}
 
void mydummyaper(void) {
410,6 → 442,10
SOFT_TASK_MODEL m_aper;
SOFT_TASK_MODEL m_soft;
 
set_shutdown_task();
 
device_drivers_init();
 
#ifdef PIMUTEX
PI_mutexattr_t a;
#endif
428,11 → 464,12
 
 
KEY_EVT emerg;
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,fine);
emerg.status = KEY_PRESSED;
keyb_hook(emerg,fine,FALSE);
 
clear();
 
448,7 → 485,6
nrt_task_def_group(m_nrt,1);
nrt_task_def_ctrl_jet(m_nrt);
 
 
soft_task_default_model(m_aper);
soft_task_def_group(m_aper,1);
soft_task_def_ctrl_jet(m_aper);
461,12 → 497,11
soft_task_def_ctrl_jet(m_soft);
soft_task_def_aperiodic(m_soft);
 
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
task_activate(shutdown_task_PID);
return 0;
}
 
hard_task_def_mit(m,50000);
473,51 → 508,32
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);
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
task_activate(shutdown_task_PID);
return 0;
}
 
// p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
p3 = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (p3 == -1) {
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
l1_exit(-1);
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
task_activate(shutdown_task_PID);
return 0;
}
 
p4 = task_create("MyDummyAper",(void *(*)(void*))mydummyaper,&m_aper,NULL);
if (p4 == -1) {
perror("Could not create task <MyDummyAper> ...");
sys_end();
l1_exit(-1);
sys_shutdown_message("Could not create task <MyDummyAper> ...");
task_activate(shutdown_task_PID);
return 0;
}
 
p5 = task_create("MyDummyNRT",(void *(*)(void*))mydummynrt,&m_nrt,NULL);
if (p5 == -1) {
perror("Could not create task <MyDummyNRT> ...");
sys_end();
l1_exit(-1);
sys_shutdown_message("Could not create task <MyDummyNRT> ...");
task_activate(shutdown_task_PID);
return 0;
}
/*
aperiodic_task_default_model(m_aper,APER_WCET);
aperiodic_task_def_ctrl_jet(m_aper);
aperiodic_task_def_system(m_aper);
 
for (i=0; i<APER_MAX; i++) {
aperiodic_task_def_level(m_aper, i/4 + 2);
aperiodic_task_def_arg(m_aper, (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);
}
}
*/
// task_nopreempt();
 
 
#ifdef PIMUTEX
PI_mutexattr_default(a);
#endif