Esempio n. 1
0
void simcall_HANDLER_comm_testany(
  smx_simcall_t simcall, simgrid::kernel::activity::ActivityImpl* comms[], size_t count)
{
  // The default result is -1 -- this means, "nothing is ready".
  // It can be changed below, but only if something matches.
  simcall_comm_testany__set__result(simcall, -1);

  if (MC_is_active() || MC_record_replay_is_active()){
    int idx = SIMCALL_GET_MC_VALUE(simcall);
    if(idx == -1){
      SIMIX_simcall_answer(simcall);
    }else{
      simgrid::kernel::activity::ActivityImpl* synchro = comms[idx];
      simcall_comm_testany__set__result(simcall, idx);
      synchro->simcalls.push_back(simcall);
      synchro->state = SIMIX_DONE;
      SIMIX_comm_finish(synchro);
    }
    return;
  }

  for (std::size_t i = 0; i != count; ++i) {
    simgrid::kernel::activity::ActivityImpl* synchro = comms[i];
    if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING) {
      simcall_comm_testany__set__result(simcall, i);
      synchro->simcalls.push_back(simcall);
      SIMIX_comm_finish(synchro);
      return;
    }
  }
  SIMIX_simcall_answer(simcall);
}
Esempio n. 2
0
void SIMIX_synchro_finish(smx_activity_t synchro)
{
  XBT_IN("(%p)",synchro);
  smx_simcall_t simcall = synchro->simcalls.front();
  synchro->simcalls.pop_front();

  switch (synchro->state) {

    case SIMIX_SRC_TIMEOUT:
      SMX_EXCEPTION(simcall->issuer, timeout_error, 0, "Synchro's wait timeout");
      break;

    case SIMIX_FAILED:
        simcall->issuer->context->iwannadie = 1;
//      SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
      break;

    default:
      THROW_IMPOSSIBLE;
      break;
  }

  SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
  simcall->issuer->waiting_synchro = nullptr;
  delete synchro;
  SIMIX_simcall_answer(simcall);
  XBT_OUT();
}
Esempio n. 3
0
/** Unlock a mutex for a process
 *
 * Unlocks the mutex and gives it to a process waiting for it. 
 * If the unlocker is not the owner of the mutex nothing happens.
 * If there are no process waiting, it sets the mutex as free.
 */
void Mutex::unlock(smx_actor_t issuer)
{
  XBT_IN("(%p, %p)", this, issuer);
  if(!this->locked)
    THROWF(mismatch_error, 0, "Cannot release that mutex: it was not locked.");

  /* If the mutex is not owned by the issuer, that's not good */
  if (issuer != this->owner)
    THROWF(mismatch_error, 0, "Cannot release that mutex: it was locked by %s (pid:%ld), not by you.",
        this->owner->name.c_str(),this->owner->pid);

  if (xbt_swag_size(this->sleeping) > 0) {
    /*process to wake up */
    smx_actor_t p = (smx_actor_t) xbt_swag_extract(this->sleeping);
    delete p->waiting_synchro;
    p->waiting_synchro = nullptr;
    this->owner = p;
    SIMIX_simcall_answer(&p->simcall);
  } else {
    /* nobody to wake up */
    this->locked = false;
    this->owner = nullptr;
  }
  XBT_OUT();
}
Esempio n. 4
0
void SIMIX_io_finish(smx_activity_t synchro)
{
  for (smx_simcall_t const& simcall : synchro->simcalls_) {
    switch (synchro->state_) {
      case SIMIX_DONE:
        /* do nothing, synchro done */
        break;
      case SIMIX_FAILED:
        SMX_EXCEPTION(simcall->issuer, io_error, 0, "IO failed");
        break;
      case SIMIX_CANCELED:
        SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
        break;
      default:
        xbt_die("Internal error in SIMIX_io_finish: unexpected synchro state %d", static_cast<int>(synchro->state_));
    }

    if (simcall->issuer->host->is_off()) {
      simcall->issuer->context->iwannadie = 1;
    }

    simcall->issuer->waiting_synchro = nullptr;
    SIMIX_simcall_answer(simcall);
  }

  /* We no longer need it */
  SIMIX_io_destroy(synchro);
}
Esempio n. 5
0
static void SIMIX_synchro_finish(smx_action_t action)
{
  XBT_IN("(%p)",action);
  smx_simcall_t simcall = xbt_fifo_shift(action->simcalls);

  switch (action->state) {

    case SIMIX_SRC_TIMEOUT:
      SMX_EXCEPTION(simcall->issuer, timeout_error, 0, "Synchro's wait timeout");
      break;

    case SIMIX_FAILED:
        simcall->issuer->context->iwannadie = 1;
//      SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
      break;

    default:
      THROW_IMPOSSIBLE;
      break;
  }

  SIMIX_synchro_stop_waiting(simcall->issuer, simcall);
  simcall->issuer->waiting_action = NULL;
  SIMIX_synchro_destroy(action);
  SIMIX_simcall_answer(simcall);
  XBT_OUT();
}
Esempio n. 6
0
void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
{
  bool res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING);
  if (res) {
    synchro->simcalls_.push_back(simcall);
    synchro->finish();
  } else {
    SIMIX_simcall_answer(simcall);
  }
  simcall_execution_test__set__result(simcall, res);
}
Esempio n. 7
0
/** @brief release the semaphore
 *
 * Unlock a process waiting on the semaphore.
 * If no one was blocked, the semaphore capacity is increased by 1.
 */
