3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
5 static const char* request_names[] = {
6 #undef SIMIX_REQ_ENUM_ELEMENT
7 #define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
9 #undef SIMIX_REQ_ENUM_ELEMENT
13 * \brief Returns a host given its name.
15 * \param name The name of the host to get
16 * \return The corresponding host
18 smx_host_t SIMIX_req_host_get_by_name(const char *name)
20 smx_req_t req = SIMIX_req_mine();
22 req->call = REQ_HOST_GET_BY_NAME;
23 req->host_get_by_name.name = name;
25 return req->host_get_by_name.result;
29 * \brief Returns the name of a host.
31 * \param host A SIMIX host
32 * \return The name of this host
34 const char* SIMIX_req_host_get_name(smx_host_t host)
36 smx_req_t req = SIMIX_req_mine();
38 req->call = REQ_HOST_GET_NAME;
39 req->host_get_name.host = host;
41 return req->host_get_name.result;
45 * \brief Returns a dict of the properties assigned to a host.
48 * \return The properties of this host
50 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
52 smx_req_t req = SIMIX_req_mine();
54 req->call = REQ_HOST_GET_PROPERTIES;
55 req->host_get_properties.host = host;
57 return req->host_get_properties.result;
61 * \brief Returns the speed of the processor.
63 * The speed returned does not take into account the current load on the machine.
64 * \param host A SIMIX host
65 * \return The speed of this host (in Mflop/s)
67 double SIMIX_req_host_get_speed(smx_host_t host)
69 smx_req_t req = SIMIX_req_mine();
71 req->call = REQ_HOST_GET_SPEED;
72 req->host_get_speed.host = host;
74 return req->host_get_speed.result;
78 * \brief Returns the available speed of the processor.
80 * \return Speed currently available (in Mflop/s)
82 double SIMIX_req_host_get_available_speed(smx_host_t host)
84 smx_req_t req = SIMIX_req_mine();
86 req->call = REQ_HOST_GET_AVAILABLE_SPEED;
87 req->host_get_available_speed.host = host;
89 return req->host_get_available_speed.result;
93 * \brief Returns the state of a host.
95 * Two states are possible: 1 if the host is active or 0 if it has crashed.
96 * \param host A SIMIX host
97 * \return 1 if the host is available, 0 otherwise
99 int SIMIX_req_host_get_state(smx_host_t host)
101 smx_req_t req = SIMIX_req_mine();
103 req->call = REQ_HOST_GET_STATE;
104 req->host_get_state.host = host;
105 SIMIX_request_push();
106 return req->host_get_state.result;
110 * \brief Returns the user data associated to a host.
112 * \param host SIMIX host
113 * \return the user data of this host
115 void* SIMIX_req_host_get_data(smx_host_t host)
117 smx_req_t req = SIMIX_req_mine();
119 req->call = REQ_HOST_GET_DATA;
120 req->host_get_data.host = host;
121 SIMIX_request_push();
122 return req->host_get_data.result;
126 * \brief Sets the user data associated to a host.
128 * The host must not have previous user data associated to it.
129 * \param A host SIMIX host
130 * \param data The user data to set
132 void SIMIX_req_host_set_data(smx_host_t host, void *data)
134 smx_req_t req = SIMIX_req_mine();
136 req->call = REQ_HOST_SET_DATA;
137 req->host_set_data.host = host;
138 req->host_set_data.data = data;
139 SIMIX_request_push();
142 /** \brief Creates an action that executes some computation of an host.
144 * This function creates a SURF action and allocates the data necessary
145 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
147 * \param name Name of the execution action to create
148 * \param host SIMIX host where the action will be executed
149 * \param amount Computation amount (in bytes)
150 * \return A new SIMIX execution action
152 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
153 double computation_amount)
155 smx_req_t req = SIMIX_req_mine();
157 req->call = REQ_HOST_EXECUTE;
158 req->host_execute.name = name;
159 req->host_execute.host = host;
160 req->host_execute.computation_amount = computation_amount;
161 SIMIX_request_push();
162 return req->host_execute.result;
165 /** \brief Creates an action that may involve parallel computation on
166 * several hosts and communication between them.
168 * \param name Name of the execution action to create
169 * \param host_nb Number of hosts where the action will be executed
170 * \param host_list Array (of size host_nb) of hosts where the action will be executed
171 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
172 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
173 * amount between each pair of hosts
174 * \param amount the SURF action amount
175 * \param rate the SURF action rate
176 * \return A new SIMIX execution action
178 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
180 smx_host_t *host_list,
181 double *computation_amount,
182 double *communication_amount,
186 smx_req_t req = SIMIX_req_mine();
188 req->call = REQ_HOST_PARALLEL_EXECUTE;
189 req->host_parallel_execute.name = name;
190 req->host_parallel_execute.host_nb = host_nb;
191 req->host_parallel_execute.host_list = host_list;
192 req->host_parallel_execute.computation_amount = computation_amount;
193 req->host_parallel_execute.communication_amount = communication_amount;
194 req->host_parallel_execute.amount = amount;
195 req->host_parallel_execute.rate = rate;
196 SIMIX_request_push();
197 return req->host_parallel_execute.result;
201 * \brief Destroys an execution action.
203 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
204 * \param action The execution action to destroy
206 void SIMIX_req_host_execution_destroy(smx_action_t execution)
208 smx_req_t req = SIMIX_req_mine();
210 req->call = REQ_HOST_EXECUTION_DESTROY;
211 req->host_execution_destroy.execution = execution;
212 SIMIX_request_push();
216 * \brief Cancels an execution action.
218 * This functions stops the execution. It calls a surf function.
219 * \param action The execution action to cancel
221 void SIMIX_req_host_execution_cancel(smx_action_t execution)
223 smx_req_t req = SIMIX_req_mine();
225 req->call = REQ_HOST_EXECUTION_CANCEL;
226 req->host_execution_cancel.execution = execution;
227 SIMIX_request_push();
231 * \brief Returns how much of an execution action remains to be done.
233 * \param Action The execution action
234 * \return The remaining amount
236 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
238 smx_req_t req = SIMIX_req_mine();
240 req->call = REQ_HOST_EXECUTION_GET_REMAINS;
241 req->host_execution_get_remains.execution = execution;
242 SIMIX_request_push();
243 return req->host_execution_get_remains.result;
247 * \brief Returns the state of an execution action.
249 * \param execution The execution action
252 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
254 smx_req_t req = SIMIX_req_mine();
256 req->call = REQ_HOST_EXECUTION_GET_STATE;
257 req->host_execution_get_state.execution = execution;
258 SIMIX_request_push();
259 return req->host_execution_get_state.result;
263 * \brief Changes the priority of an execution action.
265 * This functions changes the priority only. It calls a surf function.
266 * \param execution The execution action
267 * \param priority The new priority
269 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
271 smx_req_t req = SIMIX_req_mine();
273 req->call = REQ_HOST_EXECUTION_SET_PRIORITY;
274 req->host_execution_set_priority.execution = execution;
275 req->host_execution_set_priority.priority = priority;
276 SIMIX_request_push();
280 * \brief Waits for the completion of an execution action.
282 * \param execution The execution action
284 void SIMIX_req_host_execution_wait(smx_action_t execution)
286 smx_req_t req = SIMIX_req_mine();
288 req->call = REQ_HOST_EXECUTION_WAIT;
289 req->host_execution_wait.execution = execution;
290 SIMIX_request_push();
294 * \brief Creates and runs a new SIMIX process.
296 * The structure and the corresponding threada are created and put in the list of ready processes.
298 * \param name a name for the process. It is for user-level information and can be NULL.
299 * \param code the main function of the process
300 * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
301 * It can be retrieved with the function \ref SIMIX_req_process_get_data.
302 * \param hostname name of the host where the new agent is executed.
303 * \param argc first argument passed to \a code
304 * \param argv second argument passed to \a code
305 * \param properties the properties of the process
306 * \return The new process
308 smx_process_t SIMIX_req_process_create(const char *name,
309 xbt_main_func_t code,
311 const char *hostname,
312 int argc, char **argv,
313 xbt_dict_t properties)
315 smx_req_t req = SIMIX_req_mine();
317 req->call = REQ_PROCESS_CREATE;
318 req->process_create.name = name;
319 req->process_create.code = code;
320 req->process_create.data = data;
321 req->process_create.hostname = hostname;
322 req->process_create.argc = argc;
323 req->process_create.argv = argv;
324 req->process_create.properties = properties;
325 SIMIX_request_push();
326 return req->process_create.result;
329 /** \brief Kills a SIMIX process.
331 * This function simply kills a process.
333 * \param process poor victim
335 void SIMIX_req_process_kill(smx_process_t process)
337 smx_req_t req = SIMIX_req_mine();
339 req->call = REQ_PROCESS_KILL;
340 req->process_kill.process = process;
341 SIMIX_request_push();
345 * \brief Migrates an agent to another location.
347 * This function changes the value of the host on which \a process is running.
349 * \param process the process to migrate
350 * \param source name of the previous host
351 * \param dest name of the new host
353 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
355 smx_req_t req = SIMIX_req_mine();
357 req->call = REQ_PROCESS_CHANGE_HOST;
358 req->process_change_host.process = process;
359 req->process_change_host.source = source;
360 req->process_change_host.dest = dest;
361 SIMIX_request_push();
365 * \brief Suspends a process.
367 * This function suspends the process by suspending the action
368 * it was waiting for completion.
370 * \param process a SIMIX process
372 void SIMIX_req_process_suspend(smx_process_t process)
374 smx_req_t req = SIMIX_req_mine();
376 req->call = REQ_PROCESS_SUSPEND;
377 req->process_suspend.process = process;
378 SIMIX_request_push();
382 * \brief Resumes a suspended process.
384 * This function resumes a suspended process by resuming the action
385 * it was waiting for completion.
387 * \param process a SIMIX process
389 void SIMIX_req_process_resume(smx_process_t process)
391 smx_req_t req = SIMIX_req_mine();
393 req->call = REQ_PROCESS_RESUME;
394 req->process_resume.process = process;
395 SIMIX_request_push();
399 * \brief Returns the amount of SIMIX processes in the system
401 * Maestro internal process is not counted, only user code processes are
403 int SIMIX_req_process_count(void)
405 smx_req_t req = SIMIX_req_mine();
407 req->call = REQ_PROCESS_COUNT;
408 SIMIX_request_push();
409 return req->process_count.result;
413 * \brief Return the user data of a #smx_process_t.
415 * This functions checks whether \a process is a valid pointer or not and return the user data associated to \a process if it is possible.
416 * \param process SIMIX process
417 * \return A void pointer to the user data
419 void* SIMIX_req_process_get_data(smx_process_t process)
421 smx_req_t req = SIMIX_req_mine();
423 req->call = REQ_PROCESS_GET_DATA;
424 req->process_get_data.process = process;
425 SIMIX_request_push();
426 return req->process_get_data.result;
430 * \brief Set the user data of a #m_process_t.
432 * This functions checks whether \a process is a valid pointer or not and set the user data associated to \a process if it is possible.
433 * \param process SIMIX process
434 * \param data User data
436 void SIMIX_req_process_set_data(smx_process_t process, void *data)
438 smx_req_t req = SIMIX_req_mine();
440 req->call = REQ_PROCESS_SET_DATA;
441 req->process_set_data.process = process;
442 req->process_set_data.data = data;
443 SIMIX_request_push();
447 * \brief Return the location on which an agent is running.
449 * This functions checks whether \a process is a valid pointer or not and return the m_host_t corresponding to the location on which \a process is running.
450 * \param process SIMIX process
453 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
455 smx_req_t req = SIMIX_req_mine();
457 req->call = REQ_PROCESS_GET_HOST;
458 req->process_get_host.process = process;
459 SIMIX_request_push();
460 return req->process_get_host.result;
464 * \brief Return the name of an agent.
466 * This functions checks whether \a process is a valid pointer or not and return its name.
467 * \param process SIMIX process
468 * \return The process name
470 const char* SIMIX_req_process_get_name(smx_process_t process)
472 smx_req_t req = SIMIX_req_mine();
474 req->call = REQ_PROCESS_GET_NAME;
475 req->process_get_name.process = process;
476 SIMIX_request_push();
477 return req->process_get_name.result;
481 * \brief Returns true if the process is suspended .
483 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
484 * \param process SIMIX process
485 * \return 1, if the process is suspended, else 0.
487 int SIMIX_req_process_is_suspended(smx_process_t process)
489 smx_req_t req = SIMIX_req_mine();
491 req->call = REQ_PROCESS_IS_SUSPENDED;
492 req->process_is_suspended.process = process;
493 SIMIX_request_push();
494 return req->process_is_suspended.result;
497 /** \ingroup m_process_management
498 * \brief Return the properties
500 * This functions returns the properties associated with this process
502 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
504 smx_req_t req = SIMIX_req_mine();
506 req->call = REQ_PROCESS_GET_PROPERTIES;
507 req->process_get_properties.process = process;
508 SIMIX_request_push();
509 return req->process_get_properties.result;
512 /** \brief Creates a new sleep SIMIX action.
514 * This function creates a SURF action and allocates the data necessary
515 * to create the SIMIX action. It can raise a host_error exception if the
516 * host crashed. The default SIMIX name of the action is "sleep".
518 * \param duration Time duration of the sleep.
519 * \return A result telling whether the sleep was successful
521 e_smx_state_t SIMIX_req_process_sleep(double duration)
523 smx_req_t req = SIMIX_req_mine();
525 req->call = REQ_PROCESS_SLEEP;
526 req->process_sleep.duration = duration;
527 SIMIX_request_push();
528 return req->process_sleep.result;
532 * \brief Creates a new rendez-vous point
533 * \param name The name of the rendez-vous point
534 * \return The created rendez-vous point
536 smx_rdv_t SIMIX_req_rdv_create(const char *name)
538 smx_req_t req = SIMIX_req_mine();
540 req->call = REQ_RDV_CREATE;
541 req->rdv_create.name = name;
543 SIMIX_request_push();
544 return req->rdv_create.result;
549 * \brief Destroy a rendez-vous point
550 * \param name The rendez-vous point to destroy
552 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
554 smx_req_t req = SIMIX_req_mine();
556 req->call = REQ_RDV_DESTROY;
557 req->rdv_destroy.rdv = rdv;
559 SIMIX_request_push();
562 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
564 xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
565 smx_req_t req = SIMIX_req_mine();
567 req->call = REQ_RDV_GEY_BY_NAME;
568 req->rdv_get_by_name.name = name;
569 SIMIX_request_push();
570 return req->rdv_get_by_name.result;
574 * \brief counts the number of communication requests of a given host pending
575 * on a rendez-vous point
576 * \param rdv The rendez-vous point
577 * \param host The host to be counted
578 * \return The number of comm request pending in the rdv
580 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
582 smx_req_t req = SIMIX_req_mine();
584 req->call = REQ_RDV_COMM_COUNT_BY_HOST;
585 req->rdv_comm_count_by_host.rdv = rdv;
586 req->rdv_comm_count_by_host.host = host;
588 SIMIX_request_push();
589 return req->rdv_comm_count_by_host.result;
593 * \brief returns the communication at the head of the rendez-vous
594 * \param rdv The rendez-vous point
595 * \return The communication or NULL if empty
597 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
599 smx_req_t req = SIMIX_req_mine();
601 req->call = REQ_RDV_GET_HEAD;
602 req->rdv_get_head.rdv = rdv;
604 SIMIX_request_push();
605 return req->rdv_get_head.result;
608 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
609 void *src_buff, size_t src_buff_size,
610 int (*match_fun)(void *, void *), void *data)
612 smx_req_t req = SIMIX_req_mine();
614 xbt_assert0(rdv, "No rendez-vous point defined for isend");
616 req->call = REQ_COMM_ISEND;
617 req->comm_isend.rdv = rdv;
618 req->comm_isend.task_size = task_size;
619 req->comm_isend.rate = rate;
620 req->comm_isend.src_buff = src_buff;
621 req->comm_isend.src_buff_size = src_buff_size;
622 req->comm_isend.match_fun = match_fun;
623 req->comm_isend.data = data;
625 SIMIX_request_push();
626 return req->comm_isend.result;
629 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
630 int (*match_fun)(void *, void *), void *data)
632 smx_req_t req = SIMIX_req_mine();
634 xbt_assert0(rdv, "No rendez-vous point defined for isend");
636 req->call = REQ_COMM_IRECV;
637 req->comm_irecv.rdv = rdv;
638 req->comm_irecv.dst_buff = dst_buff;
639 req->comm_irecv.dst_buff_size = dst_buff_size;
640 req->comm_irecv.match_fun = match_fun;
641 req->comm_irecv.data = data;
643 SIMIX_request_push();
644 return req->comm_irecv.result;
647 void SIMIX_req_comm_destroy(smx_action_t comm)
649 smx_req_t req = SIMIX_req_mine();
651 req->call = REQ_COMM_DESTROY;
652 req->comm_destroy.comm = comm;
654 SIMIX_request_push();
657 void SIMIX_req_comm_cancel(smx_action_t comm)
659 smx_req_t req = SIMIX_req_mine();
661 req->call = REQ_COMM_CANCEL;
662 req->comm_cancel.comm = comm;
664 SIMIX_request_push();
667 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
669 smx_req_t req = SIMIX_req_mine();
671 req->call = REQ_COMM_WAITANY;
672 req->comm_waitany.comms = comms;
674 SIMIX_request_push();
675 return req->comm_waitany.result;
678 int SIMIX_req_comm_testany(xbt_dynar_t comms)
680 smx_req_t req = SIMIX_req_mine();
681 if (xbt_dynar_length(comms)==0)
684 req->call = REQ_COMM_TESTANY;
685 req->comm_testany.comms = comms;
687 SIMIX_request_push();
688 return req->comm_testany.result;
691 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
693 smx_req_t req = SIMIX_req_mine();
695 req->call = REQ_COMM_WAIT;
696 req->comm_wait.comm = comm;
697 req->comm_wait.timeout = timeout;
699 SIMIX_request_push();
704 * \brief Set the category of an action.
706 * This functions changes the category only. It calls a surf function.
707 * \param execution The execution action
708 * \param category The tracing category
710 void SIMIX_req_set_category(smx_action_t action, const char *category)
712 if (category == NULL) {
716 smx_req_t req = SIMIX_req_mine();
718 req->call = REQ_SET_CATEGORY;
719 req->set_category.action = action;
720 req->set_category.category = category;
722 SIMIX_request_push();
726 int SIMIX_req_comm_test(smx_action_t comm)
728 smx_req_t req = SIMIX_req_mine();
730 req->call = REQ_COMM_TEST;
731 req->comm_test.comm = comm;
733 SIMIX_request_push();
734 return req->comm_test.result;
737 double SIMIX_req_comm_get_remains(smx_action_t comm)
739 smx_req_t req = SIMIX_req_mine();
741 req->call = REQ_COMM_GET_REMAINS;
742 req->comm_get_remains.comm = comm;
744 SIMIX_request_push();
745 return req->comm_get_remains.result;
748 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
750 smx_req_t req = SIMIX_req_mine();
752 req->call = REQ_COMM_GET_STATE;
753 req->comm_get_state.comm = comm;
755 SIMIX_request_push();
756 return req->comm_get_state.result;
759 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
761 smx_req_t req = SIMIX_req_mine();
763 req->call = REQ_COMM_GET_SRC_DATA;
764 req->comm_get_src_data.comm = comm;
766 SIMIX_request_push();
767 return req->comm_get_src_data.result;
770 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
772 smx_req_t req = SIMIX_req_mine();
774 req->call = REQ_COMM_GET_DST_DATA;
775 req->comm_get_dst_data.comm = comm;
777 SIMIX_request_push();
778 return req->comm_get_dst_data.result;
781 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
783 smx_req_t req = SIMIX_req_mine();
785 req->call = REQ_COMM_GET_SRC_BUFF;
786 req->comm_get_src_buff.comm = comm;
788 SIMIX_request_push();
789 return req->comm_get_src_buff.result;
792 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
794 smx_req_t req = SIMIX_req_mine();
796 req->call = REQ_COMM_GET_DST_BUFF;
797 req->comm_get_dst_buff.comm = comm;
799 SIMIX_request_push();
800 return req->comm_get_dst_buff.result;
803 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
805 smx_req_t req = SIMIX_req_mine();
807 req->call = REQ_COMM_GET_SRC_BUFF_SIZE;
808 req->comm_get_src_buff_size.comm = comm;
810 SIMIX_request_push();
811 return req->comm_get_src_buff_size.result;
814 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
816 smx_req_t req = SIMIX_req_mine();
818 req->call = REQ_COMM_GET_DST_BUFF_SIZE;
819 req->comm_get_dst_buff_size.comm = comm;
821 SIMIX_request_push();
822 return req->comm_get_dst_buff_size.result;
825 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
827 smx_req_t req = SIMIX_req_mine();
829 req->call = REQ_COMM_GET_SRC_PROC;
830 req->comm_get_src_proc.comm = comm;
832 SIMIX_request_push();
833 return req->comm_get_src_proc.result;
836 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
838 smx_req_t req = SIMIX_req_mine();
840 req->call = REQ_COMM_GET_DST_PROC;
841 req->comm_get_dst_proc.comm = comm;
843 SIMIX_request_push();
844 return req->comm_get_dst_proc.result;
847 #ifdef HAVE_LATENCY_BOUND_TRACKING
848 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
850 smx_req_t req = SIMIX_req_mine();
852 req->call = REQ_COMM_IS_LATENCY_BOUNDED;
853 req->comm_is_latency_bounded.comm = comm;
855 SIMIX_request_push();
856 return req->comm_is_latency_bounded.result;
860 smx_mutex_t SIMIX_req_mutex_init(void)
862 smx_req_t req = SIMIX_req_mine();
864 req->call = REQ_MUTEX_INIT;
866 SIMIX_request_push();
867 return req->mutex_init.result;
870 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
872 smx_req_t req = SIMIX_req_mine();
874 req->call = REQ_MUTEX_DESTROY;
875 req->mutex_destroy.mutex = mutex;
877 SIMIX_request_push();
880 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
882 smx_req_t req = SIMIX_req_mine();
884 req->call = REQ_MUTEX_LOCK;
885 req->mutex_lock.mutex = mutex;
887 SIMIX_request_push();
890 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
892 smx_req_t req = SIMIX_req_mine();
894 req->call = REQ_MUTEX_TRYLOCK;
895 req->mutex_trylock.mutex = mutex;
897 SIMIX_request_push();
898 return req->mutex_trylock.result;
901 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
903 smx_req_t req = SIMIX_req_mine();
905 req->call = REQ_MUTEX_UNLOCK;
906 req->mutex_unlock.mutex = mutex;
908 SIMIX_request_push();
912 smx_cond_t SIMIX_req_cond_init(void)
914 smx_req_t req = SIMIX_req_mine();
916 req->call = REQ_COND_INIT;
918 SIMIX_request_push();
919 return req->cond_init.result;
922 void SIMIX_req_cond_destroy(smx_cond_t cond)
924 smx_req_t req = SIMIX_req_mine();
926 req->call = REQ_COND_DESTROY;
927 req->cond_destroy.cond = cond;
929 SIMIX_request_push();
932 void SIMIX_req_cond_signal(smx_cond_t cond)
934 smx_req_t req = SIMIX_req_mine();
936 req->call = REQ_COND_SIGNAL;
937 req->cond_signal.cond = cond;
939 SIMIX_request_push();
942 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
944 smx_req_t req = SIMIX_req_mine();
946 req->call = REQ_COND_WAIT;
947 req->cond_wait.cond = cond;
948 req->cond_wait.mutex = mutex;
950 SIMIX_request_push();
953 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
957 smx_req_t req = SIMIX_req_mine();
959 req->call = REQ_COND_WAIT_TIMEOUT;
960 req->cond_wait_timeout.cond = cond;
961 req->cond_wait_timeout.mutex = mutex;
962 req->cond_wait_timeout.timeout = timeout;
964 SIMIX_request_push();
967 void SIMIX_req_cond_broadcast(smx_cond_t cond)
969 smx_req_t req = SIMIX_req_mine();
971 req->call = REQ_COND_BROADCAST;
972 req->cond_broadcast.cond = cond;
974 SIMIX_request_push();
978 smx_sem_t SIMIX_req_sem_init(int capacity)
980 smx_req_t req = SIMIX_req_mine();
982 req->call = REQ_SEM_INIT;
983 req->sem_init.capacity = capacity;
985 SIMIX_request_push();
986 return req->sem_init.result;
989 void SIMIX_req_sem_destroy(smx_sem_t sem)
991 smx_req_t req = SIMIX_req_mine();
993 req->call = REQ_SEM_DESTROY;
994 req->sem_destroy.sem = sem;
996 SIMIX_request_push();
999 void SIMIX_req_sem_release(smx_sem_t sem)
1001 smx_req_t req = SIMIX_req_mine();
1003 req->call = REQ_SEM_RELEASE;
1004 req->sem_release.sem = sem;
1006 SIMIX_request_push();
1009 int SIMIX_req_sem_would_block(smx_sem_t sem)
1011 smx_req_t req = SIMIX_req_mine();
1013 req->call = REQ_SEM_WOULD_BLOCK;
1014 req->sem_would_block.sem = sem;
1016 SIMIX_request_push();
1017 return req->sem_would_block.result;
1020 void SIMIX_req_sem_acquire(smx_sem_t sem)
1022 smx_req_t req = SIMIX_req_mine();
1024 req->call = REQ_SEM_ACQUIRE;
1025 req->sem_acquire.sem = sem;
1027 SIMIX_request_push();
1030 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1032 smx_req_t req = SIMIX_req_mine();
1034 req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1035 req->sem_acquire_timeout.sem = sem;
1036 req->sem_acquire_timeout.timeout = timeout;
1038 SIMIX_request_push();
1041 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1043 smx_req_t req = SIMIX_req_mine();
1045 req->call = REQ_SEM_GET_CAPACITY;
1046 req->sem_get_capacity.sem = sem;
1048 SIMIX_request_push();
1049 return req->sem_get_capacity.result;
1051 /* ************************************************************************** */
1053 /** @brief returns a printable string representing the request kind */
1054 const char *SIMIX_request_name(int kind) {
1055 return request_names[kind];