Blame |
Last modification |
View Log
| RSS feed
/*
* 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: testiq.c,v 1.1.1.1 2004-05-24 17:54:50 giacomo Exp $
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2004-05-24 17:54:50 $
------------
The purpose of this test is to show that two budgets with different
period and budgets schedules correctly.
2 never ending tasks are involved
This test cannot compile because of the fact that QUEUE and QQUEUE
types does not exist anymore!
*/
/*
* Copyright (C) 2002 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 "cbsstar.h"
#include "edfstar.h"
#include "modules/rr.h"
#include "modules/dummy.h"
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
#include "drivers/keyb.h"
// --------------------------------------------------
// --------------------------------------------------
// Init Part
// --------------------------------------------------
// --------------------------------------------------
/*+ sysyem tick in us +*/
#define TICK 0
/*+ RR tick in us +*/
#define RRTICK 10000
TIME __kernel_register_levels__
(void *arg
)
{
struct multiboot_info
*mb
= (struct multiboot_info
*)arg
;
clear
();
EDF_register_level
(EDF_ENABLE_ALL
);
RR_register_level
(RRTICK
, RR_MAIN_YES
, mb
);
dummy_register_level
();
// for the keyboard...
CBS_register_level
(CBS_ENABLE_ALL
, 0);
SEM_register_module
();
CABS_register_module
();
return TICK
;
}
TASK __init__
(void *arg
)
{
struct multiboot_info
*mb
= (struct multiboot_info
*)arg
;
KEYB_PARMS kparms
= BASE_KEYB
;
HARTPORT_init
();
//keyb_def_ctrlC(kparms, NULL);
//keyb_def_map(kparms,itaMap);
KEYB_init
(&kparms
);
__call_main__
(mb
);
return (void *)0;
}
// --------------------------------------------------
// --------------------------------------------------
// The Test
// --------------------------------------------------
// --------------------------------------------------
#include <kernel/kern.h>
#include <drivers/keyb.h>
#include "iqueue.h"
sem_t s
;
PID p2
,p3
,p4
;
void *star
(void *arg
)
{
int j
;
TIME last
[5];
QUEUE i
= NIL
;
IQUEUE ii
;
q_timespec_insert
(p2
,&i
);
q_timespec_insert
(p3
,&i
);
iq_init
(&ii
,NULL
,0);
*iq_query_timespec
(p2
,&ii
) = proc_table
[p2
].
timespec_priority;
*iq_query_timespec
(p3
,&ii
) = proc_table
[p3
].
timespec_priority;
*iq_query_timespec
(p4
,&ii
) = proc_table
[p4
].
timespec_priority;
iq_timespec_insert
(p2
,&ii
);
iq_timespec_insert
(p3
,&ii
);
cprintf
("p2=%ld.%ld\n",proc_table
[p2
].
timespec_priority.
tv_sec,proc_table
[p2
].
timespec_priority.
tv_nsec/1000);
cprintf
("p3=%ld.%ld\n",proc_table
[p3
].
timespec_priority.
tv_sec,proc_table
[p3
].
timespec_priority.
tv_nsec/1000);
cprintf
("p4=%ld.%ld\n",proc_table
[p4
].
timespec_priority.
tv_sec,proc_table
[p4
].
timespec_priority.
tv_nsec/1000);
task_endcycle
();
for (j
=0; j
<200000; j
++) {
q_timespec_insert
(p4
,&i
);
q_extract
(p4
,&i
);
}
task_endcycle
();
for (j
=0; j
<200000; j
++) {
iq_timespec_insert
(p4
,&ii
);
iq_extract
(p4
,&ii
);
}
task_endcycle
();
jet_gettable
(exec_shadow
, &last
[0], 3);
cprintf
("\ninit=%d queue=%d iqueue=%d\n",
(int)last
[0], (int)last
[1], (int)last
[2]);
sys_end
();
return NULL
;
}
void *fake
(void *arg
)
{
cputs
("#");
task_endcycle
();
return NULL
;
}
void create1
()
{
HARD_TASK_MODEL m1
;
PID p1a
;
hard_task_default_model
(m1
);
hard_task_def_wcet
(m1
, 500000);
hard_task_def_group
(m1
,1);
hard_task_def_periodic
(m1
);
hard_task_def_mit
(m1
,1000000);
hard_task_def_ctrl_jet
(m1
);
p1a
= task_create
("a", star
, &m1
, NULL
);
if (p1a
== -1) {
perror("Could not create task a ...");
sys_end
();
}
hard_task_default_model
(m1
);
hard_task_def_wcet
(m1
, 5000);
hard_task_def_aperiodic
(m1
);
hard_task_def_group
(m1
,1);
hard_task_def_mit
(m1
,100000);
p2
= task_create
("a", fake
, &m1
, NULL
);
if (p1a
== -1) {
perror("Could not create task a ...");
sys_end
();
}
hard_task_def_mit
(m1
,100001);
p3
= task_create
("a", fake
, &m1
, NULL
);
if (p1a
== -1) {
perror("Could not create task a ...");
sys_end
();
}
hard_task_def_mit
(m1
,100002);
p4
= task_create
("a", fake
, &m1
, NULL
);
if (p1a
== -1) {
perror("Could not create task a ...");
sys_end
();
}
group_activate
(1);
}
void endfun
(KEY_EVT
*k
)
{
cprintf
("ESC pressed!");
sys_end
();
}
int main
(int argc
, char **argv
)
{
KEY_EVT k
;
sem_init
(&s
,0,1);
k.
flag = 0;
k.
scan = KEY_ESC
;
k.
ascii = 27;
keyb_hook
(k
,endfun
);
create1
();
return 0;
}