void SIMIX_sem_release(smx_sem_t sem)
{
  XBT_IN("(%p)",sem);
  smx_process_t proc;

  XBT_DEBUG("Sem release semaphore %p", sem);
  if ((proc = xbt_swag_extract(sem->sleeping))) {
    SIMIX_synchro_destroy(proc->waiting_action);
    proc->waiting_action = NULL;
    SIMIX_simcall_answer(&proc->simcall);
  } else if (sem->value < SMX_SEM_NOLIMIT) {
    sem->value++;
  }
  XBT_OUT();
}
Esempio n. 8
0
/** @brief release the semaphore
 *
 * Unlock a process waiting on the semaphore.
 * If no one was blocked, the semaphore capacity is increased by 1.
 */
void SIMIX_sem_release(smx_sem_t sem)
{
  XBT_IN("(%p)",sem);
  smx_actor_t proc;

  XBT_DEBUG("Sem release semaphore %p", sem);
  if ((proc = (smx_actor_t) xbt_swag_extract(sem->sleeping))) {
    delete proc->waiting_synchro;
    proc->waiting_synchro = nullptr;
    SIMIX_simcall_answer(&proc->simcall);
  } else if (sem->value < SMX_SEM_NOLIMIT) {
    sem->value++;
  }
  XBT_OUT();
}
Esempio n. 9
0
void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_activity_t synchro)
{
  simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);

  if (MC_is_active() || MC_record_replay_is_active()){
    simcall_comm_test__set__result(simcall, comm->src_proc && comm->dst_proc);
    if (simcall_comm_test__get__result(simcall)){
      synchro->state = SIMIX_DONE;
      synchro->simcalls.push_back(simcall);
      SIMIX_comm_finish(synchro);
    } else {
      SIMIX_simcall_answer(simcall);
    }
    return;
  }

  simcall_comm_test__set__result(simcall, (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING));
  if (simcall_comm_test__get__result(simcall)) {
    synchro->simcalls.push_back(simcall);
    SIMIX_comm_finish(synchro);
  } else {
    SIMIX_simcall_answer(simcall);
  }
}
Esempio n. 10
0
void ExecImpl::finish()
{
  while (not simcalls_.empty()) {
    smx_simcall_t simcall = simcalls_.front();
    simcalls_.pop_front();
    switch (state_) {

      case SIMIX_DONE:
        /* do nothing, synchro done */
        XBT_DEBUG("ExecImpl::finish(): execution successful");
        break;

      case SIMIX_FAILED:
        XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer->get_host()->get_cname());
        simcall->issuer->context_->iwannadie = true;
        if (simcall->issuer->get_host()->is_on())
          simcall->issuer->exception_ =
              std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
        /* else, the actor will be killed with no possibility to survive */
        break;

      case SIMIX_CANCELED:
        XBT_DEBUG("ExecImpl::finish(): execution canceled");
        simcall->issuer->exception_ =
            std::make_exception_ptr(simgrid::CancelException(XBT_THROW_POINT, "Execution Canceled"));
        break;

      case SIMIX_TIMEOUT:
        XBT_DEBUG("ExecImpl::finish(): execution timeouted");
        simcall->issuer->exception_ = std::make_exception_ptr(simgrid::TimeoutError(XBT_THROW_POINT, "Timeouted"));
        break;

      default:
        xbt_die("Internal error in ExecImpl::finish(): unexpected synchro state %d", static_cast<int>(state_));
    }

    simcall->issuer->waiting_synchro = nullptr;
    simcall_execution_wait__set__result(simcall, state_);

    /* Fail the process if the host is down */
    if (simcall->issuer->get_host()->is_on())
      SIMIX_simcall_answer(simcall);
    else
      simcall->issuer->context_->iwannadie = true;
  }
}
Esempio n. 11
0
static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
                            smx_simcall_t simcall)
{
  XBT_IN("(%p, %f, %p, %p)",sem,timeout,issuer,simcall);
  smx_action_t sync_act = NULL;

  XBT_DEBUG("Wait semaphore %p (timeout:%f)", sem, timeout);
  if (sem->value <= 0) {
    sync_act = SIMIX_synchro_wait(issuer->smx_host, timeout);
    xbt_fifo_unshift(sync_act->simcalls, simcall);
    issuer->waiting_action = sync_act;
    xbt_swag_insert(issuer, sem->sleeping);
  } else {
    sem->value--;
    SIMIX_simcall_answer(simcall);
  }
  XBT_OUT();
}
Esempio n. 12
0
static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_actor_t issuer,
                            smx_simcall_t simcall)
{
  XBT_IN("(%p, %f, %p, %p)",sem,timeout,issuer,simcall);
  smx_activity_t synchro = nullptr;

  XBT_DEBUG("Wait semaphore %p (timeout:%f)", sem, timeout);
  if (sem->value <= 0) {
    synchro = SIMIX_synchro_wait(issuer->host, timeout);
    synchro->simcalls.push_front(simcall);
    issuer->waiting_synchro = synchro;
    xbt_swag_insert(issuer, sem->sleeping);
  } else {
    sem->value--;
    SIMIX_simcall_answer(simcall);
  }
  XBT_OUT();
}
Esempio n. 13
0
void RawImpl::finish()
{
  smx_simcall_t simcall = simcalls_.front();
  simcalls_.pop_front();

  if (state_ == SIMIX_FAILED) {
    XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer->get_host()->get_cname());
    simcall->issuer->context_->iwannadie = true;
    simcall->issuer->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
  } else if (state_ != SIMIX_SRC_TIMEOUT) {
    xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast<int>(state_));
  }

  switch (simcall->call) {

    case SIMCALL_MUTEX_LOCK:
      simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping_, *simcall->issuer);
      break;

    case SIMCALL_COND_WAIT:
      simgrid::xbt::intrusive_erase(simcall_cond_wait__get__cond(simcall)->sleeping_, *simcall->issuer);
      break;

    case SIMCALL_COND_WAIT_TIMEOUT:
      simgrid::xbt::intrusive_erase(simcall_cond_wait_timeout__get__cond(simcall)->sleeping_, *simcall->issuer);
      simcall_cond_wait_timeout__set__result(simcall, 1); // signal a timeout
      break;

    case SIMCALL_SEM_ACQUIRE:
      simgrid::xbt::intrusive_erase(simcall_sem_acquire__get__sem(simcall)->sleeping_, *simcall->issuer);
      break;

    case SIMCALL_SEM_ACQUIRE_TIMEOUT:
      simgrid::xbt::intrusive_erase(simcall_sem_acquire_timeout__get__sem(simcall)->sleeping_, *simcall->issuer);
      simcall_sem_acquire_timeout__set__result(simcall, 1); // signal a timeout
      break;

    default:
      THROW_IMPOSSIBLE;
  }
  simcall->issuer->waiting_synchro = nullptr;
  SIMIX_simcall_answer(simcall);
}
Esempio n. 14
0
void Mutex::lock(smx_actor_t issuer)
{
  XBT_IN("(%p; %p)", this, issuer);
  /* FIXME: check where to validate the arguments */
  smx_activity_t synchro = nullptr;

  if (this->locked) {
    /* FIXME: check if the host is active ? */
    /* Somebody using the mutex, use a synchronization to get host failures */
    synchro = SIMIX_synchro_wait(issuer->host, -1);
    synchro->simcalls.push_back(&issuer->simcall);
    issuer->waiting_synchro = synchro;
    xbt_swag_insert(issuer, this->sleeping);
  } else {
    /* mutex free */
    this->locked = true;
    this->owner = issuer;
    SIMIX_simcall_answer(&issuer->simcall);
  }
  XBT_OUT();
}
Esempio n. 15
0
/**
 * \brief Handles a mutex lock simcall.
 * \param simcall the simcall
 */
