#include "gras/Msg/msg_interface.h" /* For some checks at simulation end */
#include "gras/Transport/transport_interface.h" /* For some checks at simulation end */
-XBT_LOG_EXTERNAL_CATEGORY(process);
-XBT_LOG_DEFAULT_CATEGORY(process);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(gras_virtu_process);
void
gras_process_init() {
if (!hd) {
/* First process on this host */
hd=xbt_new(gras_hostdata_t,1);
+ hd->refcount = 1;
hd->ports = xbt_dynar_new(sizeof(gras_sg_portrec_t),NULL);
memset(hd->proc, 0, sizeof(hd->proc[0]) * XBT_MAX_CHANNEL);
if (MSG_host_set_data(MSG_host_self(),(void*)hd) != MSG_OK)
THROW0(system_error,0,"Error in MSG_host_set_data()");
+ } else {
+ hd->refcount++;
}
/* take a free channel for this process */
void
gras_process_exit() {
gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
+ gras_procdata_t *pd=(gras_procdata_t*)MSG_process_get_data(MSG_process_self());
+
gras_msg_procdata_t msg_pd=(gras_msg_procdata_t)gras_libdata_by_name("gras_msg");
gras_trp_procdata_t trp_pd=(gras_trp_procdata_t)gras_libdata_by_name("gras_trp");
int myPID=MSG_process_self_PID();
xbt_dynar_cursor_rm(hd->ports, &cpt);
}
}
+
+ if ( ! --(hd->refcount)) {
+ xbt_dynar_free(&hd->ports);
+ free(hd);
+ }
+ gras_procdata_exit();
+ free(pd);
}
/* **************************************************************************
return "";
}
-int gras_os_getpid(void) {
+long int gras_os_getpid(void) {
m_process_t process = MSG_process_self();
if ((process != NULL) && (process->simdata))
- return MSG_process_get_PID(MSG_process_self());
+ return (long int)MSG_process_get_PID(MSG_process_self());
else
- return 0;
+ return (long int)0;
}