Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 888 → Rev 896

/shark/trunk/ports/first/first-server.c
19,6 → 19,7
 
#include "fsf.h"
#include "fsf_service_task.h"
#include "fsf_server.h"
#include "message.h"
 
#include "posixstar.h"
49,6 → 50,8
fsf_server_id_t service_server = -1;
fsf_contract_parameters_t service_contract;
 
bandwidth_t SERVER_return_bandwidth();
 
int FSF_register_shared_object_module(void) {
fsf_register_shared_object();
return PISTAR_register_module();
136,7 → 139,7
break;
}
 
if (contract->d_equals_t == TRUE) {
if (contract->d_equals_t == true) {
*budget = SERVER_setbudget(fsf_server_level,
TIMESPEC2USEC(&(contract->budget_min)),
TIMESPEC2USEC(&(contract->period_max)),
172,6 → 175,19
/* Admission Test function */
int add_contract(const fsf_contract_parameters_t *contract)
{
bandwidth_t current_bandwidth,U;
TIME T,Q;
T=TIMESPEC2USEC(&(contract->period_max));
Q=TIMESPEC2USEC(&(contract->budget_min));
mul32div32to32(MAX_BANDWIDTH,Q,T,U);
/* The current bandwidth is the min bandwidth */
current_bandwidth=SERVER_return_bandwidth(fsf_server_level);
 
if (fsf_max_bw>=current_bandwidth+U) return -1;
 
return 0;
 
}
199,12 → 215,12
mul32div32to32(MAX_BANDWIDTH,Q,T,server_list[i].Umin);
server_list[i].U=server_list[i].Umin;
 
if (contract->d_equals_t == TRUE) {
if (contract->d_equals_t == true) {
server_list[i].deadline = 0;
server_list[i].d_equals_t = TRUE;
server_list[i].d_equals_t = true;
} else {
server_list[i].deadline = TIMESPEC2USEC(&contract->deadline);;
server_list[i].d_equals_t = FALSE;
server_list[i].d_equals_t = false;
}
server_list[i].Qs = contract->quality;
307,7 → 323,31
 
}
 
int
fsf_request_change_quality_and_importance
(fsf_server_id_t server,
int new_importance,
int new_quality)
{
struct mess m;
 
// send response server is -1 if the operation fail
m.type=CHANGE_PARAMETER;
//memmove(&m.contract,contract, sizeof(fsf_contract_parameters_t));
 
port_send(channel[1],&m,BLOCK);
port_receive(channel[0], &m, BLOCK);
if (m.server==-1)
return FSF_ERR_CONTRACT_REJECTED;
 
//*server=m.server;
 
 
}
 
 
int fsf_negotiate_contract
(const fsf_contract_parameters_t *contract,
fsf_server_id_t *server)
856,7 → 896,7
kern_printf("(1 - Q %ld T %ld)", server_list[i].actual_budget, server_list[i].actual_period);
#endif
if (server_list[i].d_equals_t == TRUE)
if (server_list[i].d_equals_t == true)
adjust_SERVER_budget(server_list[i].server,server_list[i].Cmin, T, T);
else
adjust_SERVER_budget(server_list[i].server,server_list[i].Cmin, T, server_list[i].deadline);
869,7 → 909,7
kern_printf("(2 - Q %ld T %ld)", server_list[i].actual_budget, server_list[i].actual_period);
#endif
if (server_list[i].d_equals_t == TRUE)
if (server_list[i].d_equals_t == true)
adjust_SERVER_budget(server_list[i].server,Q, server_list[i].Tmin, server_list[i].Tmin);
else
adjust_SERVER_budget(server_list[i].server,Q, server_list[i].Tmin, server_list[i].deadline);
909,11 → 949,11
 
#define MAX_IMPORTANCE 5
#ifdef FSF_DEBUG
int temp;
kern_printf("(Recalculate contract)");
#endif
#ifdef FSF_DEBUG
int temp;
kern_printf("(Recalculate contract)");
#endif
 
/* The current bandwidth is the min bandwidth */
current_bandwidth=SERVER_return_bandwidth(fsf_server_level);