void SIMIX_pre_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex)
{
  XBT_IN("(%p)",simcall);
  /* FIXME: check where to validate the arguments */
  smx_action_t sync_act = NULL;
  smx_process_t process = simcall->issuer;

  if (mutex->locked) {
    /* FIXME: check if the host is active ? */
    /* Somebody using the mutex, use a synchro action to get host failures */
    sync_act = SIMIX_synchro_wait(process->smx_host, -1);
    xbt_fifo_push(sync_act->simcalls, simcall);
    simcall->issuer->waiting_action = sync_act;
    xbt_swag_insert(simcall->issuer, mutex->sleeping);   
  } else {
    /* mutex free */
    mutex->locked = 1;
    mutex->owner = simcall->issuer;
    SIMIX_simcall_answer(simcall);
  }
  XBT_OUT();
}
Esempio n. 16
0
void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, xbt_dynar_t synchros, double timeout)
{
  smx_activity_t synchro;
  unsigned int cursor = 0;

  if (MC_is_active() || MC_record_replay_is_active()){
    if (timeout > 0.0)
      xbt_die("Timeout not implemented for waitany in the model-checker"); 
    int idx = SIMCALL_GET_MC_VALUE(simcall);
    synchro = xbt_dynar_get_as(synchros, idx, smx_activity_t);
    synchro->simcalls.push_back(simcall);
    simcall_comm_waitany__set__result(simcall, idx);
    synchro->state = SIMIX_DONE;
    SIMIX_comm_finish(synchro);
    return;
  }
  
  if (timeout < 0.0){
    simcall->timer = NULL;
  } else {
    simcall->timer = SIMIX_timer_set(SIMIX_get_clock() + timeout, [simcall]() {
      SIMIX_waitany_remove_simcall_from_actions(simcall);
      simcall_comm_waitany__set__result(simcall, -1);
      SIMIX_simcall_answer(simcall);
    });
  }
  
  xbt_dynar_foreach(synchros, cursor, synchro){
    /* associate this simcall to the the synchro */
    synchro->simcalls.push_back(simcall);

    /* see if the synchro is already finished */
    if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING){
      SIMIX_comm_finish(synchro);
      break;
    }
  }
