XBT_PUBLIC(const char*) SIMIX_process_self_get_name();
XBT_PUBLIC(void) SIMIX_process_self_set_data(void *data);
XBT_PUBLIC(void*) SIMIX_process_self_get_data();
-XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_actor_t process);
-XBT_PUBLIC(void) SIMIX_process_set_context(smx_actor_t p,smx_context_t c);
XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_actor_t process);
XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_actor_t process);
XBT_PUBLIC(void) SIMIX_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data);
/* Process handling */
XBT_PUBLIC(void) simcall_process_cleanup(smx_actor_t process);
XBT_PUBLIC(void) simcall_process_suspend(smx_actor_t process);
-XBT_PUBLIC(void) simcall_process_resume(smx_actor_t process);
/* Getters and Setters */
XBT_PUBLIC(int) simcall_process_count();
XBT_PUBLIC(void) simcall_process_set_data(smx_actor_t process, void *data);
XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_actor_t host);
XBT_PUBLIC(void) simcall_process_set_kill_time(smx_actor_t process, double kill_time);
-XBT_PUBLIC(double) simcall_process_get_kill_time(smx_actor_t process);
XBT_PUBLIC(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data);
XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_actor_t process, int auto_restart);
XBT_PUBLIC(smx_actor_t) simcall_process_restart(smx_actor_t process);
smx_actor_t process;
unsigned int cursor;
xbt_dynar_foreach(processes, cursor, process) {
- static_cast<JavaContext*>(SIMIX_process_get_context(process))->resume();
+ static_cast<JavaContext*>(process->context)->resume();
}
}
region.block = ((char*)stack - (char*)heap->heapbase) / BLOCKSIZE + 1;
#if HAVE_SMPI
if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP && process)
- region.process_index = smpi_process_index_of_smx_process(process);
+ region.process_index = process->pid - 1;
else
#endif
region.process_index = -1;
xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
TRACE_msg_process_resume(process);
- simcall_process_resume(process->getImpl());
+ process->resume();
return MSG_OK;
}
}
smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
- return SIMIX_process_get_context(process->getImpl());
+ return process->getImpl()->context;
}
/**
* \ingroup m_process_management
smx_actor_t smx_process_safe;
xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
XBT_DEBUG("resume %s", smx_process->cname());
- SIMIX_process_resume(smx_process);
+ smx_process->resume();
}
vmState_ = SURF_VM_STATE_RUNNING;
void Actor::resume()
{
- simcall_process_resume(pimpl_);
+ simgrid::simix::kernelImmediate([this] { pimpl_->resume(); });
}
int Actor::isSuspended()
{
- return simgrid::simix::kernelImmediate([this]() { return pimpl_->suspended; });
+ return simgrid::simix::kernelImmediate([this] { return pimpl_->suspended; });
}
void Actor::setKillTime(double time) {
simcall_process_set_kill_time(pimpl_,time);
}
+/** \brief Get the kill time of an actor(or 0 if unset). */
double Actor::killTime()
{
- return simcall_process_get_kill_time(pimpl_);
+ return SIMIX_timer_get_date(pimpl_->kill_timer);
}
void Actor::kill(aid_t pid)
{
return (char*)xbt_dict_get_or_null(simcall_process_get_properties(pimpl_), key);
}
+
void Actor::setProperty(const char* key, const char* value)
{
simgrid::simix::kernelImmediate([this, key, value] {
void resume()
{
- simcall_process_resume(SIMIX_process_self());
+ smx_actor_t process = SIMIX_process_self();
+ simgrid::simix::kernelImmediate([process] { process->resume(); });
}
bool isSuspended()
}
}
-/** Whether this process is daemonized */
-bool ActorImpl::isDaemon()
+void ActorImpl::resume()
{
- return daemon;
+ XBT_IN("process = %p", this);
+
+ if (context->iwannadie) {
+ XBT_VERB("Ignoring request to suspend a process that is currently dying.");
+ return;
+ }
+
+ if (not suspended)
+ return;
+ suspended = 0;
+
+ /* resume the synchronization that was blocking the resumed process. */
+ if (waiting_synchro)
+ waiting_synchro->resume();
+
+ XBT_OUT();
}
void create_maestro(std::function<void()> code)
#if HAVE_SMPI
if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) {
if (parent_process->pid != 0) {
- SIMIX_segment_index_set(process, parent_process->segment_index);
+ process->segment_index = parent_process->segment_index;
} else {
- SIMIX_segment_index_set(process, process->pid - 1);
+ process->segment_index = process->pid - 1;
}
}
#endif
#if HAVE_SMPI
if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) {
if (parent_process->pid != 0) {
- SIMIX_segment_index_set(process, parent_process->segment_index);
+ process->segment_index = parent_process->segment_index;
} else {
- SIMIX_segment_index_set(process, process->pid - 1);
+ process->segment_index = process->pid - 1;
}
}
#endif
SMX_EXCEPTION(process, cat, value, msg);
if (process->suspended)
- SIMIX_process_resume(process);
+ process->resume();
/* cancel the blocking synchro if any */
if (process->waiting_synchro) {
xbt_swag_insert(process, dest->extension<simgrid::simix::Host>()->process_list);
}
-
void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process)
{
smx_activity_t sync_suspend = SIMIX_process_suspend(process, simcall->issuer);
}
}
-void SIMIX_process_resume(smx_actor_t process)
-{
- XBT_IN("process = %p", process);
-
- if (process->context->iwannadie) {
- XBT_VERB("Ignoring request to suspend a process that is currently dying.");
- return;
- }
-
- if (not process->suspended)
- return;
- process->suspended = 0;
-
- /* resume the synchronization that was blocking the resumed process. */
- if (process->waiting_synchro)
- process->waiting_synchro->resume();
-
- XBT_OUT();
-}
-
int SIMIX_process_get_maxpid() {
return simix_process_maxpid;
}
return simix_global->process_list.size();
}
-int SIMIX_process_get_PID(smx_actor_t self)
-{
- if (self == nullptr)
- return 0;
- else
- return self->pid;
-}
-
void* SIMIX_process_self_get_data()
{
smx_actor_t self = SIMIX_process_self();
return nullptr;
}
-int SIMIX_process_is_suspended(smx_actor_t process)
-{
- return process->suspended;
-}
-
-xbt_dict_t SIMIX_process_get_properties(smx_actor_t process)
-{
- return process->properties;
-}
-
void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout)
{
if (process->finished) {
xbt_abort();
}
-smx_context_t SIMIX_process_get_context(smx_actor_t p) {
- return p->context;
-}
-
-void SIMIX_process_set_context(smx_actor_t p,smx_context_t c) {
- p->context = c;
-}
-
/**
* \brief Returns the list of processes to run.
*/
return actor;
}
-void SIMIX_segment_index_set(smx_actor_t proc, int index){
- proc->segment_index = index;
-}
-
/**
* \ingroup simix_process_management
* \brief Creates and runs a new SIMIX process.
bool daemon = false;
public:
void daemonize();
- bool isDaemon();
+ bool isDaemon() { return daemon; } /** Whether this actor has been daemonized */
+ bool isSuspended() { return suspended; }
+ void resume();
};
}
XBT_PRIVATE void SIMIX_process_yield(smx_actor_t self);
XBT_PRIVATE void SIMIX_process_exception_terminate(xbt_ex_t * e);
XBT_PRIVATE void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest);
-XBT_PRIVATE void SIMIX_process_resume(smx_actor_t process);
-XBT_PRIVATE int SIMIX_process_get_PID(smx_actor_t self);
XBT_PRIVATE void SIMIX_process_set_data(smx_actor_t process, void *data);
XBT_PRIVATE smx_actor_t SIMIX_process_get_by_name(const char* name);
-XBT_PRIVATE int SIMIX_process_is_suspended(smx_actor_t process);
-XBT_PRIVATE xbt_dict_t SIMIX_process_get_properties(smx_actor_t process);
XBT_PRIVATE void SIMIX_process_auto_restart_set(smx_actor_t process, int auto_restart);
XBT_PRIVATE smx_actor_t SIMIX_process_restart(smx_actor_t process, smx_actor_t issuer);
-void SIMIX_segment_index_set(smx_actor_t process, int segment_index);
extern void (*SMPI_switch_data_segment)(int dest);
SG_END_DECL()
simcall_BODY_process_suspend(process);
}
-/**
- * \ingroup simix_process_management
- * \brief Resumes a suspended process.
- *
- * This function resumes a suspended process by resuming the synchro
- * it was waiting for completion.
- *
- * \param process a SIMIX process
- */
-void simcall_process_resume(smx_actor_t process)
-{
- simcall_BODY_process_resume(process);
-}
-
/**
* \ingroup simix_process_management
* \brief Returns the amount of SIMIX processes in the system
process->kill_timer=nullptr;
});
}
-/**
- * \ingroup simix_process_management
- * \brief Get the kill time of a process (or 0 if unset).
- */
-double simcall_process_get_kill_time(smx_actor_t process) {
- return SIMIX_timer_get_date(process->kill_timer);
-}
/**
* \ingroup simix_process_management
* \brief Return the properties
*
- * This functions returns the properties associated with this process
+ * This function returns the properties associated with this process
*/
xbt_dict_t simcall_process_get_properties(smx_actor_t process)
{
- return SIMIX_process_get_properties(process);
+ return process->properties;
+ ;
}
/**
* \ingroup simix_process_management
simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
}
-static inline smx_actor_t simcall_process_resume__get__process(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
-}
-static inline smx_actor_t simcall_process_resume__getraw__process(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<smx_actor_t>(simcall->args[0]);
-}
-static inline void simcall_process_resume__set__process(smx_simcall_t simcall, smx_actor_t arg)
-{
- simgrid::simix::marshal<smx_actor_t>(simcall->args[0], arg);
-}
-
static inline smx_actor_t simcall_process_join__get__process(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]);
return simcall<void, smx_actor_t>(SIMCALL_PROCESS_SUSPEND, process);
}
-inline static void simcall_BODY_process_resume(smx_actor_t process) {
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_process_resume(process);
- return simcall<void, smx_actor_t>(SIMCALL_PROCESS_RESUME, process);
- }
-
inline static int simcall_BODY_process_join(smx_actor_t process, double timeout) {
/* Go to that function to follow the code flow through the simcall barrier */
if (0) simcall_HANDLER_process_join(&SIMIX_process_self()->simcall, process, timeout);
SIMCALL_PROCESS_KILLALL,
SIMCALL_PROCESS_CLEANUP,
SIMCALL_PROCESS_SUSPEND,
- SIMCALL_PROCESS_RESUME,
SIMCALL_PROCESS_JOIN,
SIMCALL_PROCESS_SLEEP,
SIMCALL_EXECUTION_START,
"SIMCALL_PROCESS_KILLALL",
"SIMCALL_PROCESS_CLEANUP",
"SIMCALL_PROCESS_SUSPEND",
- "SIMCALL_PROCESS_RESUME",
"SIMCALL_PROCESS_JOIN",
"SIMCALL_PROCESS_SLEEP",
"SIMCALL_EXECUTION_START",
simcall_HANDLER_process_suspend(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
break;
-case SIMCALL_PROCESS_RESUME:
- SIMIX_process_resume(simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]));
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_PROCESS_JOIN:
simcall_HANDLER_process_join(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<double>(simcall->args[1]));
break;
void process_killall(int reset_pid);
void process_cleanup(smx_actor_t process) [[nohandler]];
void process_suspend(smx_actor_t process) [[block]];
-void process_resume(smx_actor_t process) [[nohandler]];
int process_join(smx_actor_t process, double timeout) [[block]];
int process_sleep(double duration) [[block]];
case SIMCALL_NONE:
case SIMCALL_PROCESS_KILL:
return 2;
- case SIMCALL_PROCESS_RESUME:
- return 1;
+ // case SIMCALL_PROCESS_RESUME:
+ // return 1;
default:
return 0;
}
/* If any of the process is suspend, create the synchro but stop its execution,
it will be restarted when the sender process resume */
- if (SIMIX_process_is_suspended(comm->src_proc) || SIMIX_process_is_suspended(comm->dst_proc)) {
- if (SIMIX_process_is_suspended(comm->src_proc))
+ if (comm->src_proc->isSuspended() || comm->dst_proc->isSuspended()) {
+ if (comm->src_proc->isSuspended())
XBT_DEBUG("The communication is suspended on startup because src (%s@%s) was suspended since it initiated the "
"communication",
comm->src_proc->cname(), comm->src_proc->host->cname());
extern XBT_PRIVATE int smpi_loaded_page;
extern XBT_PRIVATE int smpi_universe_size;
-XBT_PRIVATE int SIMIX_process_get_PID(smx_actor_t self);
-
-static inline __attribute__ ((always_inline))
-int smpi_process_index_of_smx_process(smx_actor_t process) {
- return SIMIX_process_get_PID(process) -1;
-}
-
SG_END_DECL()
#endif
smx_actor_t proc = SIMIX_process_self();
proc->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
- int index = smpi_process_index_of_smx_process(proc);
+ int index = proc->pid - 1;
if(index_to_process_data == nullptr){
index_to_process_data=static_cast<int*>(xbt_malloc(SIMIX_process_count()*sizeof(int)));
static void xbt_log_help(void)
{
- printf(
-"Description of the logging output:\n"
-"\n"
-" Threshold configuration: --log=CATEGORY_NAME.thres:PRIORITY_LEVEL\n"
-" CATEGORY_NAME: defined in code with function 'XBT_LOG_NEW_CATEGORY'\n"
-" PRIORITY_LEVEL: the level to print (trace,debug,verbose,info,warning,error,critical)\n"
-" -> trace: enter and return of some functions\n"
-" -> debug: crufty output\n"
-" -> verbose: verbose output for the user wanting more\n"
-" -> info: output about the regular functionning\n"
-" -> warning: minor issue encountered\n"
-" -> error: issue encountered\n"
-" -> critical: major issue encountered\n"
-"\n"
-" Format configuration: --log=CATEGORY_NAME.fmt:OPTIONS\n"
-" OPTIONS may be:\n"
-" -> %%%%: the %% char\n"
-" -> %%n: platform-dependent line separator (LOG4J compatible)\n"
-" -> %%e: plain old space (SimGrid extension)\n"
-"\n"
-" -> %%m: user-provided message\n"
-"\n"
-" -> %%c: Category name (LOG4J compatible)\n"
-" -> %%p: Priority name (LOG4J compatible)\n"
-"\n"
-" -> %%h: Hostname (SimGrid extension)\n"
-" -> %%P: Process name (SimGrid extension)\n"
-" -> %%t: Thread \"name\" (LOG4J compatible -- actually the address of the thread in memory)\n"
-" -> %%i: Process PID (SimGrid extension -- this is a 'i' as in 'i'dea)\n"
-"\n"
-" -> %%F: file name where the log event was raised (LOG4J compatible)\n"
-" -> %%l: location where the log event was raised (LOG4J compatible, like '%%F:%%L' -- this is a l as in 'l'etter)\n"
-" -> %%L: line number where the log event was raised (LOG4J compatible)\n"
-" -> %%M: function name (LOG4J compatible -- called method name here of course).\n"
-" Defined only when using gcc because there is no __FUNCTION__ elsewhere.\n"
-"\n"
-" -> %%b: full backtrace (Called %%throwable in LOG4J). Defined only under windows or when using the GNU libc because\n"
-" backtrace() is not defined elsewhere, and we only have a fallback for windows boxes, not mac ones for example.\n"
-" -> %%B: short backtrace (only the first line of the %%b). Called %%throwable{short} in LOG4J; defined where %%b is.\n"
-"\n"
-" -> %%d: date (UNIX-like epoch)\n"
-" -> %%r: application age (time elapsed since the beginning of the application)\n"
-"\n"
-" Miscellaneous:\n"
-" --help-log-categories Display the current hierarchy of log categories.\n"
-" --log=no_loc Don't print file names in messages (for tesh tests).\n"
-"\n"
- );
+ printf("Description of the logging output:\n"
+ "\n"
+ " Threshold configuration: --log=CATEGORY_NAME.thres:PRIORITY_LEVEL\n"
+ " CATEGORY_NAME: defined in code with function 'XBT_LOG_NEW_CATEGORY'\n"
+ " PRIORITY_LEVEL: the level to print (trace,debug,verbose,info,warning,error,critical)\n"
+ " -> trace: enter and return of some functions\n"
+ " -> debug: crufty output\n"
+ " -> verbose: verbose output for the user wanting more\n"
+ " -> info: output about the regular functioning\n"
+ " -> warning: minor issue encountered\n"
+ " -> error: issue encountered\n"
+ " -> critical: major issue encountered\n"
+ "\n"
+ " Format configuration: --log=CATEGORY_NAME.fmt:OPTIONS\n"
+ " OPTIONS may be:\n"
+ " -> %%%%: the %% char\n"
+ " -> %%n: platform-dependent line separator (LOG4J compatible)\n"
+ " -> %%e: plain old space (SimGrid extension)\n"
+ "\n"
+ " -> %%m: user-provided message\n"
+ "\n"
+ " -> %%c: Category name (LOG4J compatible)\n"
+ " -> %%p: Priority name (LOG4J compatible)\n"
+ "\n"
+ " -> %%h: Hostname (SimGrid extension)\n"
+ " -> %%P: Process name (SimGrid extension)\n"
+ " -> %%t: Thread \"name\" (LOG4J compatible -- actually the address of the thread in memory)\n"
+ " -> %%i: Process PID (SimGrid extension -- this is a 'i' as in 'i'dea)\n"
+ "\n"
+ " -> %%F: file name where the log event was raised (LOG4J compatible)\n"
+ " -> %%l: location where the log event was raised (LOG4J compatible, like '%%F:%%L' -- this is a l as "
+ "in 'l'etter)\n"
+ " -> %%L: line number where the log event was raised (LOG4J compatible)\n"
+ " -> %%M: function name (LOG4J compatible -- called method name here of course).\n"
+ " Defined only when using gcc because there is no __FUNCTION__ elsewhere.\n"
+ "\n"
+ " -> %%b: full backtrace (Called %%throwable in LOG4J). Defined only under windows or when using the "
+ "GNU libc because\n"
+ " backtrace() is not defined elsewhere, and we only have a fallback for windows boxes, not "
+ "mac ones for example.\n"
+ " -> %%B: short backtrace (only the first line of the %%b). Called %%throwable{short} in LOG4J; "
+ "defined where %%b is.\n"
+ "\n"
+ " -> %%d: date (UNIX-like epoch)\n"
+ " -> %%r: application age (time elapsed since the beginning of the application)\n"
+ "\n"
+ " Miscellaneous:\n"
+ " --help-log-categories Display the current hierarchy of log categories.\n"
+ " --log=no_loc Don't print file names in messages (for tesh tests).\n"
+ "\n");
}
static int xbt_log_cat_cmp(const void *pa, const void *pb)