Subversion Repositories shark

Rev

Rev 1219 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1218 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Giacomo Guidi       <giacomo@gandalf.sssup.it>
10
 *
11
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
12
 *
13
 * http://www.sssup.it
14
 * http://retis.sssup.it
15
 * http://shark.sssup.it
16
 */
17
 
18
/*
19
 * Copyright (C) 2000 Paolo Gai
20
 *
21
 * This program is free software; you can redistribute it and/or modify
22
 * it under the terms of the GNU General Public License as published by
23
 * the Free Software Foundation; either version 2 of the License, or
24
 * (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
 */
35
 
36
#include "kernel/kern.h"
37
 
38
#include "fsf_contract.h"
39
 
40
#include "stdlib.h"
41
#include "unistd.h"
42
#include "string.h"
43
 
44
#include "pthread.h"
45
 
46
#include "drivers/keyb.h"
47
#include "drivers/glib.h"
48
 
49
#define SERVER_I_PERIOD 40000
50
#define SERVER_I_BUDGET 10000
51
#define SERVER_P_PERIOD 40000
52
#define SERVER_P_BUDGET 10000
53
#define SERVER_B_PERIOD 40000
54
#define SERVER_B_BUDGET 1000
55
 
56
struct timespec server_I_period = {0,SERVER_I_PERIOD*1000};
57
struct timespec server_I_budget = {0,SERVER_I_BUDGET*1000};
58
struct timespec server_P_period = {0,SERVER_P_PERIOD*1000};
59
struct timespec server_P_budget = {0,SERVER_P_BUDGET*1000};
60
struct timespec server_B_period = {0,SERVER_B_PERIOD*1000};
61
struct timespec server_B_budget = {0,SERVER_B_BUDGET*1000};
62
 
63
fsf_server_id_t server_I, server_P, server_B;
64
fsf_contract_parameters_t contract_I, contract_P, contract_B;
65
 
66
pthread_t pI,pP,pB;
67
 
68
TASK decoder(void *arg)
69
{
70
 
71
  int i;
72
 
73
  cprintf("Decoder Start %d\n",exec_shadow);
74
 
75
  for (i=0;i<100000;i++);
76
 
77
  cprintf("Decoder End %d\n",exec_shadow);
78
 
79
  task_endcycle();
80
 
81
  return NULL;
82
 
83
}
84
 
85
int init_mpeg_server() {
86
 
87
  int err;
88
  HARD_TASK_MODEL ht;
89
 
90
  fsf_initialize_contract(&contract_I);
91
  fsf_set_contract_basic_parameters(&contract_I,&server_I_budget,&server_I_period,NULL,NULL,FSF_DEFAULT_WORKLOAD);
92
  fsf_set_local_scheduler_parameter(&contract_I, FSF_SCHEDULER_MPEG);
93
 
94
  fsf_initialize_contract(&contract_P);
95
  fsf_set_contract_basic_parameters(&contract_P,&server_P_budget,&server_P_period,NULL,NULL,FSF_DEFAULT_WORKLOAD);
96
  fsf_set_local_scheduler_parameter(&contract_P, FSF_SCHEDULER_MPEG);
97
 
98
  fsf_initialize_contract(&contract_B);
99
  fsf_set_contract_basic_parameters(&contract_B,&server_B_budget,&server_B_period,NULL,NULL,FSF_DEFAULT_WORKLOAD);
100
  fsf_set_local_scheduler_parameter(&contract_B, FSF_SCHEDULER_MPEG);
101
 
102
  err = fsf_negotiate_contract(&contract_I,&server_I);
103
  if (err) cprintf("(FSF ERROR %d)",err);
104
  err = fsf_negotiate_contract(&contract_P,&server_P);
105
  if (err) cprintf("(FSF ERROR %d)",err);
106
  err = fsf_negotiate_contract(&contract_B,&server_B);
107
  if (err) cprintf("(FSF ERROR %d)",err);
108
 
109
  hard_task_default_model(ht);
110
 
111
  fsf_create_thread(server_I, &pI, NULL, decoder, NULL, &ht);
112
  cprintf("Server I %d\n",pI);
113
 
114
  fsf_create_thread(server_P, &pP, NULL, decoder, NULL, &ht);
115
  cprintf("Server P %d\n",pP);
116
 
117
  fsf_create_thread(server_B, &pB, NULL, decoder, NULL, &ht);
118
  cprintf("Server B %d\n",pB);
119
 
120
  return 0;
121
 
122
}
123
 
124
int main () {
125
 
126
  init_mpeg_server();
127
  TIME T,Q;
128
 
129
  T = 40000;
130
  Q = 10000;
131
  MPEGSTAR_rescale(server_I,Q,T);
132
  task_activate(pI);
133
 
134
  T = 80000;
135
  Q = 10000;
136
  MPEGSTAR_rescale(server_P,Q,T);
137
  task_activate(pP);
138
 
139
  T = 120000;
140
  Q = 1000;
141
  MPEGSTAR_rescale(server_B,Q,T);
142
  task_activate(pB);
143
 
144
  while(1);
145
 
146
  return 0;
147
 
148
}