-/**************************************/
-/************* CPU object *************/
-/**************************************/
-
-/************ workstation creation *********/
-static void workstation_free(void *workstation)
-{
- free(((workstation_KCCFLN05_t)workstation)->name);
- xbt_dynar_free(&(((workstation_KCCFLN05_t)workstation)->incomming_communications));
- xbt_dynar_free(&(((workstation_KCCFLN05_t)workstation)->outgoing_communications));
- free(workstation);
-}
-
-static workstation_KCCFLN05_t workstation_new(const char *name,
- double power_scale,
- double power_initial,
- tmgr_trace_t power_trace,
- e_surf_cpu_state_t state_initial,
- tmgr_trace_t state_trace,
- double interference_send,
- double interference_recv,
- double interference_send_recv,
- double max_outgoing_rate)
-{
- workstation_KCCFLN05_t workstation = xbt_new0(s_workstation_KCCFLN05_t, 1);
-
- workstation->resource = (surf_resource_t) surf_workstation_resource;
- workstation->name = xbt_strdup(name);
- workstation->id = nb_workstation++;
-
- workstation->power_scale = power_scale;
- xbt_assert0(workstation->power_scale>0,"Power has to be >0");
-
- workstation->power_current = power_initial;
- if (power_trace)
- workstation->power_event =
- tmgr_history_add_trace(history, power_trace, 0.0, 0, workstation);
-
- workstation->state_current = state_initial;
- if (state_trace)
- workstation->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, workstation);
-
- workstation->interference_send=interference_send;
- workstation->interference_recv=interference_recv;
- workstation->interference_send_recv=interference_send_recv;
-
- workstation->constraint =
- lmm_constraint_new(maxmin_system_cpu_KCCFLN05, workstation,
- workstation->power_current * workstation->power_scale);
- if(max_outgoing_rate>0)
- workstation->bus=
- lmm_constraint_new(maxmin_system_cpu_KCCFLN05, workstation,
- max_outgoing_rate);
-
- workstation->incomming_communications =
- xbt_dynar_new(sizeof(surf_action_network_KCCFLN05_t),NULL);
- workstation->outgoing_communications =
- xbt_dynar_new(sizeof(surf_action_network_KCCFLN05_t),NULL);
-
- xbt_dict_set(workstation_set, name, workstation, workstation_free);
-
- return workstation;
-}
-
-static void parse_workstation(void)
-{
- double power_scale = 0.0;
- double power_initial = 0.0;
- tmgr_trace_t power_trace = NULL;
- e_surf_cpu_state_t state_initial = SURF_CPU_OFF;
- tmgr_trace_t state_trace = NULL;
- double interference_send = 0.0;
- double interference_recv = 0.0;
- double interference_send_recv = 0.0;
- double max_outgoing_rate = -1.0;
-
- surf_parse_get_double(&power_scale,A_cpu_power);
- surf_parse_get_double(&power_initial,A_cpu_availability);
- surf_parse_get_trace(&power_trace,A_cpu_availability_file);
-
- xbt_assert0((A_cpu_state==A_cpu_state_ON)||
- (A_cpu_state==A_cpu_state_OFF),
- "Invalid state")
- if (A_cpu_state==A_cpu_state_ON) state_initial = SURF_CPU_ON;
- if (A_cpu_state==A_cpu_state_OFF) state_initial = SURF_CPU_OFF;
- surf_parse_get_trace(&state_trace,A_cpu_state_file);
-
- surf_parse_get_double(&interference_send,A_cpu_interference_send);
- surf_parse_get_double(&interference_recv,A_cpu_interference_recv);
- surf_parse_get_double(&interference_send_recv,A_cpu_interference_send_recv);
- surf_parse_get_double(&max_outgoing_rate,A_cpu_max_outgoing_rate);
-
- workstation_new(A_cpu_name, power_scale, power_initial, power_trace, state_initial,
- state_trace, interference_send, interference_recv,
- interference_send_recv, max_outgoing_rate);
-}
-
-/*********** resource management ***********/
-
-static void *name_service(const char *name)
-{
- void *workstation = NULL;
-
- xbt_dict_get(workstation_set, name, &workstation);
-
- return workstation;
-}
-
-static const char *get_resource_name(void *resource_id)
-{
- return ((workstation_KCCFLN05_t) resource_id)->name;
-}
-
-static int cpu_used(void *resource_id)
-{
- return lmm_constraint_used(maxmin_system_cpu_KCCFLN05,
- ((workstation_KCCFLN05_t) resource_id)->constraint);
-}
-
-static int link_used(void *resource_id)
-{
- return lmm_constraint_used(maxmin_system_network_KCCFLN05,
- ((network_link_KCCFLN05_t) resource_id)->constraint);
-}
-
-static e_surf_cpu_state_t get_state(void *cpu)
-{
- return ((workstation_KCCFLN05_t) cpu)->state_current;
-}