3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
5 * \brief Returns a host given its name.
7 * \param name The name of the host to get
8 * \return The corresponding host
10 smx_host_t SIMIX_req_host_get_by_name(const char *name)
12 smx_req_t req = SIMIX_req_mine();
14 req->call = REQ_HOST_GET_BY_NAME;
15 req->host_get_by_name.name = name;
17 return req->host_get_by_name.result;
21 * \brief Returns the name of a host.
23 * \param host A SIMIX host
24 * \return The name of this host
26 const char* SIMIX_req_host_get_name(smx_host_t host)
28 smx_req_t req = SIMIX_req_mine();
30 req->call = REQ_HOST_GET_NAME;
31 req->host_get_name.host = host;
33 return req->host_get_name.result;
37 * \brief Returns a dict of the properties assigned to a host.
40 * \return The properties of this host
42 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
44 smx_req_t req = SIMIX_req_mine();
46 req->call = REQ_HOST_GET_PROPERTIES;
47 req->host_get_properties.host = host;
49 return req->host_get_properties.result;
53 * \brief Returns the speed of the processor.
55 * The speed returned does not take into account the current load on the machine.
56 * \param host A SIMIX host
57 * \return The speed of this host (in Mflop/s)
59 double SIMIX_req_host_get_speed(smx_host_t host)
61 smx_req_t req = SIMIX_req_mine();
63 req->call = REQ_HOST_GET_SPEED;
64 req->host_get_speed.host = host;
66 return req->host_get_speed.result;
70 * \brief Returns the available speed of the processor.
72 * \return Speed currently available (in Mflop/s)
74 double SIMIX_req_host_get_available_speed(smx_host_t host)
76 smx_req_t req = SIMIX_req_mine();
78 req->call = REQ_HOST_GET_AVAILABLE_SPEED;
79 req->host_get_available_speed.host = host;
81 return req->host_get_available_speed.result;
85 * \brief Returns the state of a host.
87 * Two states are possible: 1 if the host is active or 0 if it has crashed.
88 * \param host A SIMIX host
89 * \return 1 if the host is available, 0 otherwise
91 int SIMIX_req_host_get_state(smx_host_t host)
93 smx_req_t req = SIMIX_req_mine();
95 req->call = REQ_HOST_GET_STATE;
96 req->host_get_state.host = host;
98 return req->host_get_state.result;
102 * \brief Returns the user data associated to a host.
104 * \param host SIMIX host
105 * \return the user data of this host
107 void* SIMIX_req_host_get_data(smx_host_t host)
109 smx_req_t req = SIMIX_req_mine();
111 req->call = REQ_HOST_GET_DATA;
112 req->host_get_data.host = host;
113 SIMIX_request_push();
114 return req->host_get_data.result;
118 * \brief Sets the user data associated to a host.
120 * The host must not have previous user data associated to it.
121 * \param A host SIMIX host
122 * \param data The user data to set
124 void SIMIX_req_host_set_data(smx_host_t host, void *data)
126 smx_req_t req = SIMIX_req_mine();
128 req->call = REQ_HOST_SET_DATA;
129 req->host_set_data.host = host;
130 req->host_set_data.data = data;
131 SIMIX_request_push();
134 /** \brief Creates an action that executes some computation of an host.
136 * This function creates a SURF action and allocates the data necessary
137 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
139 * \param name Name of the execution action to create
140 * \param host SIMIX host where the action will be executed
141 * \param amount Computation amount (in bytes)
142 * \return A new SIMIX execution action
144 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
145 double computation_amount)
147 smx_req_t req = SIMIX_req_mine();
149 req->call = REQ_HOST_EXECUTE;
150 req->host_execute.name = name;
151 req->host_execute.host = host;
152 req->host_execute.computation_amount = computation_amount;
153 SIMIX_request_push();
154 return req->host_execute.result;
157 /** \brief Creates an action that may involve parallel computation on
158 * several hosts and communication between them.
160 * \param name Name of the execution action to create
161 * \param host_nb Number of hosts where the action will be executed
162 * \param host_list Array (of size host_nb) of hosts where the action will be executed
163 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
164 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
165 * amount between each pair of hosts
166 * \param amount the SURF action amount
167 * \param rate the SURF action rate
168 * \return A new SIMIX execution action
170 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
172 smx_host_t *host_list,
173 double *computation_amount,
174 double *communication_amount,
178 smx_req_t req = SIMIX_req_mine();
180 req->call = REQ_HOST_PARALLEL_EXECUTE;
181 req->host_parallel_execute.name = name;
182 req->host_parallel_execute.host_nb = host_nb;
183 req->host_parallel_execute.host_list = host_list;
184 req->host_parallel_execute.computation_amount = computation_amount;
185 req->host_parallel_execute.communication_amount = communication_amount;
186 req->host_parallel_execute.amount = amount;
187 req->host_parallel_execute.rate = rate;
188 SIMIX_request_push();
189 return req->host_parallel_execute.result;
193 * \brief Destroys an execution action.
195 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
196 * \param action The execution action to destroy
198 void SIMIX_req_host_execution_destroy(smx_action_t execution)
200 smx_req_t req = SIMIX_req_mine();
202 req->call = REQ_HOST_EXECUTION_DESTROY;
203 req->host_execution_destroy.execution = execution;
204 SIMIX_request_push();
208 * \brief Cancels an execution action.
210 * This functions stops the execution. It calls a surf function.
211 * \param action The execution action to cancel
213 void SIMIX_req_host_execution_cancel(smx_action_t execution)
215 smx_req_t req = SIMIX_req_mine();
217 req->call = REQ_HOST_EXECUTION_CANCEL;
218 req->host_execution_cancel.execution = execution;
219 SIMIX_request_push();
223 * \brief Returns how much of an execution action remains to be done.
225 * \param Action The execution action
226 * \return The remaining amount
228 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
230 smx_req_t req = SIMIX_req_mine();
232 req->call = REQ_HOST_EXECUTION_GET_REMAINS;
233 req->host_execution_get_remains.execution = execution;
234 SIMIX_request_push();
235 return req->host_execution_get_remains.result;
239 * \brief Returns the state of an execution action.
241 * \param execution The execution action
244 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
246 smx_req_t req = SIMIX_req_mine();
248 req->call = REQ_HOST_EXECUTION_GET_STATE;
249 req->host_execution_get_state.execution = execution;
250 SIMIX_request_push();
251 return req->host_execution_get_state.result;
255 * \brief Changes the priority of an execution action.
257 * This functions changes the priority only. It calls a surf function.
258 * \param execution The execution action
259 * \param priority The new priority
261 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
263 smx_req_t req = SIMIX_req_mine();
265 req->call = REQ_HOST_EXECUTION_SET_PRIORITY;
266 req->host_execution_set_priority.execution = execution;
267 req->host_execution_set_priority.priority = priority;
268 SIMIX_request_push();
272 * \brief Waits for the completion of an execution action.
274 * \param execution The execution action
276 void SIMIX_req_host_execution_wait(smx_action_t execution)
278 smx_req_t req = SIMIX_req_mine();
280 req->call = REQ_HOST_EXECUTION_WAIT;
281 req->host_execution_wait.execution = execution;
282 SIMIX_request_push();
286 * \brief Creates and runs a new SIMIX process.
288 * The structure and the corresponding threada are created and put in the list of ready processes.
290 * \param name a name for the process. It is for user-level information and can be NULL.
291 * \param code the main function of the process
292 * \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.
293 * It can be retrieved with the function \ref SIMIX_req_process_get_data.
294 * \param hostname name of the host where the new agent is executed.
295 * \param argc first argument passed to \a code
296 * \param argv second argument passed to \a code
297 * \param properties the properties of the process
298 * \return The new process
300 smx_process_t SIMIX_req_process_create(const char *name,
301 xbt_main_func_t code,
303 const char *hostname,
304 int argc, char **argv,
305 xbt_dict_t properties)
307 smx_req_t req = SIMIX_req_mine();
309 req->call = REQ_PROCESS_CREATE;
310 req->process_create.name = name;
311 req->process_create.code = code;
312 req->process_create.data = data;
313 req->process_create.hostname = hostname;
314 req->process_create.argc = argc;
315 req->process_create.argv = argv;
316 req->process_create.properties = properties;
317 SIMIX_request_push();
318 return req->process_create.result;
321 /** \brief Kills a SIMIX process.
323 * This function simply kills a process.
325 * \param process poor victim
327 void SIMIX_req_process_kill(smx_process_t process)
329 smx_req_t req = SIMIX_req_mine();
331 req->call = REQ_PROCESS_KILL;
332 req->process_kill.process = process;
333 SIMIX_request_push();
337 * \brief Migrates an agent to another location.
339 * This function changes the value of the host on which \a process is running.
341 * \param process the process to migrate
342 * \param source name of the previous host
343 * \param dest name of the new host
345 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
347 smx_req_t req = SIMIX_req_mine();
349 req->call = REQ_PROCESS_CHANGE_HOST;
350 req->process_change_host.process = process;
351 req->process_change_host.source = source;
352 req->process_change_host.dest = dest;
353 SIMIX_request_push();
357 * \brief Suspends a process.
359 * This function suspends the process by suspending the action
360 * it was waiting for completion.
362 * \param process a SIMIX process
364 void SIMIX_req_process_suspend(smx_process_t process)
366 smx_req_t req = SIMIX_req_mine();
368 req->call = REQ_PROCESS_SUSPEND;
369 req->process_suspend.process = process;
370 SIMIX_request_push();
374 * \brief Resumes a suspended process.
376 * This function resumes a suspended process by resuming the action
377 * it was waiting for completion.
379 * \param process a SIMIX process
381 void SIMIX_req_process_resume(smx_process_t process)
383 smx_req_t req = SIMIX_req_mine();
385 req->call = REQ_PROCESS_RESUME;
386 req->process_resume.process = process;
387 SIMIX_request_push();
391 * \brief Returns the amount of SIMIX processes in the system
393 * Maestro internal process is not counted, only user code processes are
395 int SIMIX_req_process_count(void)
397 smx_req_t req = SIMIX_req_mine();
399 req->call = REQ_PROCESS_COUNT;
400 SIMIX_request_push();
401 return req->process_count.result;
405 * \brief Return the user data of a #smx_process_t.
407 * 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.
408 * \param process SIMIX process
409 * \return A void pointer to the user data
411 void* SIMIX_req_process_get_data(smx_process_t process)
413 smx_req_t req = SIMIX_req_mine();
415 req->call = REQ_PROCESS_GET_DATA;
416 req->process_get_data.process = process;
417 SIMIX_request_push();
418 return req->process_get_data.result;
422 * \brief Set the user data of a #m_process_t.
424 * 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.
425 * \param process SIMIX process
426 * \param data User data
428 void SIMIX_req_process_set_data(smx_process_t process, void *data)
430 smx_req_t req = SIMIX_req_mine();
432 req->call = REQ_PROCESS_SET_DATA;
433 req->process_set_data.process = process;
434 req->process_set_data.data = data;
435 SIMIX_request_push();
439 * \brief Return the location on which an agent is running.
441 * 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.
442 * \param process SIMIX process
445 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
447 smx_req_t req = SIMIX_req_mine();
449 req->call = REQ_PROCESS_GET_HOST;
450 req->process_get_host.process = process;
451 SIMIX_request_push();
452 return req->process_get_host.result;
456 * \brief Return the name of an agent.
458 * This functions checks whether \a process is a valid pointer or not and return its name.
459 * \param process SIMIX process
460 * \return The process name
462 const char* SIMIX_req_process_get_name(smx_process_t process)
464 smx_req_t req = SIMIX_req_mine();
466 req->call = REQ_PROCESS_GET_NAME;
467 req->process_get_name.process = process;
468 SIMIX_request_push();
469 return req->process_get_name.result;
473 * \brief Returns true if the process is suspended .
475 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
476 * \param process SIMIX process
477 * \return 1, if the process is suspended, else 0.
479 int SIMIX_req_process_is_suspended(smx_process_t process)
481 smx_req_t req = SIMIX_req_mine();
483 req->call = REQ_PROCESS_IS_SUSPENDED;
484 req->process_is_suspended.process = process;
485 SIMIX_request_push();
486 return req->process_is_suspended.result;
489 /** \ingroup m_process_management
490 * \brief Return the properties
492 * This functions returns the properties associated with this process
494 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
496 smx_req_t req = SIMIX_req_mine();
498 req->call = REQ_PROCESS_GET_PROPERTIES;
499 req->process_get_properties.process = process;
500 SIMIX_request_push();
501 return req->process_get_properties.result;
504 /** \brief Creates a new sleep SIMIX action.
506 * This function creates a SURF action and allocates the data necessary
507 * to create the SIMIX action. It can raise a host_error exception if the
508 * host crashed. The default SIMIX name of the action is "sleep".
510 * \param duration Time duration of the sleep.
511 * \return A result telling whether the sleep was successful
513 e_smx_state_t SIMIX_req_process_sleep(double duration)
515 smx_req_t req = SIMIX_req_mine();
517 req->call = REQ_PROCESS_SLEEP;
518 req->process_sleep.duration = duration;
519 SIMIX_request_push();
520 return req->process_sleep.result;
524 * \brief Creates a new rendez-vous point
525 * \param name The name of the rendez-vous point
526 * \return The created rendez-vous point
528 smx_rdv_t SIMIX_req_rdv_create(const char *name)
530 smx_req_t req = SIMIX_req_mine();
532 req->call = REQ_RDV_CREATE;
533 req->rdv_create.name = name;
535 SIMIX_request_push();
536 return req->rdv_create.result;
541 * \brief Destroy a rendez-vous point
542 * \param name The rendez-vous point to destroy
544 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
546 smx_req_t req = SIMIX_req_mine();
548 req->call = REQ_RDV_DESTROY;
549 req->rdv_destroy.rdv = rdv;
551 SIMIX_request_push();
554 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
556 xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
557 smx_req_t req = SIMIX_req_mine();
559 req->call = REQ_RDV_GEY_BY_NAME;
560 req->rdv_get_by_name.name = name;
561 SIMIX_request_push();
562 return req->rdv_get_by_name.result;
566 * \brief counts the number of communication requests of a given host pending
567 * on a rendez-vous point
568 * \param rdv The rendez-vous point
569 * \param host The host to be counted
570 * \return The number of comm request pending in the rdv
572 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
574 smx_req_t req = SIMIX_req_mine();
576 req->call = REQ_RDV_COMM_COUNT_BY_HOST;
577 req->rdv_comm_count_by_host.rdv = rdv;
578 req->rdv_comm_count_by_host.host = host;
580 SIMIX_request_push();
581 return req->rdv_comm_count_by_host.result;
585 * \brief returns the communication at the head of the rendez-vous
586 * \param rdv The rendez-vous point
587 * \return The communication or NULL if empty
589 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
591 smx_req_t req = SIMIX_req_mine();
593 req->call = REQ_RDV_GET_HEAD;
594 req->rdv_get_head.rdv = rdv;
596 SIMIX_request_push();
597 return req->rdv_get_head.result;
600 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
601 void *src_buff, size_t src_buff_size,
602 int (*match_fun)(void *, void *), void *data)
604 smx_req_t req = SIMIX_req_mine();
606 xbt_assert0(rdv, "No rendez-vous point defined for isend");
608 req->call = REQ_COMM_ISEND;
609 req->comm_isend.rdv = rdv;
610 req->comm_isend.task_size = task_size;
611 req->comm_isend.rate = rate;
612 req->comm_isend.src_buff = src_buff;
613 req->comm_isend.src_buff_size = src_buff_size;
614 req->comm_isend.match_fun = match_fun;
615 req->comm_isend.data = data;
617 SIMIX_request_push();
618 return req->comm_isend.result;
621 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
622 int (*match_fun)(void *, void *), void *data)
624 smx_req_t req = SIMIX_req_mine();
626 xbt_assert0(rdv, "No rendez-vous point defined for isend");
628 req->call = REQ_COMM_IRECV;
629 req->comm_irecv.rdv = rdv;
630 req->comm_irecv.dst_buff = dst_buff;
631 req->comm_irecv.dst_buff_size = dst_buff_size;
632 req->comm_irecv.match_fun = match_fun;
633 req->comm_irecv.data = data;
635 SIMIX_request_push();
636 return req->comm_irecv.result;
639 void SIMIX_req_comm_destroy(smx_action_t comm)
641 smx_req_t req = SIMIX_req_mine();
643 req->call = REQ_COMM_DESTROY;
644 req->comm_destroy.comm = comm;
646 SIMIX_request_push();
649 void SIMIX_req_comm_cancel(smx_action_t comm)
651 smx_req_t req = SIMIX_req_mine();
653 req->call = REQ_COMM_CANCEL;
654 req->comm_cancel.comm = comm;
656 SIMIX_request_push();
659 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
661 smx_req_t req = SIMIX_req_mine();
663 req->call = REQ_COMM_WAITANY;
664 req->comm_waitany.comms = comms;
666 SIMIX_request_push();
667 return req->comm_waitany.result;
670 int SIMIX_req_comm_testany(xbt_dynar_t comms)
672 smx_req_t req = SIMIX_req_mine();
673 if (xbt_dynar_length(comms)==0)
676 req->call = REQ_COMM_TESTANY;
677 req->comm_testany.comms = comms;
679 SIMIX_request_push();
680 return req->comm_testany.result;
683 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
685 smx_req_t req = SIMIX_req_mine();
687 req->call = REQ_COMM_WAIT;
688 req->comm_wait.comm = comm;
689 req->comm_wait.timeout = timeout;
691 SIMIX_request_push();
696 * \brief Set the category of an action.
698 * This functions changes the category only. It calls a surf function.
699 * \param execution The execution action
700 * \param category The tracing category
702 void SIMIX_req_set_category(smx_action_t action, const char *category)
704 if (category == NULL) {
708 smx_req_t req = SIMIX_req_mine();
710 req->call = REQ_SET_CATEGORY;
711 req->set_category.action = action;
712 req->set_category.category = category;
714 SIMIX_request_push();
718 int SIMIX_req_comm_test(smx_action_t comm)
720 smx_req_t req = SIMIX_req_mine();
722 req->call = REQ_COMM_TEST;
723 req->comm_test.comm = comm;
725 SIMIX_request_push();
726 return req->comm_test.result;
729 double SIMIX_req_comm_get_remains(smx_action_t comm)
731 smx_req_t req = SIMIX_req_mine();
733 req->call = REQ_COMM_GET_REMAINS;
734 req->comm_get_remains.comm = comm;
736 SIMIX_request_push();
737 return req->comm_get_remains.result;
740 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
742 smx_req_t req = SIMIX_req_mine();
744 req->call = REQ_COMM_GET_STATE;
745 req->comm_get_state.comm = comm;
747 SIMIX_request_push();
748 return req->comm_get_state.result;
751 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
753 smx_req_t req = SIMIX_req_mine();
755 req->call = REQ_COMM_GET_SRC_DATA;
756 req->comm_get_src_data.comm = comm;
758 SIMIX_request_push();
759 return req->comm_get_src_data.result;
762 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
764 smx_req_t req = SIMIX_req_mine();
766 req->call = REQ_COMM_GET_DST_DATA;
767 req->comm_get_dst_data.comm = comm;
769 SIMIX_request_push();
770 return req->comm_get_dst_data.result;
773 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
775 smx_req_t req = SIMIX_req_mine();
777 req->call = REQ_COMM_GET_SRC_BUFF;
778 req->comm_get_src_buff.comm = comm;
780 SIMIX_request_push();
781 return req->comm_get_src_buff.result;
784 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
786 smx_req_t req = SIMIX_req_mine();
788 req->call = REQ_COMM_GET_DST_BUFF;
789 req->comm_get_dst_buff.comm = comm;
791 SIMIX_request_push();
792 return req->comm_get_dst_buff.result;
795 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
797 smx_req_t req = SIMIX_req_mine();
799 req->call = REQ_COMM_GET_SRC_BUFF_SIZE;
800 req->comm_get_src_buff_size.comm = comm;
802 SIMIX_request_push();
803 return req->comm_get_src_buff_size.result;
806 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
808 smx_req_t req = SIMIX_req_mine();
810 req->call = REQ_COMM_GET_DST_BUFF_SIZE;
811 req->comm_get_dst_buff_size.comm = comm;
813 SIMIX_request_push();
814 return req->comm_get_dst_buff_size.result;
817 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
819 smx_req_t req = SIMIX_req_mine();
821 req->call = REQ_COMM_GET_SRC_PROC;
822 req->comm_get_src_proc.comm = comm;
824 SIMIX_request_push();
825 return req->comm_get_src_proc.result;
828 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
830 smx_req_t req = SIMIX_req_mine();
832 req->call = REQ_COMM_GET_DST_PROC;
833 req->comm_get_dst_proc.comm = comm;
835 SIMIX_request_push();
836 return req->comm_get_dst_proc.result;
839 #ifdef HAVE_LATENCY_BOUND_TRACKING
840 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
842 smx_req_t req = SIMIX_req_mine();
844 req->call = REQ_COMM_IS_LATENCY_BOUNDED;
845 req->comm_is_latency_bounded.comm = comm;
847 SIMIX_request_push();
848 return req->comm_is_latency_bounded.result;
852 smx_mutex_t SIMIX_req_mutex_init(void)
854 smx_req_t req = SIMIX_req_mine();
856 req->call = REQ_MUTEX_INIT;
858 SIMIX_request_push();
859 return req->mutex_init.result;
862 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
864 smx_req_t req = SIMIX_req_mine();
866 req->call = REQ_MUTEX_DESTROY;
867 req->mutex_destroy.mutex = mutex;
869 SIMIX_request_push();
872 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
874 smx_req_t req = SIMIX_req_mine();
876 req->call = REQ_MUTEX_LOCK;
877 req->mutex_lock.mutex = mutex;
879 SIMIX_request_push();
882 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
884 smx_req_t req = SIMIX_req_mine();
886 req->call = REQ_MUTEX_TRYLOCK;
887 req->mutex_trylock.mutex = mutex;
889 SIMIX_request_push();
890 return req->mutex_trylock.result;
893 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
895 smx_req_t req = SIMIX_req_mine();
897 req->call = REQ_MUTEX_UNLOCK;
898 req->mutex_unlock.mutex = mutex;
900 SIMIX_request_push();
904 smx_cond_t SIMIX_req_cond_init(void)
906 smx_req_t req = SIMIX_req_mine();
908 req->call = REQ_COND_INIT;
910 SIMIX_request_push();
911 return req->cond_init.result;
914 void SIMIX_req_cond_destroy(smx_cond_t cond)
916 smx_req_t req = SIMIX_req_mine();
918 req->call = REQ_COND_DESTROY;
919 req->cond_destroy.cond = cond;
921 SIMIX_request_push();
924 void SIMIX_req_cond_signal(smx_cond_t cond)
926 smx_req_t req = SIMIX_req_mine();
928 req->call = REQ_COND_SIGNAL;
929 req->cond_signal.cond = cond;
931 SIMIX_request_push();
934 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
936 smx_req_t req = SIMIX_req_mine();
938 req->call = REQ_COND_WAIT;
939 req->cond_wait.cond = cond;
940 req->cond_wait.mutex = mutex;
942 SIMIX_request_push();
945 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
949 smx_req_t req = SIMIX_req_mine();
951 req->call = REQ_COND_WAIT_TIMEOUT;
952 req->cond_wait_timeout.cond = cond;
953 req->cond_wait_timeout.mutex = mutex;
954 req->cond_wait_timeout.timeout = timeout;
956 SIMIX_request_push();
959 void SIMIX_req_cond_broadcast(smx_cond_t cond)
961 smx_req_t req = SIMIX_req_mine();
963 req->call = REQ_COND_BROADCAST;
964 req->cond_broadcast.cond = cond;
966 SIMIX_request_push();
970 smx_sem_t SIMIX_req_sem_init(int capacity)
972 smx_req_t req = SIMIX_req_mine();
974 req->call = REQ_SEM_INIT;
975 req->sem_init.capacity = capacity;
977 SIMIX_request_push();
978 return req->sem_init.result;
981 void SIMIX_req_sem_destroy(smx_sem_t sem)
983 smx_req_t req = SIMIX_req_mine();
985 req->call = REQ_SEM_DESTROY;
986 req->sem_destroy.sem = sem;
988 SIMIX_request_push();
991 void SIMIX_req_sem_release(smx_sem_t sem)
993 smx_req_t req = SIMIX_req_mine();
995 req->call = REQ_SEM_RELEASE;
996 req->sem_release.sem = sem;
998 SIMIX_request_push();
1001 int SIMIX_req_sem_would_block(smx_sem_t sem)
1003 smx_req_t req = SIMIX_req_mine();
1005 req->call = REQ_SEM_WOULD_BLOCK;
1006 req->sem_would_block.sem = sem;
1008 SIMIX_request_push();
1009 return req->sem_would_block.result;
1012 void SIMIX_req_sem_acquire(smx_sem_t sem)
1014 smx_req_t req = SIMIX_req_mine();
1016 req->call = REQ_SEM_ACQUIRE;
1017 req->sem_acquire.sem = sem;
1019 SIMIX_request_push();
1022 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1024 smx_req_t req = SIMIX_req_mine();
1026 req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1027 req->sem_acquire_timeout.sem = sem;
1028 req->sem_acquire_timeout.timeout = timeout;
1030 SIMIX_request_push();
1033 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1035 smx_req_t req = SIMIX_req_mine();
1037 req->call = REQ_SEM_GET_CAPACITY;
1038 req->sem_get_capacity.sem = sem;
1040 SIMIX_request_push();
1041 return req->sem_get_capacity.result;
1043 /* ************************************************************************** */
1045 /** @brief returns a printable string representing the request kind */
1046 const char *SIMIX_request_name(int kind) {
1047 switch ((e_smx_req_t) kind) {
1048 case REQ_NO_REQ: return "REQ_NO_REQ";
1049 case REQ_HOST_GET_BY_NAME: return "REQ_HOST_GET_BY_NAME";
1050 case REQ_HOST_GET_NAME: return "REQ_HOST_GET_NAME";
1051 case REQ_HOST_GET_PROPERTIES: return "REQ_HOST_GET_PROPERTIES";
1052 case REQ_HOST_GET_SPEED: return "REQ_HOST_GET_SPEED";
1053 case REQ_HOST_GET_AVAILABLE_SPEED: return "REQ_HOST_GET_AVAILABLE_SPEED";
1054 case REQ_HOST_GET_STATE: return "REQ_HOST_GET_STATE";
1055 case REQ_HOST_GET_DATA: return "REQ_HOST_GET_DATA";
1056 case REQ_HOST_SET_DATA: return "REQ_HOST_SET_DATA";
1057 case REQ_HOST_EXECUTE: return "REQ_HOST_EXECUTE";
1058 case REQ_HOST_PARALLEL_EXECUTE: return "REQ_HOST_PARALLEL_EXECUTE";
1059 case REQ_HOST_EXECUTION_DESTROY: return "REQ_HOST_EXECUTION_DESTROY";
1060 case REQ_HOST_EXECUTION_CANCEL: return "REQ_HOST_EXECUTION_CANCEL";
1061 case REQ_HOST_EXECUTION_GET_REMAINS: return "REQ_HOST_EXECUTION_GET_REMAINS";
1062 case REQ_HOST_EXECUTION_GET_STATE: return "REQ_HOST_EXECUTION_GET_STATE";
1063 case REQ_HOST_EXECUTION_SET_PRIORITY: return "REQ_HOST_EXECUTION_SET_PRIORITY";
1064 case REQ_HOST_EXECUTION_WAIT: return "REQ_HOST_EXECUTION_WAIT";
1065 case REQ_PROCESS_CREATE: return "REQ_PROCESS_CREATE";
1066 case REQ_PROCESS_KILL: return "REQ_PROCESS_KILL";
1067 case REQ_PROCESS_CHANGE_HOST: return "REQ_PROCESS_CHANGE_HOST";
1068 case REQ_PROCESS_SUSPEND: return "REQ_PROCESS_SUSPEND";
1069 case REQ_PROCESS_RESUME: return "REQ_PROCESS_RESUME";
1070 case REQ_PROCESS_COUNT: return "REQ_PROCESS_COUNT";
1071 case REQ_PROCESS_GET_DATA: return "REQ_PROCESS_GET_DATA";
1072 case REQ_PROCESS_SET_DATA: return "REQ_PROCESS_SET_DATA";
1073 case REQ_PROCESS_GET_HOST: return "REQ_PROCESS_GET_HOST";
1074 case REQ_PROCESS_GET_NAME: return "REQ_PROCESS_GET_NAME";
1075 case REQ_PROCESS_IS_SUSPENDED: return "REQ_PROCESS_IS_SUSPENDED";
1076 case REQ_PROCESS_GET_PROPERTIES: return "REQ_PROCESS_GET_PROPERTIES";
1077 case REQ_PROCESS_SLEEP: return "REQ_PROCESS_SLEEP";
1078 case REQ_RDV_CREATE: return "REQ_RDV_CREATE";
1079 case REQ_RDV_DESTROY: return "REQ_RDV_DESTROY";
1080 case REQ_RDV_GEY_BY_NAME: return "REQ_RDV_GEY_BY_NAME";
1081 case REQ_RDV_COMM_COUNT_BY_HOST: return "REQ_RDV_COMM_COUNT_BY_HOST";
1082 case REQ_RDV_GET_HEAD: return "REQ_RDV_GET_HEAD";
1083 case REQ_COMM_ISEND: return "REQ_COMM_ISEND";
1084 case REQ_COMM_IRECV: return "REQ_COMM_IRECV";
1085 case REQ_COMM_DESTROY: return "REQ_COMM_DESTROY";
1086 case REQ_COMM_CANCEL: return "REQ_COMM_CANCEL";
1087 case REQ_COMM_WAITANY: return "REQ_COMM_WAITANY";
1088 case REQ_COMM_TESTANY: return "REQ_COMM_TESTANY";
1089 case REQ_COMM_WAIT: return "REQ_COMM_WAIT";
1092 case REQ_SET_CATEGORY: return "REQ_SET_CATEGORY";
1095 case REQ_COMM_TEST: return "REQ_COMM_TEST";
1096 case REQ_COMM_GET_REMAINS: return "REQ_COMM_GET_REMAINS";
1097 case REQ_COMM_GET_STATE: return "REQ_COMM_GET_STATE";
1098 case REQ_COMM_GET_SRC_DATA: return "REQ_COMM_GET_SRC_DATA";
1099 case REQ_COMM_GET_DST_DATA: return "REQ_COMM_GET_DST_DATA";
1100 case REQ_COMM_GET_SRC_BUFF: return "REQ_COMM_GET_SRC_BUFF";
1101 case REQ_COMM_GET_DST_BUFF: return "REQ_COMM_GET_DST_BUFF";
1102 case REQ_COMM_GET_SRC_BUFF_SIZE: return "REQ_COMM_GET_SRC_BUFF_SIZE";
1103 case REQ_COMM_GET_DST_BUFF_SIZE: return "REQ_COMM_GET_DST_BUFF_SIZE";
1104 case REQ_COMM_GET_SRC_PROC: return "REQ_COMM_GET_SRC_PROC";
1105 case REQ_COMM_GET_DST_PROC: return "REQ_COMM_GET_DST_PROC";
1107 #ifdef HAVE_LATENCY_BOUND_TRACKING
1108 case REQ_COMM_IS_LATENCY_BOUNDED: return "REQ_COMM_IS_LATENCY_BOUNDED";
1111 case REQ_MUTEX_INIT: return "REQ_MUTEX_INIT";
1112 case REQ_MUTEX_DESTROY: return "REQ_MUTEX_DESTROY";
1113 case REQ_MUTEX_LOCK: return "REQ_MUTEX_LOCK";
1114 case REQ_MUTEX_UNLOCK: return "REQ_MUTEX_UNLOCK";
1115 case REQ_MUTEX_TRYLOCK: return "REQ_MUTEX_TRYLOCK";
1117 case REQ_COND_INIT: return "REQ_COND_INIT";
1118 case REQ_COND_DESTROY: return "REQ_COND_DESTROY";
1119 case REQ_COND_SIGNAL: return "REQ_COND_SIGNAL";
1120 case REQ_COND_WAIT: return "REQ_COND_WAIT";
1121 case REQ_COND_WAIT_TIMEOUT: return "REQ_COND_WAIT_TIMEOUT";
1122 case REQ_COND_BROADCAST: return "REQ_COND_BROADCAST";
1124 case REQ_SEM_INIT: return "REQ_SEM_INIT";
1125 case REQ_SEM_DESTROY: return "REQ_SEM_DESTROY";
1126 case REQ_SEM_RELEASE: return "REQ_SEM_RELEASE";
1127 case REQ_SEM_ACQUIRE: return "REQ_SEM_ACQUIRE";
1128 case REQ_SEM_ACQUIRE_TIMEOUT: return "REQ_SEM_ACQUIRE_TIMEOUT";
1129 case REQ_SEM_WOULD_BLOCK: return "REQ_SEM_WOULD_BLOCK";
1130 case REQ_SEM_GET_CAPACITY: return "REQ_SEM_GET_CAPACITY";