Blame |
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: test1.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2002-09-02 09:37:48 $
------------
Test Number 1:
this test is a simple main() function with other 2 task
This test has to be compiled with init1.c, that introduce 2 RR levels
with a timeslice of 300us (!)
This test can be useful to test functions like
task_nopreempt
task_preempt
task_create
task_activate
task_delay
group_activate
normal task termination (task_abort)
normal system termination (sys_end)
standard atexit functions (the keyboard...)
**/
/*
* 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"
// for min
#include "ll/stdlib.h"
#include "ll/stdio.h"
#if !defined(__TEST1__)
THE TEST REQUIRE THE DEFINITION __TEST1__ IN CONFIG.C
#endif
struct timespec s_stime[10000];
struct timespec s_send[10000];
TIME s_curr[10000];
PID s_PID[10000];
int useds=0;
int testactive=1;
TASK pippo()
{
// int i;
struct timespec t;
int last = 0;
do {
//kern_printf("!");
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
if ((t.tv_nsec/1000000) != last) { //ogni 7000
// kern_printf("Û%dÛ",t);
last = t.tv_nsec/1000000;
// task_delay(3000000);
}
} while (t.tv_nsec <= 20000000L);
}
TASK pippo2()
{
struct timespec t;
do {
// kern_printf("pippo2");
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
if (t.tv_nsec > 5000000 && t.tv_nsec <= 12000000) task_nopreempt();
if (t.tv_nsec > 12000000) task_preempt();
} while (t.tv_nsec <= 20000000L);
}
int main(int argc, char **argv)
{
struct timespec t;
int i;
NRT_TASK_MODEL m;
PID p2,p3;
nrt_task_default_model(m);
nrt_task_def_group(m,1);
p2 = task_createn("pippo", pippo, &m, NULL);
if (p2 == NIL)
{ kern_printf("Can't create pippo task...\n"); return 1; }
p3 = task_createn("pippo2", pippo2, &m, NULL);
if (p3 == NIL)
{ kern_printf("Can't create pippo2 task...\n"); return 1; }
group_activate(1);
kern_printf("DENTRO MAIN %d\n",ll_context_save());
// testactive = 1;
NULL_TIMESPEC(&t);
do {
kern_cli();
ll_gettime(TIME_EXACT, &t);
kern_sti();
// task_delay(14000);
} while (t.tv_nsec <= 40000000L);
testactive = 0;
// sys_status(0xFFFF);
// return 0;
kern_printf("FINE MAIN time=%d useds=%d\n",ll_gettime(TIME_EXACT,NULL),useds);
for (i=0; i<min(useds,20); i++)
kern_printf("%6d: pid %6d stime %-9d reschedule %-9d avail %-9d\n",i,
s_PID[i], s_stime[i].tv_nsec, s_send[i].tv_nsec, s_curr[i]);
// sys_end();
kern_printf("DENTRO MAIN %d\n",ll_context_save());
return 0;
}