Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1377 → Rev 1376

/demos/trunk/base/pcidemo.c
13,6 → 13,7
*/
 
/*
* Copyright (C) 2000 Paolo Gai, Luca Abeni
*
* 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
31,13 → 32,10
*/
 
#include "kernel/kern.h"
#include "unistd.h"
 
#include "drivers/shark_linuxc26.h"
#include "drivers/shark_pci26.h"
 
PID shutdown_task_PID;
 
int device_drivers_init() {
LINUXC26_register_module();
54,45 → 52,21
 
}
 
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();
}
 
}
 
 
int main (int argc, char *argv[])
{
 
set_shutdown_task();
unsigned long long i;
 
device_drivers_init();
 
cprintf("Init Done...\n");
 
sleep(5);
task_activate(shutdown_task_PID);
for (i=0;i<100000000;i++);
 
device_drivers_close();
 
sys_end();
return 0;
 
/demos/trunk/base/ipcidemo.c
26,7 → 26,7
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrupt Server +*/
/*+ Interrup Server */
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
/demos/trunk/base/makefile
9,87 → 9,106
 
PROGS = hello sig time preempt
PROGS += aster aster1 aster2 aster3 aster4 aster5 aster6 aster7 aster8
PROGS += pcidemo
PROGS += pcidemo talk mousfind keycode memtest
PROGS += jointest condtest intsem semdemo pidemo pcdemo srpdemo mdemo
PROGS += ego fly cabs
PROGS += ego fly fly2 cabs sched
 
include $(BASE)/config/example.mk
 
 
# Text applications
hello:
make -f $(SUBMAKE) APP=hello INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=hello INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
time:
make -f $(SUBMAKE) APP=time INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=time INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
sig:
make -f $(SUBMAKE) APP=sig INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=sig INIT= OTHEROBJS="ihello.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
preempt:
make -f $(SUBMAKE) APP=preempt INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=preempt INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
semdemo:
make -f $(SUBMAKE) APP=semdemo INIT= OTHEROBJS="isemdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=semdemo INIT= OTHEROBJS="isemdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
pidemo:
make -f $(SUBMAKE) APP=pidemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=pidemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
pcdemo:
make -f $(SUBMAKE) APP=pcdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=pcdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
srpdemo:
make -f $(SUBMAKE) APP=srpdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=srpdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
mdemo:
make -f $(SUBMAKE) APP=mdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=mdemo INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster:
make -f $(SUBMAKE) APP=aster INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster1:
make -f $(SUBMAKE) APP=aster1 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=aster1 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster2:
make -f $(SUBMAKE) APP=aster2 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=aster2 INIT= OTHEROBJS="iaster1.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster3:
make -f $(SUBMAKE) APP=aster3 INIT= OTHEROBJS="iaster3.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=aster3 INIT= OTHEROBJS="iaster3.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster4:
make -f $(SUBMAKE) APP=aster4 INIT= OTHEROBJS="iaster4.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster4 INIT= OTHEROBJS="iaster4.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster5:
make -f $(SUBMAKE) APP=aster5 INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster5 INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster6:
make -f $(SUBMAKE) APP=aster6 INIT= OTHEROBJS="iaster6.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster6 INIT= OTHEROBJS="iaster6.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster7:
make -f $(SUBMAKE) APP=aster7 INIT= OTHEROBJS="iaster7.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster7 INIT= OTHEROBJS="iaster7.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
aster8:
make -f $(SUBMAKE) APP=aster8 INIT= OTHEROBJS="iaster8.o" OTHERINCL= SHARKOPT="__LINUXC26__ __INPUT__"
make -f $(SUBMAKE) APP=aster8 INIT= OTHEROBJS="iaster8.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
pcidemo:
make -f $(SUBMAKE) APP=pcidemo INIT= OTHEROBJS="ipcidemo.o" OTHERINCL= SHARKOPT="__LINUXC26__ __NEWPCI__"
 
talk:
make -f $(SUBMAKE) APP=talk INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
mousfind:
make -f $(SUBMAKE) APP=mousfind INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
jointest:
make -f $(SUBMAKE) APP=jointest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=jointest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
condtest:
make -f $(SUBMAKE) APP=condtest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=condtest INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
intsem:
make -f $(SUBMAKE) APP=intsem INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=
make -f $(SUBMAKE) APP=intsem INIT= OTHEROBJS="imdemo.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
keycode:
make -f $(SUBMAKE) APP=keycode INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
memtest:
make -f $(SUBMAKE) APP=memtest INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT=__OLDCHAR__
 
# Graphical applications
 
ego:
make -f $(SUBMAKE) APP=ego INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __NEWPCI__ __INPUT__ __FB__"
make -f $(SUBMAKE) APP=ego INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__"
 
fly:
make -f $(SUBMAKE) APP=fly INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __NEWPCI__ __INPUT__ __FB__"
make -f $(SUBMAKE) APP=fly INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__"
 
fly2:
make -f $(SUBMAKE) APP=fly2 INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__"
 
cabs:
make -f $(SUBMAKE) APP=cabs INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __NEWPCI__ __INPUT__ __FB__"
make -f $(SUBMAKE) APP=cabs INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__"
 
sched:
make -f $(SUBMAKE) APP=sched INIT= OTHEROBJS="isched.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__"
 
/demos/trunk/base/readme
26,14 → 26,20
- preempt.c --> simple test for CBS, task_preempt, task_nopreempt, and
save/skip arrivals
- pcidemo.c --> PCI Bus scan
- talk.c --> UDP Unix Talk clone (useful to understand the network driver)
- mousfind.c--> Simple text mouse protocol finder
- jointest.c--> Simple test that uses the task_join primitive
- condtest.c--> Simple test that uses condition variables
- intsem.c --> Simple test that uses internal semaphores
- keycode.c --> Prints Keyboard Keycodes on the screen
- memtest.c --> Do you need to use malloc, kern_alloc & co?
 
Graphical demos:
- fly.c --> Random flies going around the screen
- fly2.c --> fly.c + the fly can die after a while and be recreated
- ego.c --> Periodic tasks that writes a phrease on the screen
- cabs.c --> Example that uses cabs
- sched.c --> Scheduling example (mouse, EDF, RM, DS, PS, TBS)
 
Note on the init files:
- ihello.c (RR+dummy)
42,3 → 48,4
- iaster3.c (EDF+RR+TBS(0.1)+TBS(0.3)+dummy)
- iaster4.c (iaster3+CBS)
- initfile.c (EDF+CBS+RR+dummy, SEMaphores, CABS, HARTPORTs and Keyboard)
- isched.c (Configurable scheduling architecture)
/demos/trunk/base/fly2.c
0,0 → 1,279
/*
* 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: fly2.c,v 1.1 2004-03-30 06:46:08 pj Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2004-03-30 06:46:08 $
------------
**/
 
/*
* Copyright (C) 2000 Paolo Gai and Giorgio Buttazzo
*
* 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
*
*/
 
/*--------------------------------------------------------------*/
/* SIMULATION OF RANDOM FLIES (with death of flies) */
/*--------------------------------------------------------------*/
 
#include <kernel/kern.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <semaphore.h>
#include <stdlib.h>
#include <math.h>
 
#define YMENU 10 /* menu level */
#define XMIN 50
#define XMAX 600
#define YMIN 100
#define YMAX 450
#define VEL 5 /* linear velocity (def. = 5) */
#define ANG 30 /* angolo massimo sterzata (30) */
#define D 3 /* raggio mosca */
#define ESC 27 /* ASCII code of ESCAPE key */
#define MAX_P 35 /* max number of flies */
#define FLYGROUP 1
 
double tick = 1.0; /* system tick = 1 ms */
int fly_period = 40000; /* task period */
int fly_wcet = 1000; /* task wcet */
PID pid;
sem_t mutex;
 
 
sem_t mutex_i; /* mutex to protect i */
int i = 0; /* number of tasks created */
 
 
/*--------------------------------------------------------------*/
 
void draw_fly(int x, int y, int c)
{
sem_wait(&mutex);
grx_disc(x, y, D, c);
sem_post(&mutex);
}
 
void draw_i(void)
{
char s[50];
sem_wait(&mutex_i);
sprintf(s,"i=%d ",i);
sem_post(&mutex_i);
 
sem_wait(&mutex);
grx_text(s, XMIN+200, YMENU+30, 12, 0);
sem_post(&mutex);
}
 
int get_i(void)
{
int j;
sem_wait(&mutex_i);
j = i;
sem_post(&mutex_i);
 
return j;
}
 
void i_minus_1(void)
{
sem_wait(&mutex_i);
i--;
sem_post(&mutex_i);
}
 
void i_plus_1(void)
{
sem_wait(&mutex_i);
i++;
sem_post(&mutex_i);
}
 
 
 
/******************************************************************/
 
TASK fly(void *arg)
{
int x, y;
int ox, oy;
int dx, dy, da;
int teta, col;
int outx, outy;
double r;
int local_i = (int)arg;
int number_of_iterations;
 
x = ox = (XMIN+XMAX)/2;
y = oy = (YMIN+YMAX)/2;
teta = 0;
col = 2 + local_i; /* colore fly */
number_of_iterations = 200;
 
while (number_of_iterations) {
 
da = rand()%(2*ANG) - ANG; /* da = [-ANG,ANG] */
teta += da;
 
if (teta > 360) teta -= 360;
if (teta < 0) teta += 360;
r = (double)teta * PI / 180.;
 
dx = (float)(VEL * cos(r));
dy = (float)(VEL * sin(r));
x += dx;
y += dy;
 
outx = (x >= XMAX) || (x <= XMIN);
outy = (y >= YMAX) || (y <= YMIN);
 
if (outx || outy) {
x = x - dx;
y = y - dy;
if (outx) teta = 180 - teta;
if (outy) teta = -teta;
if (teta > 360) teta -= 360;
if (teta < 0) teta += 360;
r = (double)teta * PI / 180.;
 
dx = (float)(VEL * cos(r));
dy = (float)(VEL * sin(r));
 
x += dx;
y += dy;
}
 
draw_fly(ox, oy, 0);
draw_fly(x, y, col);
ox = x; oy = y;
 
number_of_iterations--;
 
task_endcycle();
}
 
draw_fly(x, y, 0);
 
i_minus_1();
 
draw_i();
return 0;
}
 
/****************************************************************/
 
/* This function is called when the system exits */
void byebye(void *arg)
{
grx_close();
cprintf("Bye Bye!\n");
}
 
/****************************** MAIN ******************************/
 
int main(int argc, char **argv)
{
HARD_TASK_MODEL m;
 
char c; /* character from keyboard */
TIME seme; /* used to init the random seed */
int local_i; /* local copy of i */
 
/* Set the closing function */
sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT);
 
sem_init(&mutex,0,1);
sem_init(&mutex_i,0,1);
 
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
if (grx_open(640, 480, 8) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
 
/* The scenario */
grx_rect(XMIN-D-1, YMIN-D-1, XMAX+D+1, YMAX+D+1, 14);
grx_text("Simulation of Random Flies", XMIN, YMENU+10, 13, 0);
grx_text("SPACE create a fly" , XMIN, YMENU+20, 12, 0);
grx_text("ESC exit to DOS" , XMIN, YMENU+30, 12, 0);
draw_i();
 
 
/* The program waits a space to create a fly */
c = keyb_getch(BLOCK);
 
/* randomize!!!! */
seme = sys_gettime(NULL);
srand(seme);
 
do {
local_i = get_i();
if ((c == ' ') && (local_i < MAX_P)) {
hard_task_default_model(m);
hard_task_def_ctrl_jet (m);
hard_task_def_arg (m, (void *)local_i);
hard_task_def_wcet (m, fly_wcet);
hard_task_def_mit (m, fly_period);
hard_task_def_group (m, FLYGROUP);
hard_task_def_usemath (m);
pid = task_create("fly", fly, &m, NULL);
if (pid == NIL) {
grx_close();
perror("Could not create task <fly>");
sys_abort(1);
}
task_activate(pid);
i_plus_1();
draw_i();
}
c = keyb_getch(BLOCK);
 
} while (c != ESC);
 
sys_end();
 
return 0;
}
 
/*--------------------------------------------------------------*/
/demos/trunk/base/aster6.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster6.c,v 1.4 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster6.c,v 1.3 2004-01-17 18:43:07 giacomo Exp $
 
this is a part of the classic Hartik demo Aster.
 
46,11 → 46,8
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.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 ASTER_LIM 60
#define DISPLAY_MAX 15
87,60 → 84,6
#define ASTER_WCET 2000 /* 200*/
#endif
 
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;
291,6 → 234,15
 
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);
298,6 → 250,20
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);
 
