11,8 → 11,11 |
// S.Ha.R.K. Implementation |
//===================================================================== |
|
#include "fsf_contract.h" |
#include "fsf_core.h" |
#include "fsf_server.h" |
#include "fsf_shared_objects.h" |
#include "fsf_hierarchical.h" |
#include "fsf_spare_capacity.h" |
#include <kernel/descr.h> |
#include <kernel/func.h> |
#include <pistar.h> |
19,11 → 22,11 |
|
struct hash_entry { |
mutex_t mx; |
int id; |
FSF_SHARED_OBJ_HANDLE_T_OPAQUE id; |
}; |
|
|
#define MAX_HASH_ENTRY FSF_MAX_SHARED_OPERATION |
#define MAX_HASH_ENTRY FSF_MAX_N_SHARED_OBJECTS |
struct hash_entry htable[MAX_HASH_ENTRY]; |
|
|
30,7 → 33,7 |
/*----------------------------------------------------------------------*/ |
/* hash_fun() : address hash table */ |
/*----------------------------------------------------------------------*/ |
static int hash_fun(fsf_shared_obj_id_t *id) |
static int hash_fun(fsf_shared_obj_id_t id) |
{ |
return (*id % MAX_HASH_ENTRY); |
} |
53,7 → 56,7 |
struct timespec default_deadline = FSF_DEFAULT_DEADLINE; |
|
/* Check */ |
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
/* Set to default value */ |
NULL_TIMESPEC(&contract->budget_min); |
63,7 → 66,7 |
|
contract->workload = FSF_DEFAULT_WORKLOAD; |
|
contract->local_scheduler_id = FSF_DEFAULT_SCHEDULER; |
contract->policy = FSF_DEFAULT_SCHED_POLICY; |
|
contract->d_equals_t = FSF_DEFAULT_D_EQUALS_T; |
|
91,17 → 94,19 |
(fsf_contract_parameters_t *contract, |
const struct timespec *budget_min, |
const struct timespec *period_max, |
const struct timespec *budget_max, |
const struct timespec *period_min, |
fsf_workload_t workload) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
if (budget_min) TIMESPEC_ASSIGN(&contract->budget_min,budget_min); |
if (period_max) TIMESPEC_ASSIGN(&contract->period_max,period_max); |
if (budget_max) TIMESPEC_ASSIGN(&contract->budget_max,budget_max); |
if (period_min) TIMESPEC_ASSIGN(&contract->period_min,period_min); |
if (budget_min) { |
TIMESPEC_ASSIGN(&contract->budget_min,budget_min); |
TIMESPEC_ASSIGN(&contract->budget_max,budget_min); |
} |
if (period_max) { |
TIMESPEC_ASSIGN(&contract->period_max,period_max); |
TIMESPEC_ASSIGN(&contract->period_min,period_max); |
} |
|
contract->workload = workload; |
|
113,17 → 118,13 |
(const fsf_contract_parameters_t *contract, |
struct timespec *budget_min, |
struct timespec *period_max, |
struct timespec *budget_max, |
struct timespec *period_min, |
fsf_workload_t *workload) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
TIMESPEC_ASSIGN(budget_min,&contract->budget_min); |
TIMESPEC_ASSIGN(period_max,&contract->period_max); |
TIMESPEC_ASSIGN(budget_max,&contract->budget_max); |
TIMESPEC_ASSIGN(period_min,&contract->period_min); |
|
*workload = contract->workload; |
|
141,7 → 142,7 |
union sigval deadline_miss_sig_value) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
contract->d_equals_t = d_equals_t; |
|
166,7 → 167,7 |
union sigval *deadline_miss_sig_value) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
*d_equals_t = contract->d_equals_t; |
|
181,8 → 182,11 |
|
} |
|
int fsf_set_contract_reclamation_parameters |
int |
fsf_set_contract_reclamation_parameters |
(fsf_contract_parameters_t *contract, |
const struct timespec *budget_max, |
const struct timespec *period_min, |
fsf_granularity_t granularity, |
const fsf_utilization_set_t *utilization_set, |
int quality, |
189,12 → 193,15 |
int importance) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
contract->granularity = granularity; |
|
if (utilization_set) memcpy(&contract->utilization_set,utilization_set,sizeof(fsf_utilization_set_t)); |
|
if (budget_max) TIMESPEC_ASSIGN(&contract->budget_max,budget_max); |
if (period_min) TIMESPEC_ASSIGN(&contract->period_min,period_min); |
|
contract->quality = quality; |
contract->importance = importance; |
|
204,6 → 211,8 |
|
int fsf_get_contract_reclamation_parameters |
(const fsf_contract_parameters_t *contract, |
struct timespec *budget_max, |
struct timespec *period_min, |
fsf_granularity_t *granularity, |
fsf_utilization_set_t *utilization_set, |
int *quality, |
210,12 → 219,15 |
int *importance) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
*granularity = contract->granularity; |
|
memcpy(utilization_set,&contract->utilization_set,sizeof(fsf_utilization_set_t)); |
|
TIMESPEC_ASSIGN(budget_max,&contract->budget_max); |
TIMESPEC_ASSIGN(period_min,&contract->period_min); |
|
*quality = contract->quality; |
*importance = contract->importance; |
|
223,35 → 235,27 |
|
} |
|
/* OLD VERSION |
int fsf_set_contract_synchronization_parameters |
(fsf_contract_parameters_t *contract, |
fsf_preemption_level_t preemption_level, |
const fsf_critical_sections_t *critical_sections) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
contract->preemption_level = preemption_level; |
|
if (critical_sections) memcpy(&contract->critical_sections,critical_sections,sizeof(fsf_critical_sections_t)); |
|
return 0; |
|
} |
*/ |
|
int |
fsf_get_contract_synchronization_parameters |
(const fsf_contract_parameters_t *contract, |
fsf_preemption_level_t *preemption_level, |
fsf_critical_sections_t *critical_sections) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
*preemption_level = contract->preemption_level; |
|
memcpy(critical_sections,&contract->critical_sections,sizeof(fsf_critical_sections_t)); |
|
return 0; |
259,14 → 263,14 |
} |
|
int |
fsf_set_local_scheduler_parameter |
fsf_set_contract_scheduling_policy |
(fsf_contract_parameters_t *contract, |
fsf_scheduler_id_t local_scheduler_id) |
fsf_sched_policy_t sched_policy) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
contract->local_scheduler_id = local_scheduler_id; |
contract->policy = sched_policy; |
|
return 0; |
|
273,19 → 277,20 |
} |
|
int |
fsf_get_local_scheduler_parameter |
fsf_get_contract_scheduling_policy |
(const fsf_contract_parameters_t *contract, |
fsf_scheduler_id_t *local_scheduler_id) |
fsf_sched_policy_t *sched_policy) |
{ |
|
if (!contract) return FSF_ERR_NOT_INITIALIZED; |
if (!contract) return FSF_ERR_BAD_ARGUMENT; |
|
*local_scheduler_id = contract->local_scheduler_id; |
*sched_policy = contract->policy; |
|
return 0; |
|
} |
|
/* OLD VERSION |
// mutex lock function |
|
int fsf_lock_object(fsf_shared_operation_t *op) { |
328,8 → 333,12 |
|
} |
|
int fsf_init_shared_object(fsf_shared_object_t *obj, |
fsf_shared_obj_id_t id) { |
*/ |
|
int fsf_init_shared_object |
(fsf_shared_obj_id_t id, |
fsf_shared_obj_handle_t *obj, |
pthread_mutex_t *mutex) { |
int index; |
int oldindex; |
PISTAR_mutexattr_t a; |
339,10 → 348,10 |
//kern_printf("(SI SO)\n"); |
f=kern_fsave(); |
|
index=hash_fun(&id); |
index=hash_fun(id); |
//kern_printf("Index %d Hash %d", index, htable[index].id); |
|
if (htable[index].id == id) { |
if (htable[index].id == index) { |
kern_frestore(f); |
return -1; |
} |
359,11 → 368,12 |
} |
} |
|
obj->size=0; |
//obj->size=0; |
|
mutex_init(&(htable[index]).mx, &a); |
htable[index].id=id; |
obj->obj_id=id; |
mutex=&(htable[index]).mx; |
htable[index].id=index; |
*obj=*id; |
kern_frestore(f); |
|
return 0; |
371,7 → 381,7 |
//kern_printf("(EI SO)\n"); |
} |
|
|
/* OLD VERSION |
// Declare an operation |
// This function is used to declare that a shared object has |
// a synchronized operation on it. |
417,7 → 427,9 |
|
|
} |
*/ |
|
/* OLD VERSION |
int fsf_set_contract_synchronization_parameters( |
fsf_contract_parameters_t *contract, |
const fsf_shared_operation_t *shared_ops, |
429,3 → 441,4 |
|
return 0; |
} |
*/ |