X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4365fa8e81736673eae923310a05cdbf78ec88d8..c8e414e235d6dec3d30c349a61de69eb88060ff4:/src/surf/surf_c_bindings.cpp diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index cdfef8ccb7..e32a3e0223 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -18,18 +18,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel); * TOOLS * *********/ -static CpuPtr get_casted_cpu(surf_resource_t resource){ - return static_cast(surf_cpu_resource_priv(resource)); -} - static HostPtr get_casted_host(surf_resource_t resource){ return static_cast(surf_host_resource_priv(resource)); } -static RoutingEdgePtr get_casted_routing(surf_resource_t resource){ - return static_cast(surf_routing_resource_priv(resource)); -} - static VMPtr get_casted_vm(surf_resource_t resource){ return static_cast(surf_host_resource_priv(resource)); } @@ -38,10 +30,6 @@ char *surf_routing_edge_name(sg_routing_edge_t edge){ return edge->getName(); } -#ifdef CONTEXT_THREADS -//FIXME:keeporremove static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */ -#endif - extern double NOW; extern double *surf_mins; /* return value of share_resources for each model */ extern int surf_min_index; /* current index in surf_mins */ @@ -430,11 +418,11 @@ int surf_host_file_move(surf_resource_t host, surf_file_t fd, const char* fullpa xbt_dynar_t surf_host_get_vms(surf_resource_t host){ xbt_dynar_t vms = get_casted_host(host)->getVms(); - xbt_dynar_t vms_ = xbt_dynar_new(sizeof(smx_host_t), NULL); + xbt_dynar_t vms_ = xbt_dynar_new(sizeof(sg_host_t), NULL); unsigned int cpt; VMPtr vm; xbt_dynar_foreach(vms, cpt, vm) { - smx_host_t vm_ = xbt_lib_get_elm_or_null(host_lib, vm->getName()); + sg_host_t vm_ = xbt_lib_get_elm_or_null(host_lib, vm->getName()); xbt_dynar_push(vms_, &vm_); } xbt_dynar_free(&vms); @@ -451,9 +439,7 @@ void surf_host_set_params(surf_resource_t host, ws_params_t params){ void surf_vm_destroy(surf_resource_t resource){ /* Before clearing the entries in host_lib, we have to pick up resources. */ - CpuPtr cpu = get_casted_cpu(resource); VMPtr vm = get_casted_vm(resource); - RoutingEdgePtr routing = get_casted_routing(resource); char* name = xbt_dict_get_elm_key(resource); /* We deregister objects from host_lib, without invoking the freeing callback * of each level. @@ -461,16 +447,14 @@ void surf_vm_destroy(surf_resource_t resource){ * Do not call xbt_lib_remove() here. It deletes all levels of the key, * including MSG_HOST_LEVEL and others. We should unregister only what we know. */ - xbt_lib_unset(host_lib, name, SURF_CPU_LEVEL, 0); - xbt_lib_unset(host_lib, name, ROUTING_HOST_LEVEL, 0); + sg_host_surfcpu_destroy((sg_host_t)resource); + sg_host_edge_destroy((sg_host_t)resource,1); xbt_lib_unset(host_lib, name, SURF_HOST_LEVEL, 0); /* TODO: comment out when VM storage is implemented. */ // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0); - delete cpu; delete vm; - delete routing; } void surf_vm_suspend(surf_resource_t vm){ @@ -502,7 +486,7 @@ void surf_vm_set_bound(surf_resource_t vm, double bound){ } void surf_vm_set_affinity(surf_resource_t vm, surf_resource_t cpu, unsigned long mask){ - return get_casted_vm(vm)->setAffinity(get_casted_cpu(cpu), mask); + return get_casted_vm(vm)->setAffinity(sg_host_surfcpu(cpu), mask); } int surf_network_link_is_shared(surf_cpp_resource_t link){ @@ -538,11 +522,11 @@ const char* surf_storage_get_host(surf_resource_t resource){ } surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){ - return get_casted_cpu(cpu)->execute(size); + return sg_host_surfcpu(cpu)->execute(size); } surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration){ - return get_casted_cpu(cpu)->sleep(duration); + return sg_host_surfcpu(cpu)->sleep(duration); } double surf_action_get_start_time(surf_action_t action){ @@ -598,7 +582,7 @@ double surf_action_get_cost(surf_action_t action){ } void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) { - static_cast(action)->setAffinity(get_casted_cpu(cpu), mask); + static_cast(action)->setAffinity(sg_host_surfcpu(cpu), mask); } void surf_cpu_action_set_bound(surf_action_t action, double bound) {