smx_simcall_t simcall)
{
XBT_IN("(%p, %p, %f, %p,%p)", cond, mutex, timeout, issuer, simcall);
- smx_activity_t synchro = nullptr;
+ simgrid::kernel::activity::RawImplPtr synchro = nullptr;
XBT_DEBUG("Wait condition %p", cond);
mutex->unlock(issuer);
}
- synchro = SIMIX_synchro_wait(issuer->get_host(), timeout);
+ synchro = simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl())
+ ->start(issuer->get_host(), timeout);
synchro->simcalls_.push_front(simcall);
issuer->waiting_synchro = synchro;
cond->sleeping.push_back(*simcall->issuer);
{
XBT_IN("(%p; %p)", this, issuer);
/* FIXME: check where to validate the arguments */
- smx_activity_t synchro = nullptr;
+ RawImplPtr 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->get_host(), -1);
+ synchro = RawImplPtr(new RawImpl())->start(issuer->get_host(), -1);
synchro->simcalls_.push_back(&issuer->simcall);
issuer->waiting_synchro = synchro;
this->sleeping.push_back(*issuer);
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/activity/SemaphoreImpl.hpp"
+#include "src/kernel/activity/SynchroRaw.hpp"
#include "src/simix/smx_synchro_private.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_semaphore, simix_synchro, "Semaphore kernel-space implementation");
void SemaphoreImpl::acquire(smx_actor_t issuer, double timeout)
{
- smx_activity_t synchro = nullptr;
+ RawImplPtr synchro = nullptr;
XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout);
if (value_ <= 0) {
- synchro = SIMIX_synchro_wait(issuer->get_host(), timeout);
+ synchro = RawImplPtr(new RawImpl())->start(issuer->get_host(), timeout);
synchro->simcalls_.push_front(&issuer->simcall);
issuer->waiting_synchro = synchro;
sleeping_.push_back(*issuer);
#include "simgrid/kernel/resource/Action.hpp"
#include "src/kernel/context/Context.hpp"
#include "src/simix/smx_synchro_private.hpp"
+#include "src/surf/cpu_interface.hpp"
#include "src/surf/surf_interface.hpp"
+#include <simgrid/s4u/Host.hpp>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
+
namespace simgrid {
namespace kernel {
namespace activity {
+RawImpl* RawImpl::start(s4u::Host* host, double timeout)
+{
+ surf_action_ = host->pimpl_cpu->sleep(timeout);
+ surf_action_->set_data(this);
+ return this;
+}
+
RawImpl::~RawImpl()
{
surf_action_->unref();
}
+
void RawImpl::suspend()
{
/* The suspension of raw synchros is delayed to when the process is rescheduled. */
class XBT_PUBLIC RawImpl : public ActivityImpl {
public:
~RawImpl() override;
+ RawImpl* start(s4u::Host* host, double timeout);
void suspend() override;
void resume() override;
void post() override;
std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
std::function<void()> code;
- smx_timer_t kill_timer = nullptr;
+ simix::Timer* kill_timer = nullptr;
private:
/* Refcounting */
#include "src/kernel/activity/ConditionVariableImpl.hpp"
#include "src/kernel/activity/MutexImpl.hpp"
#include "src/kernel/activity/SemaphoreImpl.hpp"
-#include "src/kernel/activity/SynchroRaw.hpp"
#include "src/kernel/context/Context.hpp"
#include "src/simix/smx_synchro_private.hpp"
-#include "src/surf/cpu_interface.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_synchro, simix, "SIMIX Synchronization (mutex, semaphores and conditions)");
/***************************** Raw synchronization *********************************/
-smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
-{
- XBT_IN("(%p, %f)",smx_host,timeout);
-
- simgrid::kernel::activity::RawImplPtr sync =
- simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl());
- sync->surf_action_ = smx_host->pimpl_cpu->sleep(timeout);
- sync->surf_action_->set_data(sync.get());
- XBT_OUT();
- return sync;
-}
-
void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall)
{
XBT_IN("(%p, %p)",process,simcall);
#include "src/simix/ActorImpl.hpp"
-smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout);
-
XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_actor_t process, smx_simcall_t simcall);
#endif