/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "xbt/ex.h"
#include "xbt/dict.h"
#include "workstation_private.h"
#include "cpu_private.h"
static void create_workstations(void)
{
- xbt_dict_cursor_t cursor = NULL;
+ xbt_dict_cursor_t cursor = NULL;
char *name = NULL;
void *cpu = NULL;
void *nw_card = NULL;
xbt_dict_foreach(cpu_set, cursor, name, cpu) {
- nw_card = NULL;
- xbt_dict_get(network_card_set, name, (void *) &nw_card);
- xbt_assert1(nw_card, "No corresponding card found for %s",name);
+ nw_card = xbt_dict_get_or_null(network_card_set, name);
+ xbt_assert1(nw_card,
+ "No corresponding card found for %s",name);
+
xbt_dict_set(workstation_set, name,
workstation_new(name, cpu, nw_card), workstation_free);
}
static void *name_service(const char *name)
{
- void *workstation = NULL;
-
- xbt_dict_get(workstation_set, name, &workstation);
-
- return workstation;
+ return xbt_dict_get_or_null(workstation_set, name);
}
static const char *get_resource_name(void *resource_id)
static void action_cancel(surf_action_t action)
{
- DIE_IMPOSSIBLE;
+ if(action->resource_type==(surf_resource_t)surf_network_resource)
+ surf_network_resource->common_public->action_cancel(action);
+ else if(action->resource_type==(surf_resource_t)surf_cpu_resource)
+ surf_cpu_resource->common_public->action_cancel(action);
+ else if(action->resource_type==(surf_resource_t)surf_workstation_resource)
+ return parallel_action_use(action);
+ else DIE_IMPOSSIBLE;
return;
}
surf_action_parallel_task_CSL05_t next_action = NULL;
xbt_swag_t running_actions =
surf_workstation_resource->common_public->states.running_action_set;
+ /* FIXME: unused
xbt_swag_t failed_actions =
surf_workstation_resource->common_public->states.failed_action_set;
+ */
xbt_swag_foreach_safe(action, next_action, running_actions) {
surf_double_update(&(action->generic_action.remains),
get_state(((workstation_CLM03_t) workstation)->cpu);
}
+static double get_speed(void *workstation, double load)
+{
+ return surf_cpu_resource->extension_public->
+ get_speed(((workstation_CLM03_t) workstation)->cpu, load);
+}
+
static surf_action_t execute_parallel_task (int workstation_nb,
void **workstation_list,
double *computation_amount,
surf_workstation_resource->extension_public->execute = execute;
surf_workstation_resource->extension_public->sleep = action_sleep;
surf_workstation_resource->extension_public->get_state = get_state;
+ surf_workstation_resource->extension_public->get_speed = get_speed;
surf_workstation_resource->extension_public->communicate = communicate;
surf_workstation_resource->extension_public->execute_parallel_task =
execute_parallel_task;