364,6 → 330,7
int j; /* the elements set by jet_gettable */
PID p;
 
 
mutex_lock(&m1);
printf_xy(0,STAT_Y,WHITE,"PID ³ Mean T.³ Max T. ³ N.A. ³ Curr. ³ Last1 ³ Last2 ³ Last3 ³ Last4 ³ Last5");
mutex_unlock(&m1);
393,7 → 360,7
 
void fine(KEY_EVT *e)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
int main(int argc, char **argv)
406,10 → 373,6
// int i;
struct timespec fineprg;
 
set_shutdown_task();
 
device_drivers_init();
 
#ifdef PIMUTEX
PI_mutexattr_t a;
#endif
422,13 → 385,13
NOP_mutexattr_t a;
#endif
 
 
KEY_EVT emerg;
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
emerg.status = KEY_PRESSED;
keyb_hook(emerg,fine,FALSE);
keyb_hook(emerg,fine);
 
clear();
 
455,11 → 418,12
soft_task_def_ctrl_jet(m_soft);
soft_task_def_aperiodic(m_soft);
 
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
}
 
hard_task_def_mit(m,500000);
466,19 → 430,34
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
l1_exit(-1);
}
 
// p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
p3 = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (p3 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
l1_exit(-1);
}
/*
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
/demos/trunk/base/talk.c
0,0 → 1,209
/*
* 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
*/
 
/*
* Copyright (C) 2000 Luca Abeni, 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
*
*
* CVS : $Id: aster1.c,v 1.1 2002/10/28 08:13:37 pj Exp
 
This is the talkdx.c Hartik's example.
 
File: Talk.C
Revision: 1.00
Author: Luca Abeni
 
 
Simple Netlib demo: nothing of seriously real-time, only another Unix
Talk clone.
Read it to see how the UDP/IP layers of the networ library work.
 
*/
 
#include <kernel/kern.h>
#include <string.h>
 
#include <drivers/crtwin.h>
#include <drivers/keyb.h>
 
#include <drivers/udpip.h>
 
 
WIN dbg;
BYTE esc = FALSE;
 
char talk_myipaddr[20];
char talk_toipaddr[20];
 
/*
This non real-time task reads UDP packets from the network and writes
them in a window
*/
TASK scrittore(void)
{
char str[2000];
UDP_ADDR from, local;
WIN displ;
int s,n;
 
/* Connect on the local port #100 */
local.s_port = 100;
s = udp_bind(&local, NULL);
 
/* Open the window */
win_init(&displ,0,0,79,6);
win_frame(&displ,BLACK,WHITE,"Remote",2);
 
while (1) {
/* Clear the buffer for receiving the packet...*/
memset(str, 0, 1999);
/*...and receive the packet (block until a packet arrives */
n = udp_recvfrom(s, str, &from);
win_puts(&displ, str);
}
}
 
/*
This non real-time task reads strings from the keyoard and sends them
to the remote host
*/
TASK write(void)
{
WIN wr;
UDP_ADDR to,local;
char str[80];
int s;
IP_ADDR bindlist[5];
 
/* Create a socket for transitting */
ip_str2addr(talk_myipaddr,&(local.s_addr));
local.s_port = 101;
 
/*
If we want the address of the remote host in the ARP table before
begginning the transmission (to eliminate a possible source of
unpredictability), we can use the bindlist, otherwise we set the
second parameter of udp_bind to NULL
*/
ip_str2addr(talk_toipaddr,&(bindlist[0]));
memset(&(bindlist[1]), 0, sizeof(IP_ADDR));
s = udp_bind(&local, /*bindlist*/NULL);
 
win_init(&wr,0,7,79,6);
win_frame(&wr,BLACK,WHITE,"Local",2);
ip_str2addr(talk_toipaddr,&(to.s_addr));
to.s_port = 100;
sprintf(str,"Local IP address %d.%d.%d.%d\n", local.s_addr.ad[0],
local.s_addr.ad[1], local.s_addr.ad[2],
local.s_addr.ad[3]);
win_puts(&dbg,str);
sprintf(str,"Talk to %d.%d.%d.%d ",to.s_addr.ad[0],to.s_addr.ad[1],
to.s_addr.ad[2],to.s_addr.ad[3]);
win_puts(&dbg,str);
while (1) {
/* Get the string...*/
win_gets(&wr,str,78);
strcat(str,"\n");
/*...and send it!!! */
udp_sendto(s,str,strlen(str)+2,&to);
}
}
 
/* This function is called when the user presses CTRL-C (stops the systems) */
void esci(KEY_EVT *k)
{
esc = TRUE;
cprintf("Ctrl-Brk pressed!\n");
sys_end();
}
 
int main(int argc, char **argv)
{
KEY_EVT k;
 
struct net_model m = net_base;
 
NRT_TASK_MODEL m_nrt;
 
k.flag = CNTL_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,esci);
k.flag = CNTR_BIT;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,esci);
 
clear();
cprintf(" Hartik Talk! Ver. 1.00\n");
 
if (argc != 3) {
cprintf("Hartik Talk usage: talk fromIP toIP\n");
return 0;
}
 
strcpy(talk_myipaddr, argv[1]);
strcpy(talk_toipaddr, argv[2]);
 
/* We want a task for TX mutual exclusion */
net_setmode(m, TXTASK);
/* We use UDP/IP stack */
net_setudpip(m, talk_myipaddr, "255.255.255.255");
/* OK: let's start the NetLib! */
if (net_init(&m) == 1) {
cprintf("Net Init OK...\n");
} else {
cprintf("Net Init Failed...\n");
sys_abort(300);
}
 
 
//dump_irq();
cprintf("\n\n\n\tPress ENTER\n");
while (!esc) {
keyb_getcode(&k,BLOCK);
if (k.ascii == 13) esc = TRUE;
}
 
esc = FALSE;
clear();
win_init(&dbg,0,20,60,3);
win_frame(&dbg,BLACK,WHITE,"Debug",2);
/* Start the sender and receiver tasks...*/
nrt_task_default_model(m_nrt);
task_activate(task_create("aaa",scrittore,&m_nrt,NULL));
task_activate(task_create("bbb",write,&m_nrt,NULL));
return 0;
}
/demos/trunk/base/sched.c
0,0 → 1,472
/*
* 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
*/
 
/*
* Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai, Massimiliano Giorgi
*
* 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
*
*
* CVS : $Id: sched.c,v 1.3 2003-05-01 19:44:07 pj Exp $
 
This demo is derived from the cbsmouse.c Hartik's example.
 
It only prints the task scheduling in graphic mode...
 
There is a parameter to choose the type of scheduling module
to initialize.
 
to init correctly the module and task bandwidth parameters, set the defines
NUM and DEN in initg.c and testg.c and remember the "s" (soft) parameter!!!
 
to plot the deadlines assigned by CBS or TBS, compile cbs.c or tbs.c with
the TESTG define
(gray dots over the mouse line are the deadlines, green dots are CBS
shifts)
 
Note that a lot of times the demo exits with an exception; to avoid
these exception you have to properly tune the task parameters.
 
On a well configured machine, you will notice the little differences
between different servers when moving the mouse ;-)
 
*/
 
#include <kernel/kern.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <drivers/mouse.h>
#include <semaphore.h>
 
/*--------------------------------------------------------------*/
/* TEST ON EDF SCHEDULING */
/*--------------------------------------------------------------*/
 
#define LMOUSE 20
#define LM 40 /* line of main */
#define OFFSET 20 /* initial phase */
#define CHAR_DIM 8 /* Height of chars in pixels */
 
#define DX (640/5-1)
 
int col[3] = {2, 4, 14}; /* colors of timelines */
int lev[3] = {80, 120, 160}; /* level of timelines */
int ptime[3] = {10, 20, 25}; /* number of cycles */
int period[3] = {40, 50,100}; /* tasks' periods */
int tick = 1; /* system tick */
int tscale = 1; /* time scale */
TIME starttime = 0; /* Simulation start time (scaled) */
 
char *title; /* used in initg.c */
 
/* period[] is scaled with a factor of PERIODSCALE usec */
#define PERIODSCALE 5000
 
// update also isched.c!!!
#define NUM 2000
#define DEN 64000
 
sem_t mutex; /* Semaphore for graphix*/
 
//#define IY(y) (480 - y)
#define IY(y) y
 
/*
* mouse cursor
*
*/
 
#define W WHITE
#define R RED
#define G GREEN
#define M MAGENTA
 
/* shape */
 
BYTE mycursor[16*16]= {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,W,W,W,W,0,0,0,0,0,0,W,W,W,W,0,
0,W,M,0,0,0,0,0,0,0,0,0,0,M,W,0,
0,W,0,M,0,0,0,0,0,0,0,0,M,0,W,0,
0,W,0,0,M,0,0,0,0,0,0,M,0,0,W,0,
0,0,0,0,0,M,0,0,0,0,M,0,0,0,0,0,
0,0,0,0,0,0,G,G,G,G,0,0,0,0,0,0,
0,0,0,0,0,0,G,0,0,G,0,0,0,0,0,0,
0,0,0,0,0,0,G,0,0,G,0,0,0,0,0,0,
0,0,0,0,0,0,G,0,0,G,0,0,0,0,0,0,
0,0,0,0,0,0,G,G,G,G,0,0,0,0,0,0,
0,0,0,0,0,0,M,M,M,M,0,0,0,0,0,0,
0,0,0,0,0,0,M,M,M,M,0,0,0,0,0,0,
0,0,0,0,0,M,M,M,M,M,M,0,0,0,0,0,
0,0,0,0,M,M,M,M,M,M,M,M,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
 
#define F 0xff
#define B 0x00
 
/* mask */
BYTE mybkg[16*16]= {
B,B,B,B,B,B,F,F,F,F,B,B,B,B,B,B,
B,0,0,0,0,B,F,F,F,F,B,0,0,0,0,B,
B,0,0,B,B,F,F,F,F,F,B,B,B,0,0,B,
B,0,B,0,B,F,F,F,F,F,F,B,0,B,0,B,
B,0,B,B,0,B,F,F,F,F,B,0,B,B,0,B,
B,B,B,F,B,0,B,B,B,B,0,B,F,B,B,B,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,B,0,0,0,0,0,0,B,F,F,F,F,
F,F,F,B,0,0,0,0,0,0,0,0,B,F,F,F,
F,F,F,B,B,B,B,B,B,B,B,B,B,F,F,F,
};
 
#undef B
#define B 0xff
 
/* bad mask */
BYTE mybadbkg[16*16]= {
B,B,B,B,B,B,F,F,F,F,B,B,B,B,B,B,
B,0,0,0,0,B,F,F,F,F,B,0,0,0,0,B,
B,0,0,B,B,F,F,F,F,F,B,B,B,0,0,B,
B,0,B,0,B,F,F,F,F,F,F,B,0,B,0,B,
B,0,B,B,0,B,F,F,F,F,B,0,B,B,0,B,
B,B,B,F,B,0,B,B,B,B,0,B,F,B,B,B,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,B,B,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,F,B,0,0,0,0,B,F,F,F,F,F,
F,F,F,F,B,0,0,0,0,0,0,B,F,F,F,F,
F,F,F,B,0,0,0,0,0,0,0,0,B,F,F,F,
F,F,F,B,B,B,B,B,B,B,B,B,B,F,F,F,
};
 
/* very bad mask */
BYTE myverybadbkg[16*16]= {
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
};
 
/*--------------------------------------------------------------*/
/* Prints a grid to show task periods during execution */
/*--------------------------------------------------------------*/
 
void print_grid()
{
int i;
int a1, a2, a3;
int temp;
 
a1 = 0;
a2 = 0;
a3 = 0;
temp = 0;
 
grx_text(title, 0, 240-10 ,10, 0);
 
grx_line(OFFSET, lev[0], 639, lev[0], 5);
grx_line(OFFSET, lev[1], 639, lev[1], 5);
grx_line(OFFSET, lev[2], 639, lev[2], 5);
grx_text("T1", 0, lev[0]-8, 9, 0);
grx_text("T2", 0, lev[1]-8, 9, 0);
grx_text("T3", 0, lev[2]-8, 9, 0);
grx_text("MA", 0, LM, 8, 0);
grx_text("MO", 0, LMOUSE, 8, 0);
 
for (i = OFFSET; i < 640; i++) {
if (temp >= a1) {
grx_line(i, lev[0] - 1, i, lev[0] - 20, 3);
a1 += period[0];
}
if (temp >= a2) {
grx_line(i, lev[1] - 1, i, lev[1] - 20, 3);
a2 += period[1];
}
if (temp >= a3) {
grx_line(i, lev[2] - 1, i, lev[2] - 20, 3);
a3 += period[2];
}
temp += tick/tscale;
}
}
 
/*--------------------------------------------------------------*/
/* This function is called at system termination */
/*--------------------------------------------------------------*/
 
void my_end()
{
grx_close();
}
 
/*--------------------------------------------------------------*/
/* GENERIC PERIODIC PROCESS */
/*--------------------------------------------------------------*/
 
TASK color(int k)
{
int i;
DWORD x = OFFSET;
TIME t;
while ( x < 640L) {
for (i = 0; i < ptime[k]; i++) {
 
t = sys_gettime(NULL) / PERIODSCALE;
x = (t - starttime) + OFFSET;
if (x>=640) break;
sem_wait(&mutex);
grx_plot(x, lev[k] - 4, col[k]);
grx_plot(x, lev[k] - 5, col[k]);
grx_plot(x, lev[k] - 6, col[k]);
grx_plot(x, lev[k] - 7, col[k]);
sem_post(&mutex);
while (sys_gettime(NULL)/PERIODSCALE == t);
}
task_endcycle();
}
return 0;
}
 
void my_mouse_handler(MOUSE_EVT *ev)
{
int x;
 
x = (sys_gettime(NULL)/PERIODSCALE - starttime) + OFFSET;
if (x>=640) return;
sem_wait(&mutex);
grx_plot(x, LMOUSE, 8);
sem_post(&mutex);
}
 
/*--------------------------------------------------------------*/
/* MAIN PROCESS */
/*--------------------------------------------------------------*/
 
int main(int argc, char *argv[])
{
int x = OFFSET;
 
MOUSE_PARMS mouse = BASE_MOUSE;
HARD_TASK_MODEL mouse_hard;
SOFT_TASK_MODEL mouse_soft;
NRT_TASK_MODEL mouse_nrt;
 
char c;
KEY_EVT emerg;
 
HARD_TASK_MODEL m_per;
int modenum;
 
if (argc>=3)
switch(*argv[2]) {
case 'h':
/* this is not correct, because it don't remember activations */
hard_task_default_model(mouse_hard);
hard_task_def_mit(mouse_hard,DEN);
hard_task_def_wcet(mouse_hard,NUM);
hard_task_def_system(mouse_hard);
hard_task_def_nokill(mouse_hard);
hard_task_def_aperiodic(mouse_hard);
mouse_def_task(mouse,(TASK_MODEL *)&mouse_hard);
break;
case 's':
soft_task_default_model(mouse_soft);
soft_task_def_wcet(mouse_soft,NUM);
soft_task_def_met(mouse_soft,NUM);
soft_task_def_period(mouse_soft,DEN);
soft_task_def_system(mouse_soft);
soft_task_def_nokill(mouse_soft);
soft_task_def_aperiodic(mouse_soft);
mouse_def_task(mouse,(TASK_MODEL *)&mouse_soft);
break;
case 'n':
/* this is not correct, because it don't remember activations */
nrt_task_default_model(mouse_nrt);
nrt_task_def_system(mouse_nrt);
nrt_task_def_nokill(mouse_nrt);
mouse_def_task(mouse,(TASK_MODEL *)&mouse_nrt);
break;
default:
argc=0;
break;
}
 
/* Serial mous on COM3 */
mouse_def_ms(mouse,2);
 
if (argc>=4) {
period[0]=atoi(argv[3]);
if (period[0]<ptime[0]) period[0]=ptime[0]+5;
}
if (argc>=5) {
period[1]=atoi(argv[4]);
if (period[1]<ptime[1]) period[1]=ptime[1]+5;
}
if (argc>=6) {
period[2]=atoi(argv[5]);
if (period[2]<ptime[2]) period[2]=ptime[2]+5;
}
if (argc<2) {
cprintf("syntax: x testg <config> <mouse-task> [t1] [t2] [t3]\n");
cprintf("where <config> can be:\n");
cprintf("\t0 - EDF + CBS + RR\n");
cprintf("\t1 - RM + PS ( bkg, U=1/16) + RR, no check Ulub < 0.69\n");
cprintf("\t2 - RM + PS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n");
cprintf("\t3 - EDF + PS ( bkg, U=1/16) + RR\n");
cprintf("\t4 - EDF + PS (nobkg, U=1/16) + RR\n");
cprintf("\t5 - EDF + TBS( U=1/16) + RR\n");
cprintf("\t6 - RM + DS ( bkg, U=1/16) + RR, no check Ulub < 0.69\n");
cprintf("\t7 - RM + DS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n");
cprintf("\nwhere <mouse-task> can be:\n");
cprintf("\th - Hard\n");
cprintf("\ts - Soft (understimated wcet)\n");
cprintf("\tn - NRT\n");
sys_end();
return -1;
}
 
if (grx_init() == -1) {
sys_shutdown_message("Error initing GraphLib!!!\n");
sys_end();
}
modenum = grx_getmode(640, 480, 8);
cprintf("Modenum :%d\n", modenum);
 
if (grx_setmode(modenum) == -1) {
sys_shutdown_message("No SetMode!!!\n");
sys_end();
}
 
/* this trick can be useful when debugging ... */
//grx_close();
 
 
 
print_grid();
grx_box(DX*0,240,DX*1-1,479,GREEN);
grx_box(DX*1,240,DX*2-1,479,WHITE);
grx_box(DX*2,240,DX*3-1,479,RED);
grx_box(DX*3,240,DX*4-1,479,MAGENTA);
grx_box(DX*4,240,DX*5-1,479,BLACK);
 
sys_atrunlevel(my_end, NULL, RUNLEVEL_BEFORE_EXIT);
 
/* mutex */
sem_init(&mutex,0,1);
 
/* keyboard */
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,(void (*)(KEY_EVT *))sys_end);
keyb_getchar();
 
/* mouse */
mouse_init(&mouse);
mouse_limit(XMINLIMIT(640,480),
240,
XMAXLIMIT(640,480),
YMAXLIMIT(640,480));
mouse_position(320,280);
mouse_threshold(2);
//grx_setcolor(255,255,255,255);
mouse_grxshape(mycursor,mybkg);
mouse_grxcursor(ENABLE);
mouse_on();
mouse_hook(my_mouse_handler);
 
/* hard task creation */
 
hard_task_default_model(m_per);
hard_task_def_mit(m_per,period[0]*PERIODSCALE);
hard_task_def_wcet(m_per,ptime[0]*PERIODSCALE);
hard_task_def_group(m_per, 1);
//task_def_wcet(m, ptime[0] * sys_tick);
if (task_create("verde", color, &m_per, NULL) == -1) {
sys_shutdown_message("Edf.C(main) Could not create <green>:");
sys_end();
}
hard_task_def_arg(m_per, (void *)1);
hard_task_def_wcet(m_per, ptime[1]*PERIODSCALE);
hard_task_def_mit(m_per,period[1]*PERIODSCALE);
if (task_create("red", color, &m_per, NULL) == -1) {
sys_shutdown_message("Edf.C(main) Could not create <red>:");
sys_end();
}
hard_task_def_arg(m_per, (void *)2);
hard_task_def_wcet(m_per, ptime[2]*PERIODSCALE);
hard_task_def_mit(m_per,period[2]*PERIODSCALE);
if (task_create("yellow", color, &m_per, NULL) == -1) {
sys_shutdown_message("Edf.C(main) Could not create <yellow>:");
sys_end();
}
starttime = sys_gettime(NULL) / PERIODSCALE;
group_activate(1);
 
/* main loop */
while (x < 640L) {
x = (sys_gettime(NULL)/PERIODSCALE - starttime) + OFFSET;
if (x>=640) break;
sem_wait(&mutex);
grx_plot(x, LM, 7);
sem_post(&mutex);
}
 
c = keyb_getchar();
 
sys_end();
return 0;
}
 