Esempio n. 17
0
void simgrid::kernel::activity::SleepImpl::post()
{
  while (not simcalls_.empty()) {
    smx_simcall_t simcall = simcalls_.front();
    simcalls_.pop_front();

    e_smx_state_t result;
    switch (surf_sleep->get_state()) {
      case simgrid::kernel::resource::Action::State::FAILED:
        simcall->issuer->context->iwannadie = 1;
        result                              = SIMIX_SRC_HOST_FAILURE;
        break;

      case simgrid::kernel::resource::Action::State::FINISHED:
        result = SIMIX_DONE;
        break;

      default:
        THROW_IMPOSSIBLE;
        break;
    }
    if (simcall->issuer->host->is_off()) {
      simcall->issuer->context->iwannadie = 1;
    }
    simcall_process_sleep__set__result(simcall, result);
    simcall->issuer->waiting_synchro = nullptr;
    if (simcall->issuer->suspended) {
      XBT_DEBUG("Wait! This process is suspended and can't wake up now.");
      simcall->issuer->suspended = 0;
      simcall_HANDLER_process_suspend(simcall, simcall->issuer);
    } else {
      SIMIX_simcall_answer(simcall);
    }
  }

  SIMIX_process_sleep_destroy(this);
}
Esempio n. 18
0
/**
 * \brief Unlocks a mutex.
 *
 * Unlocks the mutex and gives it to a process waiting for it. 
 * If the unlocker is not the owner of the mutex nothing happens.
 * If there are no process waiting, it sets the mutex as free.
 * \param mutex The mutex
 * \param issuer The process trying to unlock the mutex
 */
void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer)
{
  XBT_IN("(%p, %p)",mutex,issuer);
  smx_process_t p;              /*process to wake up */

  /* If the mutex is not owned by the issuer do nothing */
  if (issuer != mutex->owner){
    XBT_OUT();
    return;
  }

  if (xbt_swag_size(mutex->sleeping) > 0) {
    p = xbt_swag_extract(mutex->sleeping);
    SIMIX_synchro_destroy(p->waiting_action);
    p->waiting_action = NULL;
    mutex->owner = p;
    SIMIX_simcall_answer(&p->simcall);
  } else {
    /* nobody to wake up */
    mutex->locked = 0;
    mutex->owner = NULL;
  }
  XBT_OUT();
}
Esempio n. 19
0
/**
 * @brief (in kernel mode) unpack the simcall and activate the handler
 * 
 * This function is generated from src/simix/simcalls.in
 */
