Rev 1655 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://hartik.sssup.it
*/
/**
------------
CVS : $Id: test1st.c,v 1.1.1.1 2004-05-24 18:03:47 giacomo Exp $
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 18:03:47 $
------------
**/
/*
* 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 "static.h"
#include <math.h>
#include <string.h>
int theend
= 0;
void *mytask
(void *arg
)
{
struct timespec t
;
for (;;)
{
sys_gettime
(&t
);
cprintf
("I am task %s at time %d.%d\n", (char *)arg
, (int)t.
tv_sec, (int)t.
tv_nsec);
theend
++;
if (theend
> 10) sys_end
();
task_endcycle
();
}
}
int main
(int argc
, char **argv
)
{
PID p1
;
STATIC_TASK_MODEL m
;
struct timespec my_time
, h
, o
;
my_time.
tv_nsec=0;
my_time.
tv_sec = 0;
my_time.
tv_nsec = 500000000;
static_task_default_model
(m
, my_time
);
static_task_def_arg
(m
, "A");
p1
= task_create
("TaskA",mytask
,&m
,NULL
);
if (p1
== -1) {
perror("Could not create task <A> ...");
sys_end
();
}
my_time.
tv_sec = 1;
my_time.
tv_nsec = 0;
static_task_default_model
(m
, my_time
);
static_task_def_arg
(m
, "B");
p1
= task_create
("TaskB",mytask
,&m
,NULL
);
if (p1
== -1) {
perror("Could not create task <B> ...");
sys_end
();
}
my_time.
tv_sec = 1;
my_time.
tv_nsec = 500000000;
static_task_default_model
(m
, my_time
);
static_task_def_arg
(m
, "C");
p1
= task_create
("TaskC",mytask
,&m
,NULL
);
if (p1
== -1) {
perror("Could not create task <C> ...");
sys_end
();
}
h.
tv_sec = 3;
h.
tv_nsec = 0;
o.
tv_sec = 1;
o.
tv_nsec = 0;
STATIC_start
(0, &h
, &o
);
return 0;
}