X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/04fa61785ae1ecb5e5233ef0cb6d24145120d95e..f6755a2f88d16e9249253ee380f3555f1cfdb085:/doc/doxygen/uhood_switch.doc diff --git a/doc/doxygen/uhood_switch.doc b/doc/doxygen/uhood_switch.doc index bc6b8f3a2f..684eacbb20 100644 --- a/doc/doxygen/uhood_switch.doc +++ b/doc/doxygen/uhood_switch.doc @@ -304,14 +304,14 @@ as input. It looks like this: # This looks like C++ but it is a basic IDL-like language # (one definition per line) parsed by a python script: -void process_kill(smx_process_t process); +void process_kill(smx_actor_t process); void process_killall(int reset_pid); -void process_cleanup(smx_process_t process) [[nohandler]]; -void process_suspend(smx_process_t process) [[block]]; -void process_resume(smx_process_t process); -void process_set_host(smx_process_t process, sg_host_t dest); -int process_is_suspended(smx_process_t process) [[nohandler]]; -int process_join(smx_process_t process, double timeout) [[block]]; +void process_cleanup(smx_actor_t process) [[nohandler]]; +void process_suspend(smx_actor_t process) [[block]]; +void process_resume(smx_actor_t process); +void process_set_host(smx_actor_t process, sg_host_t dest); +int process_is_suspended(smx_actor_t process) [[nohandler]]; +int process_join(smx_actor_t process, double timeout) [[block]]; int process_sleep(double duration) [[block]]; smx_mutex_t mutex_init(); @@ -330,7 +330,7 @@ struct s_smx_simcall { // Simcall number: e_smx_simcall_t call; // Issuing actor: - smx_process_t issuer; + smx_actor_t issuer; // Arguments of the simcall: union u_smx_scalar args[11]; // Result of the simcall: @@ -371,7 +371,7 @@ this generates a bunch of C++ files: responsible for wrapping the parameters in the `struct s_smx_simcall`; and wrapping out the result; -* [accessors](https://github.com/simgrid/simgrid/blob/4ae2fd01d8cc55bf83654e29f294335e3cb1f022/src/simix/popping_accessors.h) +* [accessors](https://github.com/simgrid/simgrid/blob/4ae2fd01d8cc55bf83654e29f294335e3cb1f022/src/simix/popping_accessors.hpp) to get/set values of of `struct s_smx_simcall`; * a simulation-kernel-side [big switch](https://github.com/simgrid/simgrid/blob/4ae2fd01d8cc55bf83654e29f294335e3cb1f022/src/simix/popping_generated.cpp#L106) @@ -481,7 +481,7 @@ auto kernelSync(F code) -> decltype(code().get()) if (SIMIX_is_maestro()) xbt_die("Can't execute blocking call in kernel mode"); - smx_process_t self = SIMIX_process_self(); + smx_actor_t self = SIMIX_process_self(); simgrid::xbt::Result result; simcall_run_blocking([&result, self, &code]{ @@ -551,7 +551,7 @@ T simgrid::simix::Future::get() { if (!valid()) throw std::future_error(std::future_errc::no_state); - smx_process_t self = SIMIX_process_self(); + smx_actor_t self = SIMIX_process_self(); simgrid::xbt::Result result; simcall_run_blocking([this, &result, self]{ try { @@ -621,79 +621,6 @@ instead of one to do the same job (one in `kernelAsync()` and one in ## Mutexes and condition variables -## Mutexes - -SimGrid has had a C-based API for mutexes and condition variables for -some time. These mutexes are different from the standard -system-level mutex (`std::mutex`, `pthread_mutex_t`, etc.) because -they work at simulation-level. Locking on a simulation mutex does -not block the thread directly but makes a simcall -(`simcall_mutex_lock()`) which asks the simulation kernel to wake the calling -actor when it can get ownership of the mutex. Blocking directly at the -OS level would deadlock the simulation. - -Reusing the C++ standard API for our simulation mutexes has many -benefits: - - * it makes it easier for people familiar with the `std::mutex` to - understand and use SimGrid mutexes; - - * we can benefit from a proven API; - - * we can reuse from generic library code in SimGrid. - -We defined a reference-counted `Mutex` class for this (which supports -the [`Lockable`](http://en.cppreference.com/w/cpp/concept/Lockable) -requirements, see -[`[thread.req.lockable.req]`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf#page=1175) -in the C++14 standard): - -@code{cpp} -class Mutex { - friend ConditionVariable; -private: - friend simgrid::simix::Mutex; - simgrid::simix::Mutex* mutex_; - Mutex(simgrid::simix::Mutex* mutex) : mutex_(mutex) {} -public: - - friend void intrusive_ptr_add_ref(Mutex* mutex); - friend void intrusive_ptr_release(Mutex* mutex); - using Ptr = boost::intrusive_ptr; - - // No copy: - Mutex(Mutex const&) = delete; - Mutex& operator=(Mutex const&) = delete; - - static Ptr createMutex(); - -public: - void lock(); - void unlock(); - bool try_lock(); -}; -@endcode - -The methods are simply wrappers around existing simcalls: - -@code{cpp} -void Mutex::lock() -{ - simcall_mutex_lock(mutex_); -} -@endcode - -Using the same API as `std::mutex` (`Lockable`) means we can use existing -C++-standard code such as `std::unique_lock` or -`std::lock_guard` for exception-safe mutex handling[^lock]: - -@code{cpp} -{ - std::lock_guard lock(*mutex); - sum += 1; -} -@endcode - ### Condition Variables Similarly SimGrid already had simulation-level condition variables @@ -702,7 +629,7 @@ which can be exposed using the same API as `std::condition_variable`: @code{cpp} class ConditionVariable { private: - friend s_smx_cond; + friend s_smx_cond_t; smx_cond_t cond_; ConditionVariable(smx_cond_t cond) : cond_(cond) {} public: