X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/18c57b27dd71ee7839c6a90368c845886a87d638..d6fc96fb24bb0006584d44bee70df5f67b37f5fb:/src/simix/smx_smurf.c diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index d16d6dfd8a..366897ab11 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -1,6 +1,7 @@ #include "smx_private.h" #include "xbt/fifo.h" #include "xbt/xbt_os_thread.h" +#include "../mc/mc_private.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_smurf, simix, "Logging specific to SIMIX (SMURF)"); @@ -13,16 +14,18 @@ XBT_INLINE smx_simcall_t SIMIX_simcall_mine() /** * \brief Makes the current process do a simcall to the kernel and yields - * until completion. + * until completion. If the current thread is maestro, we don't yield and + * execute the simcall directly. * \param self the current process */ void SIMIX_simcall_push(smx_process_t self) { if (self != simix_global->maestro_process) { XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), self->simcall.call); + SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); SIMIX_process_yield(self); } else { + XBT_DEBUG("I'm the maestro, execute the simcall directly"); SIMIX_simcall_pre(&self->simcall, 0); } } @@ -30,10 +33,15 @@ void SIMIX_simcall_push(smx_process_t self) void SIMIX_simcall_answer(smx_simcall_t simcall) { if (simcall->issuer != simix_global->maestro_process){ - XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall->call), simcall->call, + XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall->call), (int)simcall->call, simcall->issuer->name, simcall->issuer); simcall->issuer->simcall.call = SIMCALL_NONE; +/* This check should be useless and slows everyone. Reactivate if you see something + * weird in process scheduling. + */ +/* if(!xbt_dynar_member(simix_global->process_to_run, &(simcall->issuer))) */ xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, simcall->issuer); +/* else DIE_IMPOSSIBLE; */ } } @@ -117,6 +125,17 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) SIMIX_simcall_answer(simcall); break; + case SIMCALL_COMM_IPROBE: + simcall->comm_iprobe.result = SIMIX_comm_iprobe( + simcall->issuer, + simcall->comm_iprobe.rdv, + simcall->comm_iprobe.src, + simcall->comm_iprobe.tag, + simcall->comm_iprobe.match_fun, + simcall->comm_iprobe.data); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_COMM_DESTROY: SIMIX_comm_destroy(simcall->comm_destroy.comm); SIMIX_simcall_answer(simcall); @@ -179,7 +198,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) SIMIX_simcall_answer(simcall); break; - case SIMCALL_RDV_GEY_BY_NAME: + case SIMCALL_RDV_GET_BY_NAME: simcall->rdv_get_by_name.result = SIMIX_rdv_get_by_name(simcall->rdv_get_by_name.name); SIMIX_simcall_answer(simcall); @@ -197,120 +216,119 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) SIMIX_simcall_answer(simcall); break; + case SIMCALL_RDV_SET_RECV: + SIMIX_rdv_set_receiver(simcall->rdv_set_rcv_proc.rdv, simcall->rdv_set_rcv_proc.receiver); + SIMIX_simcall_answer(simcall); + break; + + case SIMCALL_RDV_GET_RECV: + simcall->rdv_get_rcv_proc.result = SIMIX_rdv_get_receiver(simcall->rdv_set_rcv_proc.rdv); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_HOST_GET_BY_NAME: simcall->host_get_by_name.result = - SIMIX_host_get_by_name(simcall->host_get_by_name.name); + SIMIX_host_get_by_name(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_GET_NAME: - simcall->host_get_name.result = SIMIX_host_get_name(simcall->host_get_name.host); + simcall->host_get_name.result = SIMIX_host_get_name(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_GET_PROPERTIES: simcall->host_get_properties.result = - SIMIX_host_get_properties(simcall->host_get_properties.host); + SIMIX_host_get_properties(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_GET_SPEED: simcall->host_get_speed.result = - SIMIX_host_get_speed(simcall->host_get_speed.host); + SIMIX_host_get_speed(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_GET_AVAILABLE_SPEED: simcall->host_get_available_speed.result = - SIMIX_host_get_available_speed(simcall->host_get_available_speed.host); + SIMIX_host_get_available_speed(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_GET_STATE: simcall->host_get_state.result = - SIMIX_host_get_state(simcall->host_get_state.host); + SIMIX_host_get_state(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_GET_DATA: - simcall->host_get_data.result = SIMIX_host_get_data(simcall->host_get_data.host); + simcall->host_get_data.result = SIMIX_host_get_data(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_SET_DATA: - SIMIX_host_set_data(simcall->host_set_data.host, simcall->host_set_data.data); + SIMIX_host_set_data(SIMIX_pack_args(PTR(simcall->host_set_data.host), PTR(simcall->host_set_data.data))); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTE: - simcall->host_execute.result = SIMIX_host_execute( - simcall->host_execute.name, - simcall->host_execute.host, - simcall->host_execute.computation_amount, - simcall->host_execute.priority); + simcall->host_execute.result = simcall_table[simcall->call](simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_PARALLEL_EXECUTE: - simcall->host_parallel_execute.result = SIMIX_host_parallel_execute( - simcall->host_parallel_execute.name, - simcall->host_parallel_execute.host_nb, - simcall->host_parallel_execute.host_list, - simcall->host_parallel_execute.computation_amount, - simcall->host_parallel_execute.communication_amount, - simcall->host_parallel_execute.amount, - simcall->host_parallel_execute.rate); + simcall->host_parallel_execute.result = SIMIX_host_parallel_execute(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTION_DESTROY: - SIMIX_host_execution_destroy(simcall->host_execution_destroy.execution); + SIMIX_host_execution_destroy(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTION_CANCEL: - SIMIX_host_execution_cancel(simcall->host_execution_cancel.execution); + SIMIX_host_execution_cancel(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTION_GET_REMAINS: simcall->host_execution_get_remains.result = - SIMIX_host_execution_get_remains(simcall->host_execution_get_remains.execution); + SIMIX_host_execution_get_remains(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTION_GET_STATE: simcall->host_execution_get_state.result = - SIMIX_host_execution_get_state(simcall->host_execution_get_state.execution); + SIMIX_host_execution_get_state(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTION_SET_PRIORITY: - SIMIX_host_execution_set_priority( - simcall->host_execution_set_priority.execution, - simcall->host_execution_set_priority.priority); + SIMIX_host_execution_set_priority(simcall->args); SIMIX_simcall_answer(simcall); break; case SIMCALL_HOST_EXECUTION_WAIT: - SIMIX_pre_host_execution_wait(simcall); + SIMIX_pre_host_execution_wait(simcall->args); break; case SIMCALL_PROCESS_CREATE: SIMIX_process_create( simcall->process_create.process, - simcall->process_create.name, - simcall->process_create.code, - simcall->process_create.data, - simcall->process_create.hostname, - simcall->process_create.argc, - simcall->process_create.argv, - simcall->process_create.properties); + simcall->process_create.name, + simcall->process_create.code, + simcall->process_create.data, + simcall->process_create.hostname, + simcall->process_create.kill_time, + simcall->process_create.argc, + simcall->process_create.argv, + simcall->process_create.properties, + simcall->process_create.auto_restart); SIMIX_simcall_answer(simcall); break; case SIMCALL_PROCESS_KILL: - SIMIX_process_kill(simcall->process_kill.process); + SIMIX_process_kill(simcall->process_kill.process,simcall->issuer); SIMIX_simcall_answer(simcall); break; @@ -326,8 +344,8 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) case SIMCALL_PROCESS_CHANGE_HOST: SIMIX_pre_process_change_host( - simcall->process_change_host.process, - simcall->process_change_host.dest); + simcall->process_change_host.process, + simcall->process_change_host.dest); SIMIX_simcall_answer(simcall); break; @@ -350,11 +368,24 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) SIMIX_process_get_data(simcall->process_get_data.process); SIMIX_simcall_answer(simcall); break; - + case SIMCALL_PROCESS_ON_EXIT: + SIMIX_process_on_exit(simcall->process_on_exit.process, + simcall->process_on_exit.fun, + simcall->process_on_exit.data); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_PROCESS_RESTART: + simcall->process_restart.result = SIMIX_process_restart(simcall->process_restart.process, simcall->issuer); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_PROCESS_AUTO_RESTART_SET: + SIMIX_process_auto_restart_set(simcall->process_auto_restart.process,simcall->process_auto_restart.auto_restart); + SIMIX_simcall_answer(simcall); + break; case SIMCALL_PROCESS_SET_DATA: SIMIX_process_set_data( - simcall->process_set_data.process, - simcall->process_set_data.data); + simcall->process_set_data.process, + simcall->process_set_data.data); SIMIX_simcall_answer(simcall); break; @@ -409,7 +440,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) case SIMCALL_MUTEX_TRYLOCK: simcall->mutex_trylock.result = - SIMIX_mutex_trylock(simcall->mutex_trylock.mutex, simcall->issuer); + SIMIX_mutex_trylock(simcall->mutex_trylock.mutex, simcall->issuer); SIMIX_simcall_answer(simcall); break; @@ -463,7 +494,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) case SIMCALL_SEM_WOULD_BLOCK: simcall->sem_would_block.result = - SIMIX_sem_would_block(simcall->sem_would_block.sem); + SIMIX_sem_would_block(simcall->sem_would_block.sem); SIMIX_simcall_answer(simcall); break; @@ -485,12 +516,62 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value) SIMIX_pre_file_read(simcall); break; + case SIMCALL_FILE_WRITE: + SIMIX_pre_file_write(simcall); + break; + + case SIMCALL_FILE_OPEN: + SIMIX_pre_file_open(simcall); + break; + + case SIMCALL_FILE_CLOSE: + SIMIX_pre_file_close(simcall); + break; + + case SIMCALL_FILE_STAT: + SIMIX_pre_file_stat(simcall); + break; + + case SIMCALL_FILE_UNLINK: + SIMIX_pre_file_unlink(simcall); + break; + + case SIMCALL_FILE_LS: + SIMIX_pre_file_ls(simcall); + break; + + case SIMCALL_ASR_GET_PROPERTIES: + simcall->asr_get_properties.result = + SIMIX_asr_get_properties(simcall->asr_get_properties.name); + SIMIX_simcall_answer(simcall); + break; + +#ifdef HAVE_MC + case SIMCALL_MC_SNAPSHOT: + simcall->mc_snapshot.s = MC_take_snapshot(); + SIMIX_simcall_answer(simcall); + break; + + case SIMCALL_MC_COMPARE_SNAPSHOTS: + simcall->mc_compare_snapshots.result = + snapshot_compare(simcall->mc_compare_snapshots.snapshot1, simcall->mc_compare_snapshots.snapshot2, NULL, NULL); + SIMIX_simcall_answer(simcall); + break; +#endif /* HAVE_MC */ + case SIMCALL_NONE: THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s", SIMIX_process_get_name(simcall->issuer), SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer)) ); break; + + /* ****************************************************************************************** */ + /* TUTORIAL: New API */ + /* ****************************************************************************************** */ + case SIMCALL_NEW_API_INIT: + SIMIX_pre_new_api_fct(simcall); + break; } } @@ -518,5 +599,83 @@ void SIMIX_simcall_post(smx_action_t action) case SIMIX_ACTION_IO: SIMIX_post_io(action); break; + + /* ****************************************************************************************** */ + /* TUTORIAL: New API */ + /* ****************************************************************************************** */ + case SIMIX_ACTION_NEW_API: + SIMIX_post_new_api(action); + break; + } +} + +/* New Simcal interface */ + +/* FIXME: add types for every simcall */ +const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" }; + +simcall_handler_t simcall_table[NUM_SIMCALLS] = { +#undef SIMCALL_ENUM_ELEMENT +#define SIMCALL_ENUM_ELEMENT(x,y) &y /* generate strings from the enumeration values */ +SIMCALL_LIST +#undef SIMCALL_ENUM_ELEMENT +}; + + +void SIMIX_simcall_typecheck(const char *fmt, ...) +{ + return; +} + +void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args) +{ + smx_process_t self = SIMIX_process_self(); + self->simcall.call = simcall_id; + self->simcall.args = args; + + if (self != simix_global->maestro_process) { + XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, + SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); + + SIMIX_process_yield(self); + } else { + + SIMIX_simcall_pre(&self->simcall, 0); + } +} + +/* New Simcal interface */ + +/* FIXME: add types for every simcall */ +const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p", [SIMCALL_HOST_EXECUTION_WAIT] = "%p%p" }; + + +simcall_handler_t simcall_table[NUM_SIMCALLS] = { +#undef SIMCALL_ENUM_ELEMENT +#define SIMCALL_ENUM_ELEMENT(x,y) &y /* generate strings from the enumeration values */ +SIMCALL_LIST +#undef SIMCALL_ENUM_ELEMENT +}; + + +void SIMIX_simcall_typecheck(const char *fmt, ...) +{ + return; +} + +void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args) +{ + smx_process_t self = SIMIX_process_self(); + self->simcall.call = simcall_id; + self->simcall.args = args; + + if (self != simix_global->maestro_process) { + XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, + SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); + + SIMIX_process_yield(self); + } else { + + SIMIX_simcall_pre(&self->simcall, 0); } }