void SIMIX_simcall_handle(smx_simcall_t simcall, int value) {
  XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));
  SIMCALL_SET_MC_VALUE(simcall, value);
  if (simcall->issuer->context->iwannadie && simcall->call != SIMCALL_PROCESS_CLEANUP)
    return;
  switch (simcall->call) {
case SIMCALL_HOST_GET_BY_NAME:
      simcall->result.dp = SIMIX_host_get_by_name( simcall->args[0].cc);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_NAME:
      simcall->result.cc = SIMIX_host_get_name((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_ON:
       SIMIX_host_on((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_OFF:
       simcall_HANDLER_host_off(simcall , (smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_PROPERTIES:
      simcall->result.dp = SIMIX_host_get_properties((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_CORE:
      simcall->result.i = SIMIX_host_get_core((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_PROCESS_LIST:
      simcall->result.dp = SIMIX_host_get_process_list((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_SPEED:
      simcall->result.d = SIMIX_host_get_speed((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_AVAILABLE_SPEED:
      simcall->result.d = SIMIX_host_get_available_speed((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_STATE:
      simcall->result.i = SIMIX_host_get_state((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_CURRENT_POWER_PEAK:
      simcall->result.d = SIMIX_host_get_current_power_peak((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_POWER_PEAK_AT:
      simcall->result.d = SIMIX_host_get_power_peak_at((smx_host_t) simcall->args[0].dp, simcall->args[1].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_NB_PSTATES:
      simcall->result.i = SIMIX_host_get_nb_pstates((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_SET_POWER_PEAK_AT:
       SIMIX_host_set_power_peak_at((smx_host_t) simcall->args[0].dp, simcall->args[1].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_CONSUMED_ENERGY:
      simcall->result.d = SIMIX_host_get_consumed_energy((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTE:
      simcall->result.dp = SIMIX_host_execute( simcall->args[0].cc,(smx_host_t) simcall->args[1].dp, simcall->args[2].d, simcall->args[3].d, simcall->args[4].d, simcall->args[5].ul);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_PARALLEL_EXECUTE:
      simcall->result.dp = SIMIX_host_parallel_execute( simcall->args[0].cc, simcall->args[1].i,(smx_host_t*) simcall->args[2].dp,(double*) simcall->args[3].dp,(double*) simcall->args[4].dp, simcall->args[5].d, simcall->args[6].d);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_DESTROY:
       SIMIX_host_execution_destroy((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_CANCEL:
       SIMIX_host_execution_cancel((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_GET_REMAINS:
      simcall->result.d = SIMIX_host_execution_get_remains((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_GET_STATE:
      simcall->result.i = SIMIX_host_execution_get_state((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_SET_PRIORITY:
       SIMIX_host_execution_set_priority((smx_synchro_t) simcall->args[0].dp, simcall->args[1].d);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_SET_BOUND:
       SIMIX_host_execution_set_bound((smx_synchro_t) simcall->args[0].dp, simcall->args[1].d);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_SET_AFFINITY:
       SIMIX_host_execution_set_affinity((smx_synchro_t) simcall->args[0].dp,(smx_host_t) simcall->args[1].dp, simcall->args[2].ul);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_EXECUTION_WAIT:
       simcall_HANDLER_host_execution_wait(simcall , (smx_synchro_t) simcall->args[0].dp);
       break;  

case SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST:
      simcall->result.dp = SIMIX_host_get_mounted_storage_list((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST:
      simcall->result.dp = SIMIX_host_get_attached_storage_list((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_GET_PARAMS:
       SIMIX_host_get_params((smx_host_t) simcall->args[0].dp,(ws_params_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_HOST_SET_PARAMS:
       SIMIX_host_set_params((smx_host_t) simcall->args[0].dp,(ws_params_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_CREATE:
      simcall->result.dp = SIMIX_vm_create( simcall->args[0].cc,(smx_host_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_START:
       SIMIX_vm_start((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_GET_STATE:
      simcall->result.i = SIMIX_vm_get_state((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_MIGRATE:
       SIMIX_vm_migrate((smx_host_t) simcall->args[0].dp,(smx_host_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_GET_PM:
      simcall->result.dp = SIMIX_vm_get_pm((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_SET_BOUND:
       SIMIX_vm_set_bound((smx_host_t) simcall->args[0].dp, simcall->args[1].d);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_SET_AFFINITY:
       SIMIX_vm_set_affinity((smx_host_t) simcall->args[0].dp,(smx_host_t) simcall->args[1].dp, simcall->args[2].ul);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_DESTROY:
       SIMIX_vm_destroy((smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_SUSPEND:
       simcall_HANDLER_vm_suspend(simcall , (smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_RESUME:
       simcall_HANDLER_vm_resume(simcall , (smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_SHUTDOWN:
       simcall_HANDLER_vm_shutdown(simcall , (smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_SAVE:
       simcall_HANDLER_vm_save(simcall , (smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_VM_RESTORE:
       simcall_HANDLER_vm_restore(simcall , (smx_host_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_CREATE:
       simcall_HANDLER_process_create(simcall , (smx_process_t*) simcall->args[0].dp,  simcall->args[1].cc, (xbt_main_func_t) simcall->args[2].fp,  simcall->args[3].dp,  simcall->args[4].cc,  simcall->args[5].d,  simcall->args[6].i, (char**) simcall->args[7].dp, (xbt_dict_t) simcall->args[8].dp,  simcall->args[9].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_KILL:
       simcall_HANDLER_process_kill(simcall , (smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_KILLALL:
       simcall_HANDLER_process_killall(simcall ,  simcall->args[0].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_CLEANUP:
       SIMIX_process_cleanup((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_CHANGE_HOST:
       simcall_HANDLER_process_change_host(simcall , (smx_process_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_SUSPEND:
       simcall_HANDLER_process_suspend(simcall , (smx_process_t) simcall->args[0].dp);
       break;  

case SIMCALL_PROCESS_RESUME:
       simcall_HANDLER_process_resume(simcall , (smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_COUNT:
      simcall->result.i = SIMIX_process_count();
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_GET_PID:
      simcall->result.i = SIMIX_process_get_PID((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_GET_PPID:
      simcall->result.i = SIMIX_process_get_PPID((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_GET_DATA:
      simcall->result.dp = SIMIX_process_get_data((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_SET_DATA:
       SIMIX_process_set_data((smx_process_t) simcall->args[0].dp, simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_GET_HOST:
      simcall->result.dp = SIMIX_process_get_host((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_GET_NAME:
      simcall->result.cc = SIMIX_process_get_name((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_IS_SUSPENDED:
      simcall->result.i = SIMIX_process_is_suspended((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_GET_PROPERTIES:
      simcall->result.dp = SIMIX_process_get_properties((smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_JOIN:
       simcall_HANDLER_process_join(simcall , (smx_process_t) simcall->args[0].dp,  simcall->args[1].d);
       break;  

case SIMCALL_PROCESS_SLEEP:
       simcall_HANDLER_process_sleep(simcall ,  simcall->args[0].d);
       break;  

case SIMCALL_PROCESS_ON_EXIT:
       SIMIX_process_on_exit((smx_process_t) simcall->args[0].dp,(int_f_pvoid_pvoid_t) simcall->args[1].fp, simcall->args[2].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_AUTO_RESTART_SET:
       SIMIX_process_auto_restart_set((smx_process_t) simcall->args[0].dp, simcall->args[1].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_PROCESS_RESTART:
      simcall->result.dp = simcall_HANDLER_process_restart(simcall , (smx_process_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_RDV_CREATE:
      simcall->result.dp = SIMIX_rdv_create( simcall->args[0].cc);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_RDV_DESTROY:
       SIMIX_rdv_destroy((smx_rdv_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_RDV_COMM_COUNT_BY_HOST:
      simcall->result.ui = SIMIX_rdv_comm_count_by_host((smx_rdv_t) simcall->args[0].dp,(smx_host_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_RDV_GET_HEAD:
      simcall->result.dp = SIMIX_rdv_get_head((smx_rdv_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_RDV_SET_RECEIVER:
       SIMIX_rdv_set_receiver((smx_rdv_t) simcall->args[0].dp,(smx_process_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_RDV_GET_RECEIVER:
      simcall->result.dp = SIMIX_rdv_get_receiver((smx_rdv_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_IPROBE:
      simcall->result.dp = simcall_HANDLER_comm_iprobe(simcall , (smx_rdv_t) simcall->args[0].dp,  simcall->args[1].i,  simcall->args[2].i,  simcall->args[3].i, (simix_match_func_t) simcall->args[4].fp,  simcall->args[5].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_SEND:
       simcall_HANDLER_comm_send(simcall , (smx_process_t) simcall->args[0].dp, (smx_rdv_t) simcall->args[1].dp,  simcall->args[2].d,  simcall->args[3].d,  simcall->args[4].dp,  simcall->args[5].sz, (simix_match_func_t) simcall->args[6].fp, (simix_copy_data_func_t) simcall->args[7].fp,  simcall->args[8].dp,  simcall->args[9].d);
       break;  

case SIMCALL_COMM_ISEND:
      simcall->result.dp = simcall_HANDLER_comm_isend(simcall , (smx_process_t) simcall->args[0].dp, (smx_rdv_t) simcall->args[1].dp,  simcall->args[2].d,  simcall->args[3].d,  simcall->args[4].dp,  simcall->args[5].sz, (simix_match_func_t) simcall->args[6].fp, (simix_clean_func_t) simcall->args[7].fp, (simix_copy_data_func_t) simcall->args[8].fp,  simcall->args[9].dp,  simcall->args[10].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_RECV:
       simcall_HANDLER_comm_recv(simcall , (smx_rdv_t) simcall->args[0].dp,  simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, (simix_copy_data_func_t) simcall->args[4].fp,  simcall->args[5].dp,  simcall->args[6].d,  simcall->args[7].d);
       break;  

case SIMCALL_COMM_IRECV:
      simcall->result.dp = simcall_HANDLER_comm_irecv(simcall , (smx_rdv_t) simcall->args[0].dp,  simcall->args[1].dp, (size_t*) simcall->args[2].dp, (simix_match_func_t) simcall->args[3].fp, (simix_copy_data_func_t) simcall->args[4].fp,  simcall->args[5].dp,  simcall->args[6].d);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_CANCEL:
       SIMIX_comm_cancel((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_WAITANY:
       simcall_HANDLER_comm_waitany(simcall , (xbt_dynar_t) simcall->args[0].dp);
       break;  

case SIMCALL_COMM_WAIT:
       simcall_HANDLER_comm_wait(simcall , (smx_synchro_t) simcall->args[0].dp,  simcall->args[1].d);
       break;  

case SIMCALL_COMM_TEST:
       simcall_HANDLER_comm_test(simcall , (smx_synchro_t) simcall->args[0].dp);
       break;  

case SIMCALL_COMM_TESTANY:
       simcall_HANDLER_comm_testany(simcall , (xbt_dynar_t) simcall->args[0].dp);
       break;  

case SIMCALL_COMM_GET_REMAINS:
      simcall->result.d = SIMIX_comm_get_remains((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_GET_STATE:
      simcall->result.i = SIMIX_comm_get_state((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_GET_SRC_DATA:
      simcall->result.dp = SIMIX_comm_get_src_data((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_GET_DST_DATA:
      simcall->result.dp = SIMIX_comm_get_dst_data((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_GET_SRC_PROC:
      simcall->result.dp = SIMIX_comm_get_src_proc((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COMM_GET_DST_PROC:
      simcall->result.dp = SIMIX_comm_get_dst_proc((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_MUTEX_INIT:
      simcall->result.dp = simcall_HANDLER_mutex_init(simcall );
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_MUTEX_DESTROY:
       SIMIX_mutex_destroy((smx_mutex_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_MUTEX_LOCK:
       simcall_HANDLER_mutex_lock(simcall , (smx_mutex_t) simcall->args[0].dp);
       break;  

case SIMCALL_MUTEX_TRYLOCK:
      simcall->result.i = simcall_HANDLER_mutex_trylock(simcall , (smx_mutex_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_MUTEX_UNLOCK:
       simcall_HANDLER_mutex_unlock(simcall , (smx_mutex_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COND_INIT:
      simcall->result.dp = SIMIX_cond_init();
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COND_DESTROY:
       SIMIX_cond_destroy((smx_cond_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COND_SIGNAL:
       SIMIX_cond_signal((smx_cond_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_COND_WAIT:
       simcall_HANDLER_cond_wait(simcall , (smx_cond_t) simcall->args[0].dp, (smx_mutex_t) simcall->args[1].dp);
       break;  

case SIMCALL_COND_WAIT_TIMEOUT:
       simcall_HANDLER_cond_wait_timeout(simcall , (smx_cond_t) simcall->args[0].dp, (smx_mutex_t) simcall->args[1].dp,  simcall->args[2].d);
       break;  

case SIMCALL_COND_BROADCAST:
       SIMIX_cond_broadcast((smx_cond_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_SEM_INIT:
      simcall->result.dp = SIMIX_sem_init( simcall->args[0].ui);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_SEM_DESTROY:
       SIMIX_sem_destroy((smx_sem_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_SEM_RELEASE:
       simcall_HANDLER_sem_release(simcall , (smx_sem_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_SEM_WOULD_BLOCK:
      simcall->result.i = simcall_HANDLER_sem_would_block(simcall , (smx_sem_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_SEM_ACQUIRE:
       simcall_HANDLER_sem_acquire(simcall , (smx_sem_t) simcall->args[0].dp);
       break;  

case SIMCALL_SEM_ACQUIRE_TIMEOUT:
       simcall_HANDLER_sem_acquire_timeout(simcall , (smx_sem_t) simcall->args[0].dp,  simcall->args[1].d);
       break;  

case SIMCALL_SEM_GET_CAPACITY:
      simcall->result.i = simcall_HANDLER_sem_get_capacity(simcall , (smx_sem_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_FILE_READ:
       simcall_HANDLER_file_read(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgsz, (smx_host_t) simcall->args[2].dp);
       break;  

case SIMCALL_FILE_WRITE:
       simcall_HANDLER_file_write(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgsz, (smx_host_t) simcall->args[2].dp);
       break;  

case SIMCALL_FILE_OPEN:
       simcall_HANDLER_file_open(simcall ,  simcall->args[0].cc, (smx_host_t) simcall->args[1].dp);
       break;  

case SIMCALL_FILE_CLOSE:
       simcall_HANDLER_file_close(simcall , (smx_file_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp);
       break;  

case SIMCALL_FILE_UNLINK:
      simcall->result.i = SIMIX_file_unlink((smx_file_t) simcall->args[0].dp,(smx_host_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_FILE_GET_SIZE:
      simcall->result.sgsz = simcall_HANDLER_file_get_size(simcall , (smx_file_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_FILE_TELL:
      simcall->result.sgsz = simcall_HANDLER_file_tell(simcall , (smx_file_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_FILE_SEEK:
      simcall->result.i = simcall_HANDLER_file_seek(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].sgoff,  simcall->args[2].i);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_FILE_GET_INFO:
      simcall->result.dp = simcall_HANDLER_file_get_info(simcall , (smx_file_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_FILE_MOVE:
      simcall->result.i = simcall_HANDLER_file_move(simcall , (smx_file_t) simcall->args[0].dp,  simcall->args[1].cc);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_STORAGE_GET_FREE_SIZE:
      simcall->result.sgsz = simcall_HANDLER_storage_get_free_size(simcall , (smx_storage_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_STORAGE_GET_USED_SIZE:
      simcall->result.sgsz = simcall_HANDLER_storage_get_used_size(simcall , (smx_storage_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_STORAGE_GET_PROPERTIES:
      simcall->result.dp = SIMIX_storage_get_properties((smx_storage_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_STORAGE_GET_CONTENT:
      simcall->result.dp = SIMIX_storage_get_content((smx_storage_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_ASR_GET_PROPERTIES:
      simcall->result.dp = simcall_HANDLER_asr_get_properties(simcall ,  simcall->args[0].cc);
      SIMIX_simcall_answer(simcall);
      break;  

#ifdef HAVE_LATENCY_BOUND_TRACKING
case SIMCALL_COMM_IS_LATENCY_BOUNDED:
      simcall->result.i = SIMIX_comm_is_latency_bounded((smx_synchro_t) simcall->args[0].dp);
      SIMIX_simcall_answer(simcall);
      break;  

#endif

#ifdef HAVE_TRACING
case SIMCALL_SET_CATEGORY:
       SIMIX_set_category((smx_synchro_t) simcall->args[0].dp, simcall->args[1].cc);
      SIMIX_simcall_answer(simcall);
      break;  

#endif

#ifdef HAVE_MC
case SIMCALL_MC_SNAPSHOT:
      simcall->result.dp = simcall_HANDLER_mc_snapshot(simcall );
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_MC_COMPARE_SNAPSHOTS:
      simcall->result.i = simcall_HANDLER_mc_compare_snapshots(simcall , (mc_snapshot_t) simcall->args[0].dp, (mc_snapshot_t) simcall->args[1].dp);
      SIMIX_simcall_answer(simcall);
      break;  

case SIMCALL_MC_RANDOM:
      simcall->result.i = simcall_HANDLER_mc_random(simcall ,  simcall->args[0].i,  simcall->args[1].i);
      SIMIX_simcall_answer(simcall);
      break;  

#endif
    case NUM_SIMCALLS:
      break;
    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;

  }
}
Esempio n. 20
0
void unblock(smx_actor_t process)
{
  xbt_assert(SIMIX_is_maestro());
  SIMIX_simcall_answer(&process->simcall);
}