Subversion Repositories shark

Rev

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     :
 *   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;

}