/*--------------------------------------------------------------*/
/demos/trunk/base/mousfind.c
0,0 → 1,216
/*
* 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
*/
 
/*
* Copyright (C) 2000 Giorgio Buttazzo, 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
*
*
* CVS : $Id: mousfind.c,v 1.2 2003-03-24 11:18:19 pj Exp $
*/
 
/*
* Copyright (C) 2000 Paolo Gai, Massimiliano Giorgi
*
* 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 <drivers/mouse.h>
#include <drivers/keyb.h>
 
/* don't include this into real applications!!! */
#include <../drivers/oldchar/_mouse.h>
 
int done;
 
void my_mouse_hook(MOUSE_EVT *m)
{
static int buttons=-1;
if (buttons!=m->buttons) {
buttons=m->buttons;
//mouse_off();
if (isLeftButton(*m)) puts_xy(9,22,RED,"active");
else puts_xy(9,22,RED," ");
if (isCentralButton(*m)) puts_xy(9,23,RED,"active");
else puts_xy(9,23,RED," ");
if (isRightButton(*m)) puts_xy(9,24,RED,"active");
else puts_xy(9,24,RED," ");
//mouse_on();
}
 
 
/*
if (tindex>20&&first) {
int i;
cprintf("\nSTART\n");
for (i=0;i<tindex;i++) {
cprintf("%i\n",(int)tdata[i]);
}
for (i=1;i<tindex;i++) {
cprintf("%i ",(int)(tdata[i]-tdata[i-1]));
}
first=0;
}
*/
}
 
int main(int argc,char *argv[])
{
MOUSE_PARMS mouse=BASE_MOUSE;
int ch,running,nm;
int sens=5;
 
/* screen */
clear();
 
nm=0;
while (*vmouse[nm].name!='\0') {
cprintf("%c %s:\t %s\n",(char)('a'+nm),vmouse[nm].name,vmouse[nm].desc);
nm++;
}
 
cprintf("\n[a-%c]\t select a mouse server\n",(char)(nm+'a'-1));
cprintf("[z]\t decrement mouse threshold\n");
cprintf("[x]\t incremnet mouse threshold\n");
cprintf("[1-4]\t COM port\n");
cprintf("[ENTER]\t exit\n");
place(0,20);
cputs("mouse server:\n");
cputs("threshold:\n");
cputs("left :\n");
cputs("central:\n");
cputs("right :");
CRSR_OFF();
 
/* main loop */
running=done=0;
 
mouse_def_ms(mouse,0);
 
while (!done) {
ch=keyb_getch(TRUE);
switch(ch) {
 
/* exit demo */
 
case ENTER:
done = 1;
break;
/* decrement threshold */
 
case 'z':
sens--;
if (sens<2) sens=2;
mouse_threshold(sens);
/* threshold */
place(11,21);
cprintf("%i ",sens);
break;
 
/* increment threshold */
case 'x':
sens++;
if (sens>100) sens=100;
mouse_threshold(sens);
/* threshold */
place(11,21);
cprintf("%i ",sens);
break;
 
/* change mouse protocol */
default:
if (ch>='a'&&ch<='a'+nm-1) {
/* don't use this method to change a mouse protocol */
/* use mouse_def_???? macros instead */
mouse.type=ch-'a';
} else
if (ch>='1'&&ch<='4') {
/* don't use this method to change a mouse com port */
/* use mouse_def_???? macros instead */
mouse.port = ch-'1';
}
else
break;
 
/* check if a mouse server is running... */
if (running) {
/* disable autocursor */
mouse_txtcursor(DISABLE);
/* destroy actual mouse server */
mouse_end();
}
/* mouse server name */
puts_xy(14,20,GREEN," ");
puts_xy(14,20,GREEN,vmouse[mouse.type].name);
/* threshold */
place(11,21);
cprintf("%i ",sens);
/* start a new server */
running=(mouse_init(&mouse)==0?1:0);
/* if running ...*/
if (running) {
/* set mouse limit */
mouse_limit(0,0,cons_columns-1,cons_rows-1);
/* enable autocursor */
mouse_txtcursor(ENABLE|AUTOOFF);
/* hook my function */
mouse_hook(my_mouse_hook);
/* show mouse cursor */
mouse_on();
}
break;
}
}
 
CRSR_STD();
clear();
sys_end();
return 0;
}
/demos/trunk/base/aster1.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster1.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster1.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
this is a reduced verion of the classic Hartik demo Aster.
 
151,7 → 151,7
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <aster> ...");
perror("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
158,7 → 158,7
hard_task_def_mit(m,500000);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <Clock> ...");
perror("Aster.C(main): Could not create task <Clock> ...");
sys_end();
}
 
166,7 → 166,7
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
} while (t.tv_sec < 6);
 
sys_end();
return 0;
/demos/trunk/base/aster3.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster3.c,v 1.4 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster3.c,v 1.3 2003-01-07 17:10:15 pj Exp $
 
Test Number 10 (A):
 
52,7 → 52,7
*/
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules//edf.h"
 
int num_aster = 0;
#define ASTER_LIM 60
250,7 → 250,7
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
}
 
258,7 → 258,7
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
}
 
270,7 → 270,7
soft_task_def_level(m_aper, 2);
aper_table[0] = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (aper_table[0] == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
}
 
279,7 → 279,7
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) {
sys_shutdown_message("test7.c(main): Could not create task <aper> ...");
perror("test7.c(main): Could not create task <aper> ...");
sys_end();
}
}
/demos/trunk/base/aster5.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster5.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster5.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
this is a part of the classic Hartik demo Aster.
 
54,11 → 54,8
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.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 ASTER_LIM 60
#define DISPLAY_MAX 15
96,60 → 93,6
#define ASTER_WCET 2000 /* 200*/
#endif
 
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;
315,6 → 258,20
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);
 
411,7 → 368,7
 
void fine(KEY_EVT *e)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
int main(int argc, char **argv)
424,10 → 381,6
// int i;
struct timespec fineprg;
 
set_shutdown_task();
 
device_drivers_init();
 
#ifdef PIMUTEX
PI_mutexattr_t a;
#endif
441,12 → 394,11
#endif
 
KEY_EVT emerg;
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
emerg.status = KEY_PRESSED;
keyb_hook(emerg,fine,FALSE);
keyb_hook(emerg,fine);
 
clear();
 
476,9 → 428,9
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
}
 
hard_task_def_mit(m,500000);
485,17 → 437,17
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
l1_exit(-1);
}
 
// p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
p3 = task_create("JetControl",jetcontrol,&m_soft,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
l1_exit(-1);
}
/*
aperiodic_task_default_model(m_aper,APER_WCET);
531,6 → 483,7
 
fineprg.tv_sec = 1800;
fineprg.tv_nsec = 0;
//kern_event_post(&fineprg,(void (*)(void *))fine,NULL);
group_activate(1);
return 0;
}
/demos/trunk/base/aster7.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster7.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster7.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
this is a part of the classic Hartik demo Aster.
 
50,12 → 50,9
*/
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules//edf.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 ASTER_LIM 60
#define DISPLAY_MAX 15
74,60 → 71,6
 
PID aper_table[APER_MAX];
 
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;
285,7 → 228,7
 
void fine(KEY_EVT *e)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
 
297,10 → 240,6
SOFT_TASK_MODEL m_aper;
int i;
 
set_shutdown_task();
 
device_drivers_init();
 
KEY_EVT emerg;
 
clear();
311,8 → 250,7
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
emerg.status = KEY_PRESSED;
keyb_hook(emerg,fine,FALSE);
keyb_hook(emerg,fine);
 
hard_task_default_model(m);
hard_task_def_wcet(m,ASTER_WCET);
326,9 → 264,8
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
}
 
hard_task_def_mit(m,500000);
335,9 → 272,8
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
}
 
soft_task_default_model(m_aper);
347,9 → 283,8
soft_task_def_aperiodic(m_aper);
p3 = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (p3 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
}
 
soft_task_def_wcet(m_aper,APER_WCET);
361,9 → 296,8
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) {
sys_shutdown_message("test7.c(main): Could not create task <aper> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <aper> ...");
sys_end();
}
}
 
/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.3 2004-04-17 11:36:13 giacomo Exp $
* CVS : $Id: aster8.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
Test for Sporadic Server (ss):
 
52,11 → 52,8
#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
99,60 → 96,7
#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;
298,6 → 242,7
{
PID p;
 
// HARD_TASK_MODEL m;
SOFT_TASK_MODEL m_soft;
int r;
int x; // adaptive bandwidth...
304,14 → 249,37
 
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);
 
411,7 → 379,7
 
void fine(KEY_EVT *e)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
void mydummyaper(void) {
442,10 → 410,6
SOFT_TASK_MODEL m_aper;
SOFT_TASK_MODEL m_soft;
 
set_shutdown_task();
 
device_drivers_init();
 
#ifdef PIMUTEX
PI_mutexattr_t a;
#endif
464,12 → 428,11
 
 
KEY_EVT emerg;
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
emerg.status = KEY_PRESSED;
keyb_hook(emerg,fine,FALSE);
keyb_hook(emerg,fine);
 
clear();
 
485,6 → 448,7
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);
497,11 → 461,12
soft_task_def_ctrl_jet(m_soft);
soft_task_def_aperiodic(m_soft);
 
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
l1_exit(-1);
}
 
hard_task_def_mit(m,50000);
508,32 → 473,51
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
l1_exit(-1);
}
 
// p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
p3 = task_create("JetControl",jetcontrol,&m_aper,NULL);
if (p3 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
task_activate(shutdown_task_PID);
return 0;
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
l1_exit(-1);
}
 
p4 = task_create("MyDummyAper",(void *(*)(void*))mydummyaper,&m_aper,NULL);
if (p4 == -1) {
sys_shutdown_message("Could not create task <MyDummyAper> ...");
task_activate(shutdown_task_PID);
return 0;
perror("Could not create task <MyDummyAper> ...");
sys_end();
l1_exit(-1);
}
 
p5 = task_create("MyDummyNRT",(void *(*)(void*))mydummynrt,&m_nrt,NULL);
if (p5 == -1) {
sys_shutdown_message("Could not create task <MyDummyNRT> ...");
task_activate(shutdown_task_PID);
return 0;
perror("Could not create task <MyDummyNRT> ...");
sys_end();
l1_exit(-1);
}
/*
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
/demos/trunk/base/cabs.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: cabs.c,v 1.4 2004-04-17 11:36:13 giacomo Exp $
* CVS : $Id: cabs.c,v 1.3 2003-01-07 17:10:15 pj Exp $
*/
 
/*--------------------------------------------------------------*/
43,16 → 43,10
 
#include <kernel/kern.h>
#include <modules/cabs.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
#define NCAB 4 /* max number of CABs */
#define NCAR 26 /* generated characters */
 
91,80 → 85,17
TIME w1[NCAB] = {10000, 10000, 10000, 10000};
TIME w2[NCAB] = {10000, 10000, 10000, 10000};
 
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
FB26_init();
FB26_open(FRAME_BUFFER_DEVICE);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
return 0;
}
 
int device_drivers_close() {
 
FB26_close(FRAME_BUFFER_DEVICE);
 
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();
}
 
}
 
 
/****************************************************************/
 
/* This function is called when Alt-X is pressed.
It simply shutdown the system using sys_end.
Note that the byebye() function is called only if we exit from
the system using sys_end()!!!!
*/
void my_end(KEY_EVT* e)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
/******************************************************************/
183,10 → 114,22
NOT called
*/
 
 
/*--------------------------------------------------------------*/
/* User exit function */
/*--------------------------------------------------------------*/
 
void byebye(void *arg)
{
grx_close();
cprintf("Bye Bye!\n");
}
 
/*--------------------------------------------------------------*/
/* Main task */
/*--------------------------------------------------------------*/
 
 
/****************************** MAIN ******************************/
 
int main(int argc, char **argv)
193,9 → 136,18
{
char c = 0; /* character from keyboard */
 
set_shutdown_task();
/* Set the closing function */
sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT);
 
device_drivers_init();
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
if (grx_open(640, 480, 8) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
 
grx_clear(BLACK);
 
209,7 → 161,7
create_channel(c-'1');
}
task_activate(shutdown_task_PID);
sys_end();
 
return 0;
}
315,9 → 267,9
hard_task_def_usemath (m);
p1[i] = task_create(pname1[i], producer, &m, NULL);
if (p1[i] == NIL) {
sys_shutdown_message("Could not create task <producer>");
task_activate(shutdown_task_PID);
return;
grx_close();
perror("Could not create task <producer>");
sys_abort(1);
}
task_activate(p1[i]);
 
329,9 → 281,9
hard_task_def_usemath (m);
p2[i] = task_create(pname2[i], consumer, &m, NULL);
if (p2[i] == NIL) {
sys_shutdown_message("Could not create task <consumer>");
task_activate(shutdown_task_PID);
return;
grx_close();
perror("Could not create task <consumer>");
sys_abort(1);
}
task_activate(p2[i]);
}
366,3 → 318,5
grx_text(buffer,X2+88,yc+R+16,14,0);
}
 
/*--------------------------------------------------------------*/
 
/demos/trunk/base/fly.c
18,11 → 18,11
 
/**
------------
CVS : $Id: fly.c,v 1.4 2004-04-17 11:36:13 giacomo Exp $
CVS : $Id: fly.c,v 1.3 2003-01-07 17:10:15 pj Exp $
 
File: $File$
Revision: $Revision: 1.4 $
Last update: $Date: 2004-04-17 11:36:13 $
Revision: $Revision: 1.3 $
Last update: $Date: 2003-01-07 17:10:15 $
------------
**/
 
50,17 → 50,12
/*--------------------------------------------------------------*/
 
#include <kernel/kern.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
#include <semaphore.h>
#include <stdlib.h>
#include <math.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
#define YMENU 10 /* menu level */
#define XMIN 50
#define XMAX 600
69,7 → 64,6
#define VEL 5 /* linear velocity (def. = 5) */
#define ANG 30 /* angolo massimo sterzata (30) */
#define D 3 /* raggio mosca */
#undef ESC
#define ESC 27 /* ASCII code of ESCAPE key */
#define MAX_P 35 /* max number of flies */
#define FLYGROUP 1
78,78 → 72,15
int fly_period = 40000; /* task period */
int fly_wcet = 1000; /* task wcet */
PID pid;
sem_t mutex;
 
PID shutdown_task_PID = -1;
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
FB26_init();
FB26_open(FRAME_BUFFER_DEVICE);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
return 0;
}
 
int device_drivers_close() {
 
FB26_close(FRAME_BUFFER_DEVICE);
 
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();
}
 
}
 
/*--------------------------------------------------------------*/
 
void draw_fly(int x, int y, int c)
{
sem_wait(&mutex);
grx_disc(x, y, D, c);
sem_post(&mutex);
}
 
/******************************************************************/
210,6 → 141,15
}
}
 
/****************************************************************/
 
/* This function is called when the system exits */
void byebye(void *arg)
{
grx_close();
cprintf("Bye Bye!\n");
}
 
/****************************** MAIN ******************************/
 
int main(int argc, char **argv)
220,9 → 160,18
int i = 0; /* number of tasks created */
TIME seme; /* used to init the random seed */
 
set_shutdown_task();
/* Set the closing function */
sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT);
 
device_drivers_init();
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
if (grx_open(640, 480, 8) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
 
/* The scenario */
grx_rect(XMIN-D-1, YMIN-D-1, XMAX+D+1, YMAX+D+1, 14);
248,9 → 197,9
hard_task_def_usemath (m);
pid = task_create("fly", fly, &m, NULL);
if (pid == NIL) {
sys_shutdown_message("Could not create task <fly>");
task_activate(shutdown_task_PID);
return 0;
grx_close();
perror("Could not create task <fly>");
sys_abort(1);
}
task_activate(pid);
i++;
259,10 → 208,9
 
} while (c != ESC);
 
task_activate(shutdown_task_PID);
sys_end();
 
return 0;
 
}
 
/*--------------------------------------------------------------*/
/demos/trunk/base/pcdemo.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: pcdemo.c,v 1.3 2004-04-17 11:36:14 giacomo Exp $
* CVS : $Id: pcdemo.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
This test verify the correctness of the PC module.
 
63,9 → 63,11
*/
 
#include "kernel/kern.h"
#include "drivers/keyb.h"
 
mutex_t m0,m1,m2;
 
 
void startJ(void *a)
{
task_activate((PID)a);
121,6 → 123,12
return 0;
}
 
void fine(KEY_EVT *e)
{
sys_end();
}
 
 
int main(int argc, char **argv)
{
struct timespec t;
132,10 → 140,18
PI_mutexattr_t a2;
PC_RES_MODEL r;
 
KEY_EVT emerg;
 
clear();
 
cprintf("Priority Ceiling demo. It ends after 60 sec\n");
cprintf("Priority Ceiling demo. Press Alt-X to exit the demo\n");
 
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,fine);
 
/* ---------------------------------------------------------------------
Task creation
--------------------------------------------------------------------- */
192,12 → 208,7
 
task_activate(p2);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
sys_end();
cprintf("END main\n");
 
return 0;
 
}
/demos/trunk/base/srpdemo.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: srpdemo.c,v 1.3 2004-04-17 11:36:15 giacomo Exp $
* CVS : $Id: srpdemo.c,v 1.2 2003-01-07 17:10:16 pj Exp $
 
This test verify the correctness of the SRP module.
 
62,6 → 62,7
*/
 
#include "kernel/kern.h"
#include "drivers/keyb.h"
 
#include "modules/srp.h"
 
152,6 → 153,12
return 0;
}
 
void fine(KEY_EVT *e)
{
sys_end();
}
 
 
int main(int argc, char **argv)
{
struct timespec t;
164,10 → 171,18
 
PI_mutexattr_t a2;
 
KEY_EVT emerg;
 
clear();
cprintf("Stack resource Policy demo. It ends after 60 sec\n");
cprintf("Stack resource Policy demo. Press Alt-X to exit the demo\n");
 
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,fine);
 
/* ---------------------------------------------------------------------
Mutex creation
--------------------------------------------------------------------- */
178,6 → 193,7
mutex_init(&m2,&a);
mutex_init(&m3,&a);
 
 
/* ---------------------------------------------------------------------
Task creation
--------------------------------------------------------------------- */
224,11 → 240,7
 
task_activate(p2);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 60);
sys_end();
cprintf("END main\n");
 
return 0;
}
/demos/trunk/base/ego.c
18,11 → 18,11
 
/**
------------
CVS : $Id: ego.c,v 1.4 2004-04-17 11:36:13 giacomo Exp $
CVS : $Id: ego.c,v 1.3 2003-01-07 17:10:15 pj Exp $
 
File: $File$
Revision: $Revision: 1.4 $
Last update: $Date: 2004-04-17 11:36:13 $
Revision: $Revision: 1.3 $
Last update: $Date: 2003-01-07 17:10:15 $
------------
**/
 
50,15 → 50,11
/****************************************************************/
 
#include <kernel/kern.h>
#include <drivers/glib.h>
#include <drivers/keyb.h>
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
#include <drivers/shark_fb26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
#include <semaphore.h>
 
#define FRAME_BUFFER_DEVICE 0
 
#define X0 10
 
/* task periods */
74,74 → 70,11
"I am ego2 and I print a character every 200 ms",
"I am ego3 and I print a character every 300 ms"};
 
PID shutdown_task_PID = -1;
/* A semaphore used to access Video Cards in mutual exclusion */
sem_t mutex;
 
/***************************************************************/
 
int device_drivers_init() {
KEYB_PARMS kparms = BASE_KEYB;
LINUXC26_register_module();
 
PCI26_init();
 
keyb_def_ctrlC(kparms, NULL);
INPUT26_init();
 
KEYB26_init(&kparms);
 
FB26_init();
FB26_open(FRAME_BUFFER_DEVICE);
FB26_use_grx(FRAME_BUFFER_DEVICE);
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
return 0;
}
 
int device_drivers_close() {
 
FB26_close(FRAME_BUFFER_DEVICE);
 
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 ego(void *arg)
{
int i = (int)arg;
160,7 → 93,10
 
while (1) {
s[0] = talk[i][j];
sem_wait(&mutex);
/* grx_text("TEST", 100,100,12,0); */
grx_text(s,x,y[i],12+i,0);
sem_post(&mutex);
x += 8;
if (++j == leng) {
j = 0;
176,10 → 112,13
/****************************************************************/
 
/* This function is called when Alt-X is pressed.
It simply shutdown the system using sys_end.
Note that the byebye() function is called only if we exit from
the system using sys_end()!!!!
*/
void my_end(KEY_EVT* e)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
/******************************************************************/
198,6 → 137,12
NOT called
*/
 
void byebye(void *arg)
{
grx_close();
cprintf("Bye Bye!\n");
}
 
/****************************** MAIN ******************************/
 
int main(int argc, char **argv)
206,17 → 151,33
KEY_EVT emerg;
HARD_TASK_MODEL m1, m2, m3;
 
set_shutdown_task();
/* Set the closing function */
sys_atrunlevel(byebye, NULL, RUNLEVEL_BEFORE_EXIT);
 
device_drivers_init();
/* Initializes the semaphore */
sem_init(&mutex,0,1);
 
/* graphic card Initialization */
if (grx_init() < 1) {
sys_abort(1);
}
 
if (grx_open(640, 480, 8) < 0) {
cprintf("GRX Err\n");
sys_abort(1);
}
 
/* set the keyboard handler to exit correctly */
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
emerg.status = KEY_PRESSED;
keyb_hook(emerg,my_end,FALSE);
keyb_hook(emerg,my_end);
 
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTR_BIT;
keyb_hook(emerg,my_end);
 
/* a small banner */
grx_text("EGO Test",8,8,WHITE,0);
grx_text("Press Alt-X to exit",8,16,WHITE,0);
230,9 → 191,9
hard_task_def_group (m1,1);
pid1 = task_create("ego1", ego, &m1, NULL);
if (pid1 == NIL) {
sys_shutdown_message("Could not create task <ego1>");
task_activate(shutdown_task_PID);
return 0;
grx_close();
perror("Could not create task <ego1>");
sys_abort(1);
}
 
/* ego2 creation */
244,9 → 205,9
hard_task_def_group (m2,1);
pid2 = task_create("ego2", ego, &m2, NULL);
if (pid2 == NIL) {
sys_shutdown_message("Could not create task <ego2>");
task_activate(shutdown_task_PID);
return 0;
grx_close();
perror("Could not create task <ego2>");
sys_abort(1);
}
 
/* ego3 creation */
258,9 → 219,9
hard_task_def_group (m3,1);
pid3 = task_create("ego3", ego, &m3, NULL);
if (pid3 == NIL) {
sys_shutdown_message("Could not create task <ego3>");
task_activate(shutdown_task_PID);
return 0;
grx_close();
perror("Could not create task <ego3>");
sys_abort(1);
}
 
/* and finally we activate the three threads... */
/demos/trunk/base/pidemo.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: pidemo.c,v 1.3 2004-04-17 11:36:14 giacomo Exp $
* CVS : $Id: pidemo.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
This test verify the correctness of the PI module.
 
77,8 → 77,6
HARD_TASK_MODEL m;
PID p2,p3;
 
struct timespec t;
 
PI_mutexattr_t a;
 
hard_task_default_model(m);
112,12 → 110,5
mutex_destroy(&m1);
cprintf("main after mutex_destroy\n");
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
 
sys_end();
 
return 0;
 
}
/demos/trunk/base/aster.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster.c,v 1.2 2003-01-07 17:10:15 pj Exp $
 
Author: Gerardo Lamastra
Giuseppe Lipari
76,18 → 76,20
executed in both cases, to allow clean system shutdown.
*/
 
//#include <string.h>
//#include <stdlib.h>
 
#include <kernel/kern.h>
#include <modules/sem.h>
#include <modules/hartport.h>
#include <modules/cabs.h>
#include <drivers/keyb.h>
#include <string.h>
 
 
#define __VPAGING__
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_input26.h>
#include <drivers/shark_keyb26.h>
 
#include <drivers/keyb.h>
#include <drivers/crtwin.h>
 
int num_aster = 0;
95,61 → 97,7
 
CAB cc;
BYTE esc = FALSE;
PID shutdown_task_PID;
 
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 = 1;
251,15 → 199,19
}
}
 
#define STR "..................... S.Ha.R.K. ....................."\
#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)"\
" "\
" "\
342,6 → 294,14
else return (1.0 - u/rif);
}
 
void my_end(KEY_EVT *e)
{
set_active_page(0);
set_visual_page(0);
cprintf("Ctrl-Brk pressed!\n");
sys_end();
}
 
int main(int argc, char **argv)
{
PID p1,p2,p3,p4,p5,p6;
350,17 → 310,22
SOFT_TASK_MODEL m_soft;
NRT_TASK_MODEL m_nrt;
 
KEY_EVT emerg;
// double rif;
struct timespec t;
set_shutdown_task();
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,my_end);
 
device_drivers_init();
 
#ifdef __VPAGING__
set_active_page(1);
set_visual_page(1);
#endif
CRSR_OFF();
clear();
puts_xy(0,20,WHITE,"Press ESC to exit demo.");
382,25 → 347,22
hard_task_def_group(m_per, 1);
p2 = task_create("Clock",clock,&m_per,NULL);
if (p2 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <Clock>");
task_activate(shutdown_task_PID);
return 0;
perror("Aster.C(main): Could not create task <Clock>");
sys_abort(-1);
}
 
soft_task_def_period(m_soft, 50000);
p3 = task_create("Title",title,&m_soft, NULL);
if (p3 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <Title>");
task_activate(shutdown_task_PID);
return 0;
perror("Aster.C(main): Could not create task <Title>");
sys_abort(-1);
}
 
soft_task_def_period(m_soft, 1000000);
p4 = task_create("Put",put,&m_soft, NULL);
if (p4 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <Put>");
task_activate(shutdown_task_PID);
return 0;
perror("Aster.C(main): Could not create task <Put>");
sys_abort(-1);
}
 
nrt_task_default_model(m_nrt);
407,19 → 369,25
nrt_task_def_group(m_nrt, 1);
p5 = task_create("Write",write_keyb,&m_nrt,NULL);
if (p5 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <Write>");
task_activate(shutdown_task_PID);
return 0;
perror("Aster.C(main): Could not create task <Write>");
sys_abort(-1);
}
 
hard_task_def_mit(m_per, 50000);
p6 = task_create("CabTask",ccc,&m_per,NULL);
if (p6 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <CabTask>\n");
task_activate(shutdown_task_PID);
return 0;
perror("Aster.C(main): Could not create task <CabTask>\n");
sys_abort(-1);
}
 
/*
task_activate(p1);
task_activate(p2);
task_activate(p3);
task_activate(p4);
task_activate(p5);
task_activate(p6);
*/
group_activate(1);
 
while (!esc) {
434,9 → 402,12
set_active_page(0);
set_visual_page(0);
#endif
 
task_activate(shutdown_task_PID);
cprintf("System closed\n");
sys_end();
/*
sys_status(NORM_STATUS|BLOCKED_STATUS|SLEEP_STATUS|IDLE_STATUS);
sys_status(NORM_STATUS|SLEEP_STATUS);
*/
return 0;
 
}
 
/demos/trunk/base/jointest.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: jointest.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $
* CVS : $Id: jointest.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
This test verify the correctness of the task_join primitive. (that
function is the same as pthread_join... someday I will change the
65,10 → 65,17
*/
 
#include "kernel/kern.h"
#include "drivers/keyb.h"
 
 
PID j0, j1, j2, j3, j4;
mutex_t m1;
 
void fine(KEY_EVT *e)
{
sys_end();
}
 
TASK J1()
{
int err;
141,10 → 148,16
 
PI_mutexattr_t a;
 
KEY_EVT emerg;
 
int err;
void *ret;
 
struct timespec t;
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,fine);
 
j0 = exec_shadow;
nrt_task_default_model(m);
203,12 → 216,5
 
cprintf("main: join J4 returns %d error %d, exiting\n", (int)ret, err);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
sys_end();
 
return 0;
 
}
/demos/trunk/base/mdemo.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: mdemo.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $
* CVS : $Id: mdemo.c,v 1.1 2002-11-11 08:22:46 pj Exp $
 
This test verify the correctness of the NOP module. It works with the
PI, PC, SRP module, too.
60,6 → 60,7
*/
 
#include "kernel/kern.h"
#include "drivers/keyb.h"
#include "modules/srp.h"
 
mutex_t m0;
106,6 → 107,12
return 0;
}
 
void fine(KEY_EVT *e)
{
sys_end();
}
 
 
int main(int argc, char **argv)
{
struct timespec t;
122,6 → 129,14
PC_RES_MODEL r;
SRP_RES_MODEL srp;
 
KEY_EVT emerg;
 
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,fine);
 
/* ---------------------------------------------------------------------
Mutex creation
--------------------------------------------------------------------- */
179,11 → 194,7
 
task_activate(p2);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 60);
sys_end();
cprintf("END main\n");
 
return 0;
}
/demos/trunk/base/aster4.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster4.c,v 1.2 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster4.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
Test Number 13 (D):
 
80,11 → 80,8
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.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 ASTER_LIM 60
#define DISPLAY_MAX 15
105,60 → 102,8
 
PID aper_table[APER_MAX];
 
PID shutdown_task_PID = -1;
int shutting_down = 0;
 
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;
213,6 → 158,11
s[0] = c;
puts_xy(i,y,rand()%15+1,s);
 
if (shutting_down) {
cprintf("Ending System Task %d\n",exec_shadow);
return 0;
}
 
task_endcycle();
 
puts_xy(i,y,WHITE," ");
325,6 → 275,8
}
}
 
 
 
/* we consider the first ASTER_MAX + 2 tasks from the PID 2
and plot on the screen the elapsed times... */
TASK jetcontrol()
362,9 → 314,15
 
void endfun(KEY_EVT *k)
{
task_activate(shutdown_task_PID);
sys_end();
}
 
void exiting(void *arg)
{
cprintf("System shut down...\n");
shutting_down = 1;
}
 
int main(int argc, char **argv)
{
KEY_EVT k;
375,19 → 333,16
SOFT_TASK_MODEL m_soft;
int i;
 
set_shutdown_task();
 
device_drivers_init();
 
k.flag = 0;
k.scan = KEY_ENT;
k.ascii = 13;
k.status = KEY_PRESSED;
keyb_hook(k, endfun, FALSE);
keyb_hook(k, endfun);
 
clear();
cprintf("Press ENTER to end the demo...");
sys_atrunlevel(exiting, NULL, RUNLEVEL_SHUTDOWN);
 
hard_task_default_model(m);
hard_task_def_wcet(m,ASTER_WCET);
hard_task_def_mit(m,10000);
401,11 → 356,11
soft_task_def_ctrl_jet(m_soft);
soft_task_def_aperiodic(m_soft);
 
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <aster> ...");
task_activate(shutdown_task_PID);
return 0;
perror("aster4.c(main): Could not create task <aster> ...");
sys_end();
}
 
hard_task_def_mit(m,500000);
412,16 → 367,14
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <Clock> ...");
task_activate(shutdown_task_PID);
return 0;
perror("aster4.c(main): Could not create task <Clock> ...");
sys_end();
}
 
p3 = task_create("JetControl",jetcontrol,&m_soft,NULL);
if (p3 == -1) {
sys_shutdown_message("aster4.c(main): Could not create task <JetControl> ...");
task_activate(shutdown_task_PID);
return 0;
perror("aster4.c(main): Could not create task <JetControl> ...");
sys_end();
}
 
soft_task_default_model(m_aper);
435,9 → 388,8
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) {
sys_shutdown_message("aster4.c(main): Could not create task <aper> ...");
task_activate(shutdown_task_PID);
return 0;
perror("aster4.c(main): Could not create task <aper> ...");
sys_end();
}
}
 
/demos/trunk/base/imdemo.c
34,14 → 34,12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: imdemo.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $
* CVS : $Id: imdemo.c,v 1.1 2002-11-11 08:22:45 pj Exp $
**/
 
#include "kernel/kern.h"
 
#include "modules/intdrive.h"
#include "modules/edf.h"
#include "modules/hardcbs.h"
#include "modules/cbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
 
54,25 → 52,23
#include "modules/npp.h"
#include "modules/nop.h"
 
#include "drivers/keyb.h"
 
 
/*+ sysyem tick in us +*/
//#define TICK 1000
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
HCBS_register_level(HCBS_ENABLE_ALL, 1);
CBS_register_level(CBS_ENABLE_ALL, 0);
dummy_register_level();
 
SEM_register_module();
94,9 → 90,10
 
HARTPORT_init();
 
KEYB_init(NULL);
 
__call_main__(mb);
 
return (void *)0;
 
}
 
/demos/trunk/base/memtest.c
0,0 → 1,101
/*
* 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
*/
 
/*
* Copyright (C) 2000 Giorgio Buttazzo, 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
*
*
* CVS : $Id: memtest.c,v 1.1 2002-11-11 08:22:46 pj Exp $
*/
 
/*
* 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 <stdlib.h>
 
int main(int argc, char **argv)
{
void *a;
 
clear();
 
a = malloc(4500);
cprintf("malloc : %ld\n", (DWORD)a);
free(a);
 
kern_cli(); a = DOS_alloc(4500); kern_sti();
cprintf("below 1 M: %ld\n", (DWORD)a);
kern_cli(); DOS_free(a,4500); kern_sti();
 
kern_cli(); a = kern_alloc_aligned(10000,MEMORY_UNDER_16M,10,0); kern_sti();
cprintf("below 16M: %ld\n", (DWORD)a);
kern_cli(); kern_free(a,10000); kern_sti();
 
kern_cli(); a = kern_alloc_aligned(10000,MEMORY_FROM_1M_TO_16M,2,0); kern_sti();
cprintf(">1M <16M : %ld\n", (DWORD)a);
kern_cli(); kern_free(a,10000); kern_sti();
 
kern_cli(); a = kern_alloc(10000); kern_sti();
cprintf("normal : %ld\n", (DWORD)a);
kern_cli(); kern_free(a,10000); kern_sti();
 
kern_cli(); a = kern_alloc_page(MEMORY_UNDER_1M); kern_sti();
cprintf("page <1M : %ld\n", (DWORD)a);
kern_cli(); kern_free_page(a); kern_sti();
 
kern_cli(); a = kern_alloc_page(MEMORY_FROM_1M_TO_16M); kern_sti();
cprintf("p>1<16M : %ld\n", (DWORD)a);
kern_cli(); kern_free_page(a); kern_sti();
 
kern_cli(); a = kern_alloc_page(0); kern_sti();
cprintf("page : %ld\n", (DWORD)a);
kern_cli(); kern_free_page(a); kern_sti();
 
return 0;
}
/demos/trunk/base/intsem.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: intsem.c,v 1.2 2004-04-17 11:36:14 giacomo Exp $
* CVS : $Id: intsem.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
this test is a simple main() function with one other task.
 
80,8 → 80,6
NRT_TASK_MODEL m;
PID p2,p3;
 
struct timespec t;
 
nrt_task_default_model(m);
nrt_task_def_group(m,1);
 
99,11 → 97,5
 
group_activate(1);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
sys_end();
 
return 0;
}
/demos/trunk/base/isched.c
0,0 → 1,207
/*
* 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: isched.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2002-11-11 08:22:45 $
------------
 
System initialization file
 
The tick is set to TICK ms.
 
This file contains the 2 functions needed to initialize the system.
 
These functions register the following levels:
 
an EDF (Earliest Deadline First) level
a RR (Round Robin) level
a CBS (Costant Bandwidth Server) level
a Dummy level
 
It can accept these task models:
 
HARD_TASK_MODEL (wcet+mit) at level 0
NRT_TASK_MODEL at level 1
SOFT_TASK_MODEL (met, period) at level 2
 
This file is similar to the configuration of Hartik 3.3.1
 
**/
 
/*
* 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/rm.h"
 
#include "modules/cbs.h"
#include "modules/tbs.h"
#include "modules/ps.h"
#include "modules/ds.h"
 
#include "modules/rr.h"
#include "modules/rr2.h"
 
#include "modules/dummy.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include "drivers/keyb.h"
 
 
/*+ sysyem tick in us +*/
#define TICK 300
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
 
/* the mouse task use 160 us approx on my Celeron 366 */
#define NUM 2000
#define DEN 64000
//#define DEN 8000
 
//#undef XXX
//#define XXX
 
int argc;
char *argv[100];
 
extern char *title;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
int conf;
 
__compute_args__(mb,&argc, argv);
 
if (argc < 2)
conf = '0'; // default
else
conf = *argv[1];
 
switch (conf) {
case '1':
RM_register_level(0); // NO GUARANTEE!!!
PS_register_level(PS_ENABLE_BACKGROUND, 0, NUM, DEN);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
title = "1 - RM + PS ( bkg, U=1/16) + RR, no check Ulub < 0.69";
break;
 
case '2':
RM_register_level(0); // NO GUARANTEE!!!
PS_register_level(0, 0, NUM, DEN);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
title = "2 - RM + PS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n";
break;
 
case '3':
EDF_register_level(2);
PS_register_level(PS_ENABLE_ALL_EDF, 0, NUM, DEN);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
title = "3 - EDF + PS ( bkg, U=1/16) + RR";
break;
 
case '4':
EDF_register_level(2);
PS_register_level(PS_ENABLE_GUARANTEE_EDF, 0, NUM, DEN);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
title = "4 - EDF + PS (nobkg, U=1/16) + RR";
break;
 
case '5':
EDF_register_level(2);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
TBS_register_level(TBS_ENABLE_ALL, 0, NUM, DEN);
title = "5 - EDF + TBS( U=1/16) + RR";
break;
 
case '6':
RM_register_level(0); // NO GUARANTEE!!!
DS_register_level(DS_ENABLE_BACKGROUND, 0, NUM, DEN);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
title = "6 - RM + DS ( bkg, U=1/16) + RR, no check Ulub < 0.69";
break;
 
case '7':
RM_register_level(0); // NO GUARANTEE!!!
DS_register_level(0, 0, NUM, DEN);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
title = "7 - RM + DS (nobkg, U=1/16) + RR, no check Ulub < 0.69\n";
break;
 
default: // '0'
EDF_register_level(2);
RR2_register_level(RRTICK, RR2_MAIN_YES, mb);
CBS_register_level(CBS_ENABLE_ALL, 0);
title = "0 - EDF + CBS + RR";
}
 
dummy_register_level();
 
SEM_register_module();
 
CABS_register_module();
 
return TICK;
}
 
int main(int argc, char **argv);
 
TASK __init__(void *arg)
{
// struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
KEYB_init(NULL);
 
main(argc,argv);
 
return (void *)0;
}
 
/demos/trunk/base/iaster4.c
16,6 → 16,42
* http://shark.sssup.it
*/
 
/**
------------
CVS : $Id: iaster4.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2002-11-11 08:22:45 $
------------
 
System initialization file
 
The tick is set to TICK ms.
 
This file contains the 2 functions needed to initialize the system.
 
These functions register the following levels:
 
an EDF (Earliest Deadline First) level
a RR (Round Robin) level
a TBS (Total Bandwidth Server) level 0.1 Us
a TBS (Total Bandwidth Server) level 0.3 Us
a CBS (Constant Bandwidth Server) level
a Dummy level
 
The TBS bandwidth is TBS_NUM/TBS_DEN
 
 
It can accept these task models (into () the mandatory fields):
 
HARD_TASK_MODEL (wcet+mit) at level 0
NRT_TASK_MODEL at level 1
SOFT_TASK_MODEL (wcet, periodicity=APERIODIC) at level 2,3
SOFT_TASK_MODEL (met,period) at level 4
 
**/
 
/*
* Copyright (C) 2000 Paolo Gai
*
35,8 → 71,9
*
*/
 
 
 
#include "kernel/kern.h"
#include "modules/intdrive.h"
#include "modules/edf.h"
#include "modules/rr.h"
#include "modules/tbs.h"
43,10 → 80,12
#include "modules/cbs.h"
#include "modules/rrsoft.h"
#include "modules/dummy.h"
#include "drivers/keyb.h"
#include "modules/sem.h"
#include "modules/hartport.h"
 
/*+ sysyem tick in us +*/
//#define TICK 300
#define TICK 0
 
#define RRTICK 5000
53,23 → 92,25
#define TBS_NUM 1
#define TBS_DEN 10
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
TBS_register_level(TBS_ENABLE_ALL, 1, TBS_NUM, TBS_DEN);
TBS_register_level(TBS_ENABLE_ALL, 1, TBS_NUM*3, TBS_DEN);
CBS_register_level(CBS_ENABLE_ALL, 1);
TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM, TBS_DEN);
TBS_register_level(TBS_ENABLE_ALL, 0, TBS_NUM*3, TBS_DEN);
CBS_register_level(CBS_ENABLE_ALL, 0);
 
/* RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD);
RR_register_level(RRTICK, RR_MAIN_NO, mb);
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //cbs
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //tbs
RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_SOFT); //tbs
RR_register_level(RRTICK, RR_MAIN_YES, mb);
*/
 
dummy_register_level();
 
SEM_register_module();
83,6 → 124,8
 
HARTPORT_init();
 
KEYB_init(NULL);
 
__call_main__(mb);
 
return (void *)0;
/demos/trunk/base/iaster6.c
18,11 → 18,11
 
/**
------------
CVS : $Id: iaster6.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $
CVS : $Id: iaster6.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2004-04-17 11:36:13 $
Revision: $Revision: 1.1 $
Last update: $Date: 2002-11-11 08:22:45 $
------------
 
System initialization file
68,8 → 68,6
 
 
#include "kernel/kern.h"
 
#include "modules/intdrive.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/rr.h"
85,6 → 83,9
#include "modules/npp.h"
#include "modules/nop.h"
 
#include "drivers/keyb.h"
 
 
/*+ sysyem tick in us +*/
#define TICK 1000
 
91,20 → 92,14
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
CBS_register_level(CBS_ENABLE_ALL, 1);
PS_register_level(2 /*PS_ENABLE_ALL_EDF*/,1,500,100000);
CBS_register_level(CBS_ENABLE_ALL, 0);
PS_register_level(2 /*PS_ENABLE_ALL_EDF*/,0,500,100000);
dummy_register_level();
 
SEM_register_module();
126,6 → 121,8
 
HARTPORT_init();
 
KEYB_init(NULL);
 
__call_main__(mb);
 
return (void *)0;
/demos/trunk/base/iaster7.c
18,11 → 18,11
 
/**
------------
CVS : $Id: iaster7.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $
CVS : $Id: iaster7.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2004-04-17 11:36:13 $
Revision: $Revision: 1.1 $
Last update: $Date: 2002-11-11 08:22:45 $
------------
 
System initialization file
65,7 → 65,6
 
 
#include "kernel/kern.h"
#include "modules/intdrive.h"
#include "modules/edf.h"
#include "modules/tbs.h"
 
78,27 → 77,37
#include "modules/sem.h"
#include "modules/hartport.h"
 
#include "drivers/keyb.h"
 
#include <ll/stdio.h>
 
 
/*+ sysyem tick in us +*/
#define TICK 0
#define TICK 300
 
#define RRTICK 10000
#define RRTICK 5000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
// EDF_register_level(EDF_ENABLE_ALL);
// PS_register_level(2 /*PS_ENABLE_ALL_EDF*/,0,1000,100000);
// RR_register_level(RRTICK, RR_MAIN_YES, mb);
// TBS_register_level(TBS_ENABLE_ALL, 0, 1, 10);
// PS_register_level(2,0,3000,10000);
// TBS_register_level(TBS_ENABLE_ALL, 0, 3, 10);
 
 
RM_register_level(RM_ENABLE_ALL);
PS_register_level(PS_ENABLE_ALL_RM,1,1000,100000);
PS_register_level(PS_ENABLE_ALL_RM,0,1000,100000);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
PS_register_level(4,1,10000,100000);
PS_register_level(4,1,30000,100000);
PS_register_level(4,0,10000,100000);
PS_register_level(4,0,30000,100000);
 
 
 
dummy_register_level();
 
SEM_register_module();
106,12 → 115,28
return TICK;
}
 
SOFT_TASK_MODEL m;
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
KEYB_PARMS k = BASE_KEYB;
 
soft_task_default_model(m);
soft_task_def_wcet(m,2000);
soft_task_def_met(m,800);
soft_task_def_period(m,25000);
soft_task_def_system(m);
soft_task_def_nokill(m);
soft_task_def_aperiodic(m);
soft_task_def_level(m,4);
keyb_def_task(k,&m);
 
HARTPORT_init();
 
if (KEYB_init(&k) < 0)
cprintf("Error during the init of the Keyboard!!!");
 
__call_main__(mb);
 
return (void *)0;
/demos/trunk/base/iaster8.c
18,11 → 18,11
 
/**
------------
CVS : $Id: iaster8.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $
CVS : $Id: iaster8.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2004-04-17 11:36:13 $
Revision: $Revision: 1.1 $
Last update: $Date: 2002-11-11 08:22:45 $
------------
 
System initialization file
68,7 → 68,6
 
 
#include "kernel/kern.h"
#include "modules/intdrive.h"
#include "modules/rm.h"
#include "modules/edf.h"
#include "modules/cbs.h"
85,6 → 84,9
#include "modules/npp.h"
#include "modules/nop.h"
 
#include "drivers/keyb.h"
 
 
/*+ system tick in us +*/
#define TICK 1000
 
91,16 → 93,10
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
SS_register_level(SS_ENABLE_GUARANTEE_EDF,0,5000,20000);
125,9 → 121,8
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
KEYB_init(NULL);
__call_main__(mb);
return (void *)0;
}
 
/demos/trunk/base/condtest.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: condtest.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $
* CVS : $Id: condtest.c,v 1.1 2002-11-11 08:22:45 pj Exp $
 
This test verify the correctness of the condition variables.
(... it doesn't test all...)
53,7 → 53,9
*/
 
#include "kernel/kern.h"
#include "drivers/keyb.h"
 
 
mutex_t m0;
cond_t c0;
 
95,6 → 97,7
 
TASK j2()
{
// struct timespec t;
 
cprintf("J2: started, waiting t=0.5 sec\n");
while (sys_gettime(NULL) < 500000);
105,6 → 108,7
 
number++;
cond_signal(&c0);
// cond_broadcast(&c0);
 
cprintf("J2: unlocking m0\n");
mutex_unlock(&m0);
120,6 → 124,7
 
number++;
cond_signal(&c0);
// cond_broadcast(&c0);
 
cprintf("J2: unlocking m0\n");
mutex_unlock(&m0);
152,15 → 157,28
return 0;
}
 
void fine(KEY_EVT *e)
{
sys_end();
}
 
 
int main(int argc, char **argv)
{
struct timespec t;
// struct timespec t;
 
NRT_TASK_MODEL m;
 
PI_mutexattr_t a;
 
KEY_EVT emerg;
 
//keyb_set_map(itaMap);
emerg.ascii = 'x';
emerg.scan = KEY_X;
emerg.flag = ALTL_BIT;
keyb_hook(emerg,fine);
 
/* ---------------------------------------------------------------------
Task creation
--------------------------------------------------------------------- */
198,12 → 216,7
 
group_activate(1);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
sys_end();
cprintf("END main\n");
 
return 0;
 
}
/demos/trunk/base/keycode.c
0,0 → 1,80
/*
* 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
*/
 
/*
* Copyright (C) 2000 Giorgio Buttazzo, 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
*
*
* CVS : $Id: keycode.c,v 1.1 2002-11-11 08:22:46 pj Exp $
*/
 
#include <kernel/kern.h>
#include <drivers/keyb.h>
 
int main(int argc, char **argv)
{
KEY_EVT k;
 
clear();
k.ascii = 0;
 
cprintf("Press ESC to end the demo, 2 for itamap, 3 for engmap\n");
while (k.ascii != ESC) {
keyb_getcode(&k,BLOCK);
if (k.ascii == '2') {
keyb_set_map(itaMap);
cprintf("\nItalian Keymap set\n");
}
if (k.ascii == '3') {
keyb_set_map(engMap);
cprintf("\nEnglish Keymap set\n");
}
if (isLeftCtrl(k)) putc_xy(72+0,0,RED,'L');
else putc_xy(72+0,0,RED,' ');
if (isRightCtrl(k)) putc_xy(72+1,0,RED,'R');
else putc_xy(72+1,0,RED,' ');
if (isLeftAlt(k)) putc_xy(72+2,0,GREEN,'L');
else putc_xy(72+2,0,RED,' ');
if (isRightAlt(k)) putc_xy(72+3,0,GREEN,'R');
else putc_xy(72+3,0,RED,' ');
if (isLeftShift(k)) putc_xy(72+4,0,YELLOW,'L');
else putc_xy(72+4,0,RED,' ');
if (isRightShift(k)) putc_xy(72+5,0,YELLOW,'R');
else putc_xy(72+5,0,RED,' ');
cprintf("%d [%c]\t",k.scan,k.ascii);
 
}
 
sys_end();
return 0;
}
/demos/trunk/base/semdemo.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: semdemo.c,v 1.2 2004-04-17 11:36:15 giacomo Exp $
* CVS : $Id: semdemo.c,v 1.1 2002-11-11 08:22:46 pj Exp $
 
This is a really simple semaphore demo.
 
74,8 → 74,6
NRT_TASK_MODEL m;
PID p2,p3;
 
struct timespec t;
 
nrt_task_default_model(m);
nrt_task_def_group(m,1);
 
95,11 → 93,5
 
group_activate(1);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
 
sys_end();
 
return 0;
}
/demos/trunk/base/aster2.c
34,7 → 34,7
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* CVS : $Id: aster2.c,v 1.3 2004-04-17 11:36:12 giacomo Exp $
* CVS : $Id: aster2.c,v 1.2 2002-11-11 08:20:44 pj Exp $
 
this is a part of the classic Hartik demo Aster.
 
46,7 → 46,7
 
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules//edf.h"
 
int num_aster = 0;
#define ASTER_LIM 60
207,7 → 207,7
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <aster> ...");
perror("test7.c(main): Could not create task <aster> ...");
sys_end();
}
 
215,13 → 215,13
hard_task_def_wcet(m,CLOCK_WCET);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <Clock> ...");
perror("test7.c(main): Could not create task <Clock> ...");
sys_end();
}
 
p3 = task_create("JetControl",jetcontrol,&m_nrt,NULL);
if (p2 == -1) {
sys_shutdown_message("test7.c(main): Could not create task <JetControl> ...");
perror("test7.c(main): Could not create task <JetControl> ...");
sys_end();
}
 
/demos/trunk/base/iaster3.c
18,11 → 18,11
 
/**
------------
CVS : $Id: iaster3.c,v 1.2 2004-04-17 11:36:13 giacomo Exp $
CVS : $Id: iaster3.c,v 1.1 2002-10-28 08:13:37 pj Exp $
 
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2004-04-17 11:36:13 $
Revision: $Revision: 1.1 $
Last update: $Date: 2002-10-28 08:13:37 $
------------
 
System initialization file
76,6 → 76,7
#include "modules/rr.h"
#include "modules/tbs.h"
#include "modules/dummy.h"
#include "drivers/keyb.h"
 
 
/*+ sysyem tick in us +*/
/demos/trunk/base/initfile.c
1,25 → 1,84
/*
* Project: S.Ha.R.K
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* 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://hartik.sssup.it
* http://shark.sssup.it
*/
 
/*
------------
CVS : $Id: initfile.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $
 
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2002-09-02 09:37:41 $
------------
 
System initialization file
 
This file contains the 2 functions needed to initialize the system.
 
These functions register the following levels:
 
an EDF (Earliest Deadline First) level
a RR (Round Robin) level
a CBS (Costant Bandwidth Server) level
a Dummy level
 
It can accept these task models:
 
HARD_TASK_MODEL (wcet+mit) at level 0
SOFT_TASK_MODEL (met, period) at level 1
NRT_TASK_MODEL at level 2
 
This file is similar to the configuration of kernel/init/hartik3.c
 
TICK is set to 0 (one-shot timer is 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"
#include "modules/cbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
#include "modules/intdrive.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
#include "drivers/keyb.h"
 
 
/*+ sysyem tick in us +*/
#define TICK 0
 
26,33 → 85,36
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_T 10000
#define INTDRIVE_FLAG 0
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 1);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
SEM_register_module();
 
return TICK;
CABS_register_module();
 
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
KEYB_PARMS kparms = BASE_KEYB;
 
__call_main__(mb);
HARTPORT_init();
 
return (void *)0;
keyb_def_ctrlC(kparms, NULL);
keyb_def_map(kparms,itaMap);
KEYB_init(&kparms);
 
__call_main__(mb);
 
return (void *)0;
}