static void simopen(const char *const *action) { const char *processid = action[0]; const char *worktime = action[3]; double sleeptime; const char *index = action[4]; char full_name[1024]; msg_file_t file = NULL; double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ //Because the action open is too fast ,to catch up with the clock of the simulator, we let it to sleep for a while. sleeptime = atof(worktime); MSG_process_sleep(sleeptime); //open slow filename const char *file_name = action[2]; char fn[200]; strcpy(fn,file_name); ReplaceStr(fn,"/home","/slow"); sprintf(full_name, "%s:%s:%s:%s","slow",file_name,MSG_process_get_name(MSG_process_self()),index); ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name); file = MSG_file_open(fn, NULL); xbt_dict_set(opened_files, full_name, file, NULL); //open fast filename strcpy(fn,file_name); ReplaceStr(fn,"/home","/fast"); sprintf(full_name, "%s:%s:%s:%s","fast",file_name,MSG_process_get_name(MSG_process_self()),index); ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name); file = MSG_file_open(fn, NULL); xbt_dict_set(opened_files, full_name, file, NULL); log_action(action, MSG_get_clock() - clock); XBT_INFO("open worker %s%s is done",processid,index); }
static void simcreat(const char *const *action) { const char *processid = action[0]; const char *worktime = action[3]; double sleeptime; const char *index = action[4]; char full_name[1024]; msg_file_t file = NULL; double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ sleeptime = atof(worktime); MSG_process_sleep(sleeptime); //open slow file const char *file_name = action[2]; char fn[200]; strcpy(fn,file_name); ReplaceStr(fn,"/home","/slow"); sprintf(full_name, "%s:%s:%s:%s","slow",file_name,MSG_process_get_name(MSG_process_self()), index); ACT_DEBUG("Entering Creat: %s (filename: %s)", NAME, file_name); file = MSG_file_open(fn, NULL); xbt_dict_set(opened_files, full_name, file, NULL); //open fast version of file strcpy(fn,file_name); ReplaceStr(fn,"/home","/fast"); sprintf(full_name, "%s:%s:%s:%s","fast",file_name,MSG_process_get_name(MSG_process_self()), index); ACT_DEBUG("Entering Creat: %s (filename: %s)", NAME, file_name); file = MSG_file_open(fn, NULL); xbt_dict_set(opened_files, full_name, file, NULL); log_action(action, MSG_get_clock() - clock); XBT_INFO("creat worker %s %s is done",processid,index); }
static void linkContainers (container_t src, container_t dst, xbt_dict_t filter) { //ignore loopback if (strcmp (src->name, "__loopback__") == 0 || strcmp (dst->name, "__loopback__") == 0){ XBT_DEBUG (" linkContainers: ignoring loopback link"); return; } //find common father container_t father = lowestCommonAncestor (src, dst); if (!father){ xbt_die ("common father unknown, this is a tracing problem"); } if (filter != NULL){ //check if we already register this pair (we only need one direction) char aux1[INSTR_DEFAULT_STR_SIZE], aux2[INSTR_DEFAULT_STR_SIZE]; snprintf (aux1, INSTR_DEFAULT_STR_SIZE, "%s%s", src->name, dst->name); snprintf (aux2, INSTR_DEFAULT_STR_SIZE, "%s%s", dst->name, src->name); if (xbt_dict_get_or_null (filter, aux1)){ XBT_DEBUG (" linkContainers: already registered %s <-> %s (1)", src->name, dst->name); return; } if (xbt_dict_get_or_null (filter, aux2)){ XBT_DEBUG (" linkContainers: already registered %s <-> %s (2)", dst->name, src->name); return; } //ok, not found, register it xbt_dict_set (filter, aux1, xbt_strdup ("1"), NULL); xbt_dict_set (filter, aux2, xbt_strdup ("1"), NULL); } //declare type char link_typename[INSTR_DEFAULT_STR_SIZE]; snprintf (link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", father->type->name, src->type->name, src->type->id, dst->type->name, dst->type->id); type_t link_type = PJ_type_get_or_null (link_typename, father->type); if (link_type == NULL){ link_type = PJ_type_link_new (link_typename, father->type, src->type, dst->type); } //register EDGE types for triva configuration xbt_dict_set (trivaEdgeTypes, link_type->name, xbt_strdup("1"), NULL); //create the link static long long counter = 0; char key[INSTR_DEFAULT_STR_SIZE]; snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++); new_pajeStartLink(SIMIX_get_clock(), father, link_type, src, "topology", key); new_pajeEndLink(SIMIX_get_clock(), father, link_type, dst, "topology", key); XBT_DEBUG (" linkContainers %s <-> %s", src->name, dst->name); }
int main(int argc, char **argv) { xbt_dict_cursor_t cursor = NULL; char *key, *data; char noexist[] = "NoProp"; const char *value; char exist[] = "Hdd"; /* SD initialization */ SD_init(&argc, argv); xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s ../../platforms/prop.xml", argv[0], argv[0]); SD_create_environment(argv[1]); /* init of platform elements */ sg_host_t h1 = sg_host_by_name("host1"); sg_host_t h2 = sg_host_by_name("host2"); const char *name1 = sg_host_get_name(h1); const char *name2 = sg_host_get_name(h2); /* Get the property list of 'host1' */ XBT_INFO("Property list for host %s", name1); xbt_dict_t props = sg_host_get_properties(h1); /* Trying to set a new property */ xbt_dict_set(props, "NewProp", strdup("newValue"), NULL); /* Print the properties of 'host1' */ xbt_dict_foreach(props, cursor, key, data) { XBT_INFO("\tProperty: %s has value: %s", key, data); }
void gras_process_init() { char **env_iter; _gras_procdata = xbt_new0(gras_procdata_t, 1); gras_procdata_init(); /* initialize the host & process properties */ _host_properties = xbt_dict_new(); _process_properties = xbt_dict_new(); env_iter = environ; while (*env_iter) { char *equal, *buf = xbt_strdup(*env_iter); equal = strchr(buf, '='); if (!equal) { XBT_WARN ("The environment contains an entry without '=' char: %s (ignore it)", *env_iter); continue; } *equal = '\0'; xbt_dict_set(_process_properties, buf, xbt_strdup(equal + 1), xbt_free_f); free(buf); env_iter++; } }
static int new_request(MPI_Request req) { static int request_id = INT_MIN; char key[KEY_SIZE]; xbt_dict_set(request_lookup, get_key(key, request_id), req, NULL); return request_id++; }
void print_TICreateContainer(paje_event_t event) { //if we are in the mode with only one file static FILE *temp = nullptr; if (tracing_files == nullptr) { tracing_files = xbt_dict_new_homogeneous(nullptr); //generate unique run id with time prefix = xbt_os_time(); } if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) { char *folder_name = bprintf("%s_files", TRACE_get_filename()); char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name); #ifdef WIN32 _mkdir(folder_name); #else mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); #endif temp = fopen(filename, "w"); xbt_assert(temp, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); fprintf(tracing_file, "%s\n", filename); xbt_free(folder_name); xbt_free(filename); } xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr); }
static void* shm_map(int fd, size_t size, shared_data_t* data) { void* mem; char loc[PTR_STRLEN]; shared_metadata_t* meta; if(size > shm_size(fd)) { if(ftruncate(fd, (off_t)size) < 0) { xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno)); } } mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if(mem == MAP_FAILED) { xbt_die("Could not map fd %d: %s", fd, strerror(errno)); } if(!allocs_metadata) { allocs_metadata = xbt_dict_new(); } snprintf(loc, PTR_STRLEN, "%p", mem); meta = xbt_new(shared_metadata_t, 1); meta->size = size; meta->data = data; xbt_dict_set(allocs_metadata, loc, meta, &free); XBT_DEBUG("MMAP %zu to %p", size, mem); return mem; }
int console_host_set_property(lua_State *L) { const char* name =""; const char* prop_id = ""; const char* prop_value = ""; lua_ensure(lua_istable(L, -1), "Bad Arguments to create link, Should be a table with named arguments"); // get Host id lua_pushstring(L, "host"); lua_gettable(L, -2); name = lua_tostring(L, -1); lua_pop(L, 1); // get prop Name lua_pushstring(L, "prop"); lua_gettable(L, -2); prop_id = lua_tostring(L, -1); lua_pop(L, 1); //get args lua_pushstring(L,"value"); lua_gettable(L, -2); prop_value = lua_tostring(L,-1); lua_pop(L, 1); sg_host_t host = sg_host_by_name(name); lua_ensure(host, "no host '%s' found",name); xbt_dict_t props = sg_host_get_properties(host); xbt_dict_set(props,prop_id,xbt_strdup(prop_value),nullptr); return 0; }
StorageAction *StorageN11::open(const char* mount, const char* path) { XBT_DEBUG("\tOpen file '%s'",path); sg_size_t size, *psize; psize = (sg_size_t*) xbt_dict_get_or_null(content_, path); // if file does not exist create an empty file if(psize) size = *psize; else { psize = xbt_new(sg_size_t,1); size = 0; *psize = size; xbt_dict_set(content_, path, psize, nullptr); XBT_DEBUG("File '%s' was not found, file created.",path); } surf_file_t file = xbt_new0(s_surf_file_t,1); file->name = xbt_strdup(path); file->size = size; file->mount = xbt_strdup(mount); file->current_position = 0; StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, OPEN); action->p_file = file; return action; }
//used by all methods static void __TRACE_surf_check_variable_set_to_zero(double now, const char *variable, const char *resource) { /* * To trace resource utilization, we use pajeAddVariable and pajeSubVariable only. * The Paje simulator needs a pajeSetVariable in the first place so it knows * the initial value of all variables for subsequent adds/subs. If we don't do * so, the first pajeAddVariable is added to a non-determined value within * the Paje simulator, causing analysis problems. */ // create a key considering the resource and variable int n = strlen(variable)+strlen(resource)+1; char *key = (char*)xbt_malloc(n*sizeof(char)); snprintf (key, n, "%s%s", resource, variable); // check if key exists: if it doesn't, set the variable to zero and mark this in the dict if (!xbt_dict_get_or_null(platform_variables, key)) { container_t container = PJ_container_get (resource); type_t type = PJ_type_get (variable, container->type); new_pajeSetVariable (now, container, type, 0); xbt_dict_set(platform_variables, key, (char*)"", NULL); } xbt_free(key); }
void StorageN11Model::updateActionsState(double /*now*/, double delta) { StorageAction *action = nullptr; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; action = static_cast<StorageAction*>(&*it); if(action->m_type == WRITE){ // Update the disk usage // Update the file size // For each action of type write double current_progress = delta * lmm_variable_getvalue(action->getVariable()); long int incr = current_progress; XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld", action->p_file->name, action->progress, current_progress, incr, lrint(action->progress + current_progress), lrint(action->progress)+ incr); /* take care of rounding error accumulation */ if (lrint(action->progress + current_progress) > lrint(action->progress)+ incr) incr++; action->progress +=current_progress; action->p_storage->usedSize_ += incr; // disk usage action->p_file->current_position+= incr; // current_position // which becomes the new file size action->p_file->size = action->p_file->current_position ; sg_size_t *psize = xbt_new(sg_size_t,1); *psize = action->p_file->size; xbt_dict_t content_dict = action->p_storage->content_; xbt_dict_set(content_dict, action->p_file->name, psize, nullptr); } action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta); if (action->getMaxDuration() > NO_MAX_DURATION) action->updateMaxDuration(delta); if(action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 && action->p_storage->usedSize_ == action->p_storage->size_) { action->finish(); action->setState(Action::State::failed); } else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) || ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) { action->finish(); action->setState(Action::State::done); } } return; }
static void set_reqq_self(xbt_dynar_t mpi_request){ char * key; int size = asprintf(&key, "%d", smpi_process_index()); if(size==-1) xbt_die("could not allocate memory for asprintf"); xbt_dict_set(reqq, key, mpi_request, free); free(key); }
static void store_in_dict(xbt_dict_t dict, const char *key, double value) { double *ir; ir = xbt_dict_get_or_null(dict, key); if (!ir) { ir = xbt_new0(double, 1); xbt_dict_set(dict, key, ir, xbt_free_f); }
void STag_surfxml_prop(void) { if(AS_TAG){ if (!as_current_property_set){ xbt_assert(as_prop_nb < 1024, "Number of AS property reach the limit!!!"); as_current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error as_name_tab[as_prop_nb] = xbt_strdup(A_surfxml_AS_id); as_dict_tab[as_prop_nb] = as_current_property_set; XBT_DEBUG("PUSH prop %p for AS '%s'",as_dict_tab[as_prop_nb],as_name_tab[as_prop_nb]); as_prop_nb++; } xbt_dict_set(as_current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); } else{ if (!current_property_set) current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); } }
void* smpi_shared_set_call(const char* func, const char* input, void* data) { char* loc = bprintf("%s:%s", func, input); if(!calls) { calls = xbt_dict_new_homogeneous(NULL); } xbt_dict_set(calls, loc, data, NULL); free(loc); return data; }
xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name, xbt_dict_t nodes) { xbt_node_t ret = (xbt_node_t) xbt_dict_get_or_null(nodes, name); if (ret) return ret; ret = xbt_graph_new_node(graph, xbt_strdup(name)); xbt_dict_set(nodes, name, ret, nullptr); return ret; }
void STag_surfxml_prop(void) { if(AS_TAG){ // We need a stack here to retrieve the most recently opened AS if (!as_current_property_set){ xbt_assert(as_prop_nb < 1024, "Number of AS property reach the limit!!!"); as_current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error as_name_tab[as_prop_nb] = xbt_strdup(A_surfxml_AS_id); as_dict_tab[as_prop_nb] = as_current_property_set; XBT_DEBUG("PUSH prop set %p for AS '%s'",as_dict_tab[as_prop_nb],as_name_tab[as_prop_nb]); as_prop_nb++; } XBT_DEBUG("add prop %s=%s into current AS property set", A_surfxml_prop_id, A_surfxml_prop_value); xbt_dict_set(as_current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr); } else{ if (!current_property_set) current_property_set = xbt_dict_new(); // Maybe, it should raise an error xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), xbt_free_f); XBT_DEBUG("add prop %s=%s into current property set", A_surfxml_prop_id, A_surfxml_prop_value); } }
smx_mailbox_t SIMIX_mbox_create(const char *name) { xbt_assert(name, "Mailboxes must have a name"); /* two processes may have pushed the same mbox_create simcall at the same time */ smx_mailbox_t mbox = static_cast<smx_mailbox_t>(xbt_dict_get_or_null(mailboxes, name)); if (!mbox) { mbox = new simgrid::simix::Mailbox(name); XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name); xbt_dict_set(mailboxes, mbox->name, mbox, nullptr); } return mbox; }
xbt_dict_t Storage::getContent() { /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */ xbt_dict_t content_dict = xbt_dict_new_homogeneous(NULL); xbt_dict_cursor_t cursor = NULL; char *file; sg_size_t *psize; xbt_dict_foreach(p_content, cursor, file, psize){ xbt_dict_set(content_dict,file,psize,NULL); }
void sg_platf_new_trace(sg_platf_trace_cbarg_t trace) { tmgr_trace_t tmgr_trace; if (trace->file && strcmp(trace->file, "") != 0) { tmgr_trace = tmgr_trace_new_from_file(trace->file); } else { xbt_assert(strcmp(trace->pc_data, ""), "Trace '%s' must have either a content, or point to a file on disk.",trace->id); tmgr_trace = tmgr_trace_new_from_string(trace->id, trace->pc_data, trace->periodicity); } xbt_dict_set(traces_set_list, trace->id, (void *) tmgr_trace, nullptr); }
static void IB_create_host_callback(sg_platf_host_cbarg_t t){ static int id=0; // pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL) ((NetworkIBModel*)surf_network_model)->active_nodes=xbt_dict_new(); IBNode* act = new IBNode(id); id++; xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes, t->id, act, NULL); }
void TRACE_internal_smpi_set_category (const char *category) { if (!TRACE_smpi_is_enabled()) return; //declare category TRACE_category (category); char processid[INSTR_DEFAULT_STR_SIZE]; snprintf (processid, INSTR_DEFAULT_STR_SIZE, "%p", SIMIX_process_self()); if (xbt_dict_get_or_null (process_category, processid)) xbt_dict_remove (process_category, processid); if (category != NULL) xbt_dict_set (process_category, processid, xbt_strdup(category), NULL); }
static void simopen(const char *const *action) { const char *processid = action[0]; const char *file_name = action[2]; const char *index = action[4]; char full_name[1024]; msg_file_t file = NULL; double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */ sprintf(full_name, "%s:%s:%s", file_name,MSG_process_get_name(MSG_process_self()),index); ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name); file = MSG_file_open(full_name, NULL); xbt_dict_set(opened_files, full_name, file, NULL); log_action(action, MSG_get_clock() - clock); XBT_INFO("open worker %s%s is done",processid,index); }
void config_init_log_file(void) { xmlXPathObjectPtr xmlobject = NULL; const char *r = "/config/batch"; #ifdef VERBOSE fprintf(stderr, "Init log files : \n"); #endif xmlobject = config_get(r); if (!xmlobject) { #ifdef VERBOSE fprintf(stderr, "failed\n"); fprintf(stderr, "XPathError : %s\n", r); #endif free(config); exit(2); } if (xmlobject->type == XPATH_NODESET) if (xmlobject->nodesetval) { int i = 0; #ifdef VERBOSE fprintf(stderr, "\tnb log file : %d\n", xmlobject->nodesetval->nodeNr); #endif for (i=0; i<xmlobject->nodesetval->nodeNr; ++i) { char *logfile = NULL; FILE *flog = NULL; xmlChar *batchName; batchName = xmlGetProp(xmlobject->nodesetval->nodeTab[i], BAD_CAST("host")); logfile = calloc(xmlStrlen(batchName) + 5, sizeof(char)); sprintf(logfile, "%s.log", batchName); flog = (FILE *)xbt_dict_get_or_null(book_of_log, (char *)batchName); if (!flog) { flog = fopen(logfile, "w"); xbt_dict_set(book_of_log, (char *)batchName, flog, close_log_file); #ifdef VERBOSE fprintf(stderr, "\tlog file : %s\n", logfile); #endif free(logfile); } } } }
void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect) { xbt_assert(xbt_dict_get_or_null(traces_set_list, trace_connect->trace), "Cannot connect trace %s to %s: trace unknown", trace_connect->trace, trace_connect->element); switch (trace_connect->kind) { case SURF_TRACE_CONNECT_KIND_HOST_AVAIL: xbt_dict_set(trace_connect_list_host_avail, trace_connect->trace, xbt_strdup(trace_connect->element), NULL); break; case SURF_TRACE_CONNECT_KIND_SPEED: xbt_dict_set(trace_connect_list_host_speed, trace_connect->trace, xbt_strdup(trace_connect->element), NULL); break; case SURF_TRACE_CONNECT_KIND_LINK_AVAIL: xbt_dict_set(trace_connect_list_link_avail, trace_connect->trace, xbt_strdup(trace_connect->element), NULL); break; case SURF_TRACE_CONNECT_KIND_BANDWIDTH: xbt_dict_set(trace_connect_list_link_bw, trace_connect->trace, xbt_strdup(trace_connect->element), NULL); break; case SURF_TRACE_CONNECT_KIND_LATENCY: xbt_dict_set(trace_connect_list_link_lat, trace_connect->trace, xbt_strdup(trace_connect->element), NULL); break; default: surf_parse_error("Cannot connect trace %s to %s: kind of trace unknown", trace_connect->trace, trace_connect->element); break; } }
static void action_open(const char *const *action) { const char *file_name = action[2]; char full_name[1024]; msg_file_t file = NULL; double clock = MSG_get_clock(); snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name); ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name); file = MSG_file_open(file_name, NULL); xbt_dict_set(opened_files, full_name, file, NULL); log_action(action, MSG_get_clock() - clock); }
/** \ingroup m_host_management * \brief Return the content of mounted storages on an host. * \param host a host * \return a dict containing content (as a dict) of all storages mounted on the host */ xbt_dict_t MSG_host_get_storage_content(msg_host_t host) { xbt_assert((host != NULL), "Invalid parameters"); xbt_dict_t contents = xbt_dict_new_homogeneous(NULL); msg_storage_t storage; char* storage_name; char* mount_name; xbt_dict_cursor_t cursor = NULL; xbt_dict_t storage_list = simcall_host_get_mounted_storage_list(host); xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){ storage = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib,storage_name); xbt_dict_t content = simcall_storage_get_content(storage); xbt_dict_set(contents,mount_name, content,NULL); }
int main(int argc, char **argv) { const SD_workstation_t *workstations; SD_workstation_t w1; SD_workstation_t w2; const char *name1; const char *name2; xbt_dict_t props; xbt_dict_cursor_t cursor = NULL; char *key, *data; char noexist[] = "NoProp"; const char *value; char exist[] = "Hdd"; /* initialisation of SD */ SD_init(&argc, argv); if (argc < 2) { XBT_INFO("Usage: %s platform_file", argv[0]); XBT_INFO("example: %s sd_platform.xml", argv[0]); exit(1); } SD_create_environment(argv[1]); /* init of platform elements */ workstations = SD_workstation_get_list(); w1 = workstations[0]; w2 = workstations[1]; SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS); name1 = SD_workstation_get_name(w1); name2 = SD_workstation_get_name(w2); /* The host properties can be retrived from all interfaces */ XBT_INFO("Property list for workstation %s", name1); /* Get the property list of the workstation 1 */ props = SD_workstation_get_properties(w1); /* Trying to set a new property */ xbt_dict_set(props, "NewProp", strdup("newValue"), NULL); /* Print the properties of the workstation 1 */ xbt_dict_foreach(props, cursor, key, data) { XBT_INFO("\tProperty: %s has value: %s", key, data); }
void *smpi_shared_malloc(size_t size, const char *file, int line) { char *loc = bprintf("%zu_%s_%d", (size_t)getpid(), file, line); size_t len = strlen(loc); size_t i; int fd; void* mem; shared_data_t *data; for(i = 0; i < len; i++) { /* Make the 'loc' ID be a flat filename */ if(loc[i] == '/') { loc[i] = '_'; } } if (!allocs) { allocs = xbt_dict_new_homogeneous(free); } data = xbt_dict_get_or_null(allocs, loc); if(!data) { fd = shm_open(loc, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if(fd < 0) { switch(errno) { case EEXIST: xbt_die("Please cleanup /dev/shm/%s", loc); default: xbt_die("An unhandled error occured while opening %s: %s", loc, strerror(errno)); } } data = xbt_new(shared_data_t, 1); data->fd = fd; data->count = 1; data->loc = loc; mem = shm_map(fd, size, data); if(shm_unlink(loc) < 0) { XBT_WARN("Could not early unlink %s: %s", loc, strerror(errno)); } xbt_dict_set(allocs, loc, data, NULL); XBT_DEBUG("Mapping %s at %p through %d", loc, mem, fd); } else { mem = shm_map(data->fd, size, data); data->count++; } XBT_DEBUG("Malloc %zu in %p (metadata at %p)", size, mem, data); return mem; }