Rev 1089 |
Go to most recent revision |
Blame |
Compare with Previous |
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: test5.c,v 1.2 2003-01-07 17:10:17 pj Exp $
File: $File$
Revision: $Revision: 1.2 $
Last update: $Date: 2003-01-07 17:10:17 $
------------
The purpose of this test is to show that two budgets with different
period and budgets schedules correctly.
2 never ending tasks are involved
*/
/*
* 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
;
int cbsstar_level
;
int edfstar_level
, edfstar_level2
, edfstar_level3
;
int mybudget
, mybudget2
;
clear
();
EDF_register_level
(EDF_ENABLE_ALL
);
cbsstar_level
= CBSSTAR_register_level
(3, 0);
mybudget
= CBSSTAR_setbudget
(cbsstar_level
, 2000, 50000);
edfstar_level
= EDFSTAR_register_level
(mybudget
, cbsstar_level
);
mybudget2
= CBSSTAR_setbudget
(cbsstar_level
, 10000, 25000);
edfstar_level2
= EDFSTAR_register_level
(mybudget2
, cbsstar_level
);
edfstar_level3
= EDFSTAR_register_level
(mybudget2
, cbsstar_level
);
RR_register_level
(RRTICK
, RR_MAIN_YES
, mb
);
dummy_register_level
();
cprintf
("edfstar_level=%d, edfstar_level2=%d\n",
edfstar_level
,edfstar_level2
);
// for the keyboard...
CBS_register_level
(CBS_ENABLE_ALL
, 0);
CBS_register_level
(CBS_ENABLE_ALL
, edfstar_level3
);
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 <semaphore.h>
sem_t s
;
void *star
(void *arg
)
{
int j
,z
;
for (;;) {
for (z
=0; z
<50; z
++) {
for (j
=0; j
<60000; j
++);
// sem_wait(&s);
cputs
((char *)arg
);
// sem_post(&s);
}
task_endcycle
();
}
return NULL
;
}
void create1
()
{
HARD_TASK_MODEL m1
;
SOFT_TASK_MODEL ms
;
PID p1a
, p1b
, p1c
, p2
;
hard_task_default_model
(m1
);
hard_task_def_wcet
(m1
, 5000);
hard_task_def_group
(m1
,1);
hard_task_def_periodic
(m1
);
hard_task_def_level
(m1
,2);
hard_task_def_arg
(m1
,(void *)"O");
hard_task_def_mit
(m1
,5000);
p1a
= task_create
("a", star
, &m1
, NULL
);
if (p1a
== -1) {
perror("Could not create task a ...");
sys_end
();
}
hard_task_def_level
(m1
,3);
hard_task_def_arg
(m1
,(void *)".");
hard_task_def_mit
(m1
,50000);
p1b
= task_create
("b", star
, &m1
, NULL
);
if (p1b
== -1) {
perror("Could not create task c ...");
sys_end
();
}
hard_task_def_level
(m1
,4);
hard_task_def_arg
(m1
,(void *)",");
hard_task_def_mit
(m1
,50000);
p1c
= task_create
("c", star
, &m1
, NULL
);
if (p1c
== -1) {
perror("Could not create task c ...");
sys_end
();
}
soft_task_default_model
(ms
);
soft_task_def_met
(ms
, 5000);
soft_task_def_period
(ms
, 30000);
soft_task_def_group
(ms
,1);
soft_task_def_periodic
(ms
);
soft_task_def_level
(ms
,8);
soft_task_def_arg
(ms
,(void *)"X");
p2
= task_create
("S", star
, &ms
, NULL
);
if (p2
== -1) {
perror("Could not create task S ...");
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;
}