Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1216 → Rev 1218

/demos/trunk/mpegstar/mpegstar.c
0,0 → 1,148
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/*
* 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 "fsf_contract.h"
 
#include "stdlib.h"
#include "unistd.h"
#include "string.h"
 
#include "pthread.h"
 
#include "drivers/keyb.h"
#include "drivers/glib.h"
 
#define SERVER_I_PERIOD 40000
#define SERVER_I_BUDGET 10000
#define SERVER_P_PERIOD 40000
#define SERVER_P_BUDGET 10000
#define SERVER_B_PERIOD 40000
#define SERVER_B_BUDGET 1000
 
struct timespec server_I_period = {0,SERVER_I_PERIOD*1000};
struct timespec server_I_budget = {0,SERVER_I_BUDGET*1000};
struct timespec server_P_period = {0,SERVER_P_PERIOD*1000};
struct timespec server_P_budget = {0,SERVER_P_BUDGET*1000};
struct timespec server_B_period = {0,SERVER_B_PERIOD*1000};
struct timespec server_B_budget = {0,SERVER_B_BUDGET*1000};
 
fsf_server_id_t server_I, server_P, server_B;
fsf_contract_parameters_t contract_I, contract_P, contract_B;
 
pthread_t pI,pP,pB;
 
TASK decoder(void *arg)
{
 
int i;
 
cprintf("Decoder Start %d\n",exec_shadow);
 
for (i=0;i<100000;i++);
 
cprintf("Decoder End %d\n",exec_shadow);
 
task_endcycle();
 
return NULL;
 
}
 
int init_mpeg_server() {
 
int err;
HARD_TASK_MODEL ht;
 
fsf_initialize_contract(&contract_I);
fsf_set_contract_basic_parameters(&contract_I,&server_I_budget,&server_I_period,NULL,NULL,FSF_DEFAULT_WORKLOAD);
fsf_set_local_scheduler_parameter(&contract_I, FSF_SCHEDULER_MPEG);
 
fsf_initialize_contract(&contract_P);
fsf_set_contract_basic_parameters(&contract_P,&server_P_budget,&server_P_period,NULL,NULL,FSF_DEFAULT_WORKLOAD);
fsf_set_local_scheduler_parameter(&contract_P, FSF_SCHEDULER_MPEG);
 
fsf_initialize_contract(&contract_B);
fsf_set_contract_basic_parameters(&contract_B,&server_B_budget,&server_B_period,NULL,NULL,FSF_DEFAULT_WORKLOAD);
fsf_set_local_scheduler_parameter(&contract_B, FSF_SCHEDULER_MPEG);
 
err = fsf_negotiate_contract(&contract_I,&server_I);
if (err) cprintf("(FSF ERROR %d)",err);
err = fsf_negotiate_contract(&contract_P,&server_P);
if (err) cprintf("(FSF ERROR %d)",err);
err = fsf_negotiate_contract(&contract_B,&server_B);
if (err) cprintf("(FSF ERROR %d)",err);
 
hard_task_default_model(ht);
 
fsf_create_thread(server_I, &pI, NULL, decoder, NULL, &ht);
cprintf("Server I %d\n",pI);
 
fsf_create_thread(server_P, &pP, NULL, decoder, NULL, &ht);
cprintf("Server P %d\n",pP);
 
fsf_create_thread(server_B, &pB, NULL, decoder, NULL, &ht);
cprintf("Server B %d\n",pB);
 
return 0;
}
 
int main () {
 
init_mpeg_server();
TIME T,Q;
 
T = 40000;
Q = 10000;
MPEGSTAR_rescale(server_I,Q,T);
task_activate(pI);
T = 80000;
Q = 10000;
MPEGSTAR_rescale(server_P,Q,T);
task_activate(pP);
 
T = 120000;
Q = 1000;
MPEGSTAR_rescale(server_B,Q,T);
task_activate(pB);
while(1);
return 0;
 
}
/demos/trunk/mpegstar/initfile.c
0,0 → 1,95
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@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 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/posix.h"
#include "pthread.h"
#include "drivers/keyb.h"
#include "modules/sem.h"
#include "modules/dummy.h"
#include "modules/hartport.h"
 
#include "fsf_contract.h"
#include "fsf_server.h"
 
#include "modules/pi.h"
#include "modules/pc.h"
 
#define TICK 0
 
#define RRTICK 10000
 
void load_file();
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
int grubstar_level;
 
EDF_register_level(EDF_ENABLE_ALL);
POSIX_register_level(RRTICK, 1, mb, 32);
grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 0);
FSF_register_module(grubstar_level);
dummy_register_level();
CBS_register_level(CBS_ENABLE_ALL,0);
 
SEM_register_module();
 
PI_register_module();
PC_register_module();
 
PTHREAD_register_module(1, 0, 1);
 
return TICK;
 
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
KEYB_init(NULL);
 
__call_main__(mb);
 
return (void *)0;
}
/demos/trunk/mpegstar/makefile
0,0 → 1,13
#
#
 
BASE=../..
include $(BASE)/config/config.mk
 
PROGS= mpegstar
 
include $(BASE)/config/example.mk
 
mpegstar:
make -f $(SUBMAKE) APP=mpegstar INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __GRX__ __FIRST__"