4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
6 static const char* request_names[] = {
7 #undef SIMIX_REQ_ENUM_ELEMENT
8 #define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
10 #undef SIMIX_REQ_ENUM_ELEMENT
14 * \brief Returns a host given its name.
16 * \param name The name of the host to get
17 * \return The corresponding host
19 smx_host_t SIMIX_req_host_get_by_name(const char *name)
21 smx_req_t req = SIMIX_req_mine();
23 req->call = REQ_HOST_GET_BY_NAME;
24 req->host_get_by_name.name = name;
26 return req->host_get_by_name.result;
30 * \brief Returns the name of a host.
32 * \param host A SIMIX host
33 * \return The name of this host
35 const char* SIMIX_req_host_get_name(smx_host_t host)
37 smx_req_t req = SIMIX_req_mine();
39 req->call = REQ_HOST_GET_NAME;
40 req->host_get_name.host = host;
42 return req->host_get_name.result;
46 * \brief Returns a dict of the properties assigned to a host.
49 * \return The properties of this host
51 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
53 smx_req_t req = SIMIX_req_mine();
55 req->call = REQ_HOST_GET_PROPERTIES;
56 req->host_get_properties.host = host;
58 return req->host_get_properties.result;
62 * \brief Returns the speed of the processor.
64 * The speed returned does not take into account the current load on the machine.
65 * \param host A SIMIX host
66 * \return The speed of this host (in Mflop/s)
68 double SIMIX_req_host_get_speed(smx_host_t host)
70 smx_req_t req = SIMIX_req_mine();
72 req->call = REQ_HOST_GET_SPEED;
73 req->host_get_speed.host = host;
75 return req->host_get_speed.result;
79 * \brief Returns the available speed of the processor.
81 * \return Speed currently available (in Mflop/s)
83 double SIMIX_req_host_get_available_speed(smx_host_t host)
85 smx_req_t req = SIMIX_req_mine();
87 req->call = REQ_HOST_GET_AVAILABLE_SPEED;
88 req->host_get_available_speed.host = host;
90 return req->host_get_available_speed.result;
94 * \brief Returns the state of a host.
96 * Two states are possible: 1 if the host is active or 0 if it has crashed.
97 * \param host A SIMIX host
98 * \return 1 if the host is available, 0 otherwise
100 int SIMIX_req_host_get_state(smx_host_t host)
102 smx_req_t req = SIMIX_req_mine();
104 req->call = REQ_HOST_GET_STATE;
105 req->host_get_state.host = host;
106 SIMIX_request_push();
107 return req->host_get_state.result;
111 * \brief Returns the user data associated to a host.
113 * \param host SIMIX host
114 * \return the user data of this host
116 void* SIMIX_req_host_get_data(smx_host_t host)
118 smx_req_t req = SIMIX_req_mine();
120 req->call = REQ_HOST_GET_DATA;
121 req->host_get_data.host = host;
122 SIMIX_request_push();
123 return req->host_get_data.result;
127 * \brief Sets the user data associated to a host.
129 * The host must not have previous user data associated to it.
130 * \param A host SIMIX host
131 * \param data The user data to set
133 void SIMIX_req_host_set_data(smx_host_t host, void *data)
135 smx_req_t req = SIMIX_req_mine();
137 req->call = REQ_HOST_SET_DATA;
138 req->host_set_data.host = host;
139 req->host_set_data.data = data;
140 SIMIX_request_push();
143 /** \brief Creates an action that executes some computation of an host.
145 * This function creates a SURF action and allocates the data necessary
146 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
148 * \param name Name of the execution action to create
149 * \param host SIMIX host where the action will be executed
150 * \param amount Computation amount (in bytes)
151 * \return A new SIMIX execution action
153 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
154 double computation_amount,
157 smx_req_t req = SIMIX_req_mine();
159 req->call = REQ_HOST_EXECUTE;
160 req->host_execute.name = name;
161 req->host_execute.host = host;
162 req->host_execute.computation_amount = computation_amount;
163 req->host_execute.priority = priority;
164 SIMIX_request_push();
165 return req->host_execute.result;
168 /** \brief Creates an action that may involve parallel computation on
169 * several hosts and communication between them.
171 * \param name Name of the execution action to create
172 * \param host_nb Number of hosts where the action will be executed
173 * \param host_list Array (of size host_nb) of hosts where the action will be executed
174 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
175 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
176 * amount between each pair of hosts
177 * \param amount the SURF action amount
178 * \param rate the SURF action rate
179 * \return A new SIMIX execution action
181 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
183 smx_host_t *host_list,
184 double *computation_amount,
185 double *communication_amount,
189 smx_req_t req = SIMIX_req_mine();
191 req->call = REQ_HOST_PARALLEL_EXECUTE;
192 req->host_parallel_execute.name = name;
193 req->host_parallel_execute.host_nb = host_nb;
194 req->host_parallel_execute.host_list = host_list;
195 req->host_parallel_execute.computation_amount = computation_amount;
196 req->host_parallel_execute.communication_amount = communication_amount;
197 req->host_parallel_execute.amount = amount;
198 req->host_parallel_execute.rate = rate;
199 SIMIX_request_push();
200 return req->host_parallel_execute.result;
204 * \brief Destroys an execution action.
206 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
207 * \param action The execution action to destroy
209 void SIMIX_req_host_execution_destroy(smx_action_t execution)
211 smx_req_t req = SIMIX_req_mine();
213 req->call = REQ_HOST_EXECUTION_DESTROY;
214 req->host_execution_destroy.execution = execution;
215 SIMIX_request_push();
219 * \brief Cancels an execution action.
221 * This functions stops the execution. It calls a surf function.
222 * \param action The execution action to cancel
224 void SIMIX_req_host_execution_cancel(smx_action_t execution)
226 smx_req_t req = SIMIX_req_mine();
228 req->call = REQ_HOST_EXECUTION_CANCEL;
229 req->host_execution_cancel.execution = execution;
230 SIMIX_request_push();
234 * \brief Returns how much of an execution action remains to be done.
236 * \param Action The execution action
237 * \return The remaining amount
239 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
241 smx_req_t req = SIMIX_req_mine();
243 req->call = REQ_HOST_EXECUTION_GET_REMAINS;
244 req->host_execution_get_remains.execution = execution;
245 SIMIX_request_push();
246 return req->host_execution_get_remains.result;
250 * \brief Returns the state of an execution action.
252 * \param execution The execution action
255 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
257 smx_req_t req = SIMIX_req_mine();
259 req->call = REQ_HOST_EXECUTION_GET_STATE;
260 req->host_execution_get_state.execution = execution;
261 SIMIX_request_push();
262 return req->host_execution_get_state.result;
266 * \brief Changes the priority of an execution action.
268 * This functions changes the priority only. It calls a surf function.
269 * \param execution The execution action
270 * \param priority The new priority
272 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
274 smx_req_t req = SIMIX_req_mine();
276 req->call = REQ_HOST_EXECUTION_SET_PRIORITY;
277 req->host_execution_set_priority.execution = execution;
278 req->host_execution_set_priority.priority = priority;
279 SIMIX_request_push();
283 * \brief Waits for the completion of an execution action and destroy it.
285 * \param execution The execution action
287 e_smx_state_t SIMIX_req_host_execution_wait(smx_action_t execution)
289 smx_req_t req = SIMIX_req_mine();
291 req->call = REQ_HOST_EXECUTION_WAIT;
292 req->host_execution_wait.execution = execution;
293 SIMIX_request_push();
294 return req->host_execution_wait.result;
298 * \brief Creates and runs a new SIMIX process.
300 * The structure and the corresponding thread are created and put in the list of ready processes.
302 * \param process the process created will be stored in this pointer
303 * \param name a name for the process. It is for user-level information and can be NULL.
304 * \param code the main function of the process
305 * \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.
306 * It can be retrieved with the function \ref SIMIX_req_process_get_data.
307 * \param hostname name of the host where the new agent is executed.
308 * \param argc first argument passed to \a code
309 * \param argv second argument passed to \a code
310 * \param properties the properties of the process
312 void SIMIX_req_process_create(smx_process_t *process, const char *name,
313 xbt_main_func_t code,
315 const char *hostname,
316 int argc, char **argv,
317 xbt_dict_t properties)
319 smx_req_t req = SIMIX_req_mine();
321 req->call = REQ_PROCESS_CREATE;
322 req->process_create.process = process;
323 req->process_create.name = name;
324 req->process_create.code = code;
325 req->process_create.data = data;
326 req->process_create.hostname = hostname;
327 req->process_create.argc = argc;
328 req->process_create.argv = argv;
329 req->process_create.properties = properties;
330 SIMIX_request_push();
333 /** \brief Kills a SIMIX process.
335 * This function simply kills a process.
337 * \param process poor victim
339 void SIMIX_req_process_kill(smx_process_t process)
341 smx_req_t req = SIMIX_req_mine();
343 req->call = REQ_PROCESS_KILL;
344 req->process_kill.process = process;
345 SIMIX_request_push();
348 /** \brief Kills all SIMIX processes.
350 void SIMIX_req_process_killall(void)
352 smx_req_t req = SIMIX_req_mine();
354 req->call = REQ_PROCESS_KILLALL;
355 SIMIX_request_push();
358 /** \brief Cleans up a SIMIX process.
359 * \param process poor victim (must have already been killed)
361 void SIMIX_req_process_cleanup(smx_process_t process)
363 smx_req_t req = SIMIX_req_mine();
365 req->call = REQ_PROCESS_CLEANUP;
366 req->process_cleanup.process = process;
367 SIMIX_request_push();
371 * \brief Migrates an agent to another location.
373 * This function changes the value of the host on which \a process is running.
375 * \param process the process to migrate
376 * \param source name of the previous host
377 * \param dest name of the new host
379 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
381 smx_req_t req = SIMIX_req_mine();
383 req->call = REQ_PROCESS_CHANGE_HOST;
384 req->process_change_host.process = process;
385 req->process_change_host.source = source;
386 req->process_change_host.dest = dest;
387 SIMIX_request_push();
391 * \brief Suspends a process.
393 * This function suspends the process by suspending the action
394 * it was waiting for completion.
396 * \param process a SIMIX process
398 void SIMIX_req_process_suspend(smx_process_t process)
400 xbt_assert(process, "Invalid parameters");
402 smx_req_t req = SIMIX_req_mine();
404 req->call = REQ_PROCESS_SUSPEND;
405 req->process_suspend.process = process;
406 SIMIX_request_push();
410 * \brief Resumes a suspended process.
412 * This function resumes a suspended process by resuming the action
413 * it was waiting for completion.
415 * \param process a SIMIX process
417 void SIMIX_req_process_resume(smx_process_t process)
419 smx_req_t req = SIMIX_req_mine();
421 req->call = REQ_PROCESS_RESUME;
422 req->process_resume.process = process;
423 SIMIX_request_push();
427 * \brief Returns the amount of SIMIX processes in the system
429 * Maestro internal process is not counted, only user code processes are
431 int SIMIX_req_process_count(void)
433 smx_req_t req = SIMIX_req_mine();
435 req->call = REQ_PROCESS_COUNT;
436 SIMIX_request_push();
437 return req->process_count.result;
441 * \brief Return the user data of a #smx_process_t.
443 * 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.
444 * \param process SIMIX process
445 * \return A void pointer to the user data
447 void* SIMIX_req_process_get_data(smx_process_t process)
449 if (process == SIMIX_process_self()) {
450 /* avoid a request if this function is called by the process itself */
451 return SIMIX_process_self_get_data();
454 smx_req_t req = SIMIX_req_mine();
456 req->call = REQ_PROCESS_GET_DATA;
457 req->process_get_data.process = process;
458 SIMIX_request_push();
459 return req->process_get_data.result;
463 * \brief Set the user data of a #m_process_t.
465 * 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.
466 * \param process SIMIX process
467 * \param data User data
469 void SIMIX_req_process_set_data(smx_process_t process, void *data)
471 if (process == SIMIX_process_self()) {
472 /* avoid a request if this function is called by the process itself */
473 SIMIX_process_self_set_data(data);
477 smx_req_t req = SIMIX_req_mine();
479 req->call = REQ_PROCESS_SET_DATA;
480 req->process_set_data.process = process;
481 req->process_set_data.data = data;
482 SIMIX_request_push();
487 * \brief Return the location on which an agent is running.
489 * 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.
490 * \param process SIMIX process
493 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
495 smx_req_t req = SIMIX_req_mine();
497 req->call = REQ_PROCESS_GET_HOST;
498 req->process_get_host.process = process;
499 SIMIX_request_push();
500 return req->process_get_host.result;
504 * \brief Return the name of an agent.
506 * This functions checks whether \a process is a valid pointer or not and return its name.
507 * \param process SIMIX process
508 * \return The process name
510 const char* SIMIX_req_process_get_name(smx_process_t process)
512 if (process == SIMIX_process_self()) {
513 /* avoid a request if this function is called by the process itself */
514 return process->name;
517 smx_req_t req = SIMIX_req_mine();
519 req->call = REQ_PROCESS_GET_NAME;
520 req->process_get_name.process = process;
521 SIMIX_request_push();
522 return req->process_get_name.result;
526 * \brief Returns true if the process is suspended .
528 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
529 * \param process SIMIX process
530 * \return 1, if the process is suspended, else 0.
532 int SIMIX_req_process_is_suspended(smx_process_t process)
534 smx_req_t req = SIMIX_req_mine();
536 req->call = REQ_PROCESS_IS_SUSPENDED;
537 req->process_is_suspended.process = process;
538 SIMIX_request_push();
539 return req->process_is_suspended.result;
542 /** \ingroup m_process_management
543 * \brief Return the properties
545 * This functions returns the properties associated with this process
547 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
549 smx_req_t req = SIMIX_req_mine();
551 req->call = REQ_PROCESS_GET_PROPERTIES;
552 req->process_get_properties.process = process;
553 SIMIX_request_push();
554 return req->process_get_properties.result;
557 /** \brief Creates a new sleep SIMIX action.
559 * This function creates a SURF action and allocates the data necessary
560 * to create the SIMIX action. It can raise a host_error exception if the
561 * host crashed. The default SIMIX name of the action is "sleep".
563 * \param duration Time duration of the sleep.
564 * \return A result telling whether the sleep was successful
566 e_smx_state_t SIMIX_req_process_sleep(double duration)
568 smx_req_t req = SIMIX_req_mine();
570 req->call = REQ_PROCESS_SLEEP;
571 req->process_sleep.duration = duration;
572 SIMIX_request_push();
573 return req->process_sleep.result;
577 * \brief Creates a new rendez-vous point
578 * \param name The name of the rendez-vous point
579 * \return The created rendez-vous point
581 smx_rdv_t SIMIX_req_rdv_create(const char *name)
583 smx_req_t req = SIMIX_req_mine();
585 req->call = REQ_RDV_CREATE;
586 req->rdv_create.name = name;
588 SIMIX_request_push();
589 return req->rdv_create.result;
594 * \brief Destroy a rendez-vous point
595 * \param name The rendez-vous point to destroy
597 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
599 smx_req_t req = SIMIX_req_mine();
601 req->call = REQ_RDV_DESTROY;
602 req->rdv_destroy.rdv = rdv;
604 SIMIX_request_push();
607 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
609 xbt_assert(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
611 /* FIXME: this is a horrible lost of performance, so we hack it out by
612 * skipping the request (for now). It won't work on distributed but
613 * probably we will change MSG for that. */
615 smx_req_t req = SIMIX_req_mine();
616 req->call = REQ_RDV_GEY_BY_NAME;
617 req->rdv_get_by_name.name = name;
618 SIMIX_request_push();
619 return req->rdv_get_by_name.result;*/
621 return SIMIX_rdv_get_by_name(name);
625 * \brief counts the number of communication requests of a given host pending
626 * on a rendez-vous point
627 * \param rdv The rendez-vous point
628 * \param host The host to be counted
629 * \return The number of comm request pending in the rdv
631 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
633 smx_req_t req = SIMIX_req_mine();
635 req->call = REQ_RDV_COMM_COUNT_BY_HOST;
636 req->rdv_comm_count_by_host.rdv = rdv;
637 req->rdv_comm_count_by_host.host = host;
639 SIMIX_request_push();
640 return req->rdv_comm_count_by_host.result;
644 * \brief returns the communication at the head of the rendez-vous
645 * \param rdv The rendez-vous point
646 * \return The communication or NULL if empty
648 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
650 smx_req_t req = SIMIX_req_mine();
652 req->call = REQ_RDV_GET_HEAD;
653 req->rdv_get_head.rdv = rdv;
655 SIMIX_request_push();
656 return req->rdv_get_head.result;
659 void SIMIX_req_comm_send(smx_rdv_t rdv, double task_size, double rate,
660 void *src_buff, size_t src_buff_size,
661 int (*match_fun)(void *, void *), void *data,
664 xbt_assert(rdv, "No rendez-vous point defined for send");
667 /* the model-checker wants two separate requests */
668 smx_action_t comm = SIMIX_req_comm_isend(rdv, task_size, rate,
669 src_buff, src_buff_size, match_fun, data, 0);
670 SIMIX_req_comm_wait(comm, timeout);
673 smx_req_t req = SIMIX_req_mine();
675 req->call = REQ_COMM_SEND;
676 req->comm_send.rdv = rdv;
677 req->comm_send.task_size = task_size;
678 req->comm_send.rate = rate;
679 req->comm_send.src_buff = src_buff;
680 req->comm_send.src_buff_size = src_buff_size;
681 req->comm_send.match_fun = match_fun;
682 req->comm_send.data = data;
683 req->comm_send.timeout = timeout;
685 SIMIX_request_push();
689 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
690 void *src_buff, size_t src_buff_size,
691 int (*match_fun)(void *, void *), void *data,
694 xbt_assert(rdv, "No rendez-vous point defined for isend");
696 smx_req_t req = SIMIX_req_mine();
698 req->call = REQ_COMM_ISEND;
699 req->comm_isend.rdv = rdv;
700 req->comm_isend.task_size = task_size;
701 req->comm_isend.rate = rate;
702 req->comm_isend.src_buff = src_buff;
703 req->comm_isend.src_buff_size = src_buff_size;
704 req->comm_isend.match_fun = match_fun;
705 req->comm_isend.data = data;
706 req->comm_isend.detached = detached;
708 SIMIX_request_push();
709 return req->comm_isend.result;
712 void SIMIX_req_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
713 int (*match_fun)(void *, void *), void *data, double timeout)
715 xbt_assert(rdv, "No rendez-vous point defined for recv");
718 /* the model-checker wants two separate requests */
719 smx_action_t comm = SIMIX_req_comm_irecv(rdv, dst_buff, dst_buff_size,
721 SIMIX_req_comm_wait(comm, timeout);
724 smx_req_t req = SIMIX_req_mine();
726 req->call = REQ_COMM_RECV;
727 req->comm_recv.rdv = rdv;
728 req->comm_recv.dst_buff = dst_buff;
729 req->comm_recv.dst_buff_size = dst_buff_size;
730 req->comm_recv.match_fun = match_fun;
731 req->comm_recv.data = data;
732 req->comm_recv.timeout = timeout;
734 SIMIX_request_push();
738 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
739 int (*match_fun)(void *, void *), void *data)
741 xbt_assert(rdv, "No rendez-vous point defined for irecv");
743 smx_req_t req = SIMIX_req_mine();
745 req->call = REQ_COMM_IRECV;
746 req->comm_irecv.rdv = rdv;
747 req->comm_irecv.dst_buff = dst_buff;
748 req->comm_irecv.dst_buff_size = dst_buff_size;
749 req->comm_irecv.match_fun = match_fun;
750 req->comm_irecv.data = data;
752 SIMIX_request_push();
753 return req->comm_irecv.result;
756 void SIMIX_req_comm_destroy(smx_action_t comm)
758 xbt_assert(comm, "Invalid parameter");
760 /* FIXME remove this request type: comms are auto-destroyed now,
761 * but what happens with unfinished comms? */
764 smx_req_t req = SIMIX_req_mine();
766 req->call = REQ_COMM_DESTROY;
767 req->comm_destroy.comm = comm;
769 SIMIX_request_push();
773 void SIMIX_req_comm_cancel(smx_action_t comm)
775 smx_req_t req = SIMIX_req_mine();
777 req->call = REQ_COMM_CANCEL;
778 req->comm_cancel.comm = comm;
780 SIMIX_request_push();
783 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
785 smx_req_t req = SIMIX_req_mine();
787 req->call = REQ_COMM_WAITANY;
788 req->comm_waitany.comms = comms;
790 SIMIX_request_push();
791 return req->comm_waitany.result;
794 int SIMIX_req_comm_testany(xbt_dynar_t comms)
796 smx_req_t req = SIMIX_req_mine();
797 if (xbt_dynar_length(comms)==0)
800 req->call = REQ_COMM_TESTANY;
801 req->comm_testany.comms = comms;
803 SIMIX_request_push();
804 return req->comm_testany.result;
807 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
809 smx_req_t req = SIMIX_req_mine();
811 req->call = REQ_COMM_WAIT;
812 req->comm_wait.comm = comm;
813 req->comm_wait.timeout = timeout;
815 SIMIX_request_push();
820 * \brief Set the category of an action.
822 * This functions changes the category only. It calls a surf function.
823 * \param execution The execution action
824 * \param category The tracing category
826 void SIMIX_req_set_category(smx_action_t action, const char *category)
828 if (category == NULL) {
832 smx_req_t req = SIMIX_req_mine();
834 req->call = REQ_SET_CATEGORY;
835 req->set_category.action = action;
836 req->set_category.category = category;
838 SIMIX_request_push();
842 int SIMIX_req_comm_test(smx_action_t comm)
844 smx_req_t req = SIMIX_req_mine();
846 req->call = REQ_COMM_TEST;
847 req->comm_test.comm = comm;
849 SIMIX_request_push();
850 return req->comm_test.result;
853 double SIMIX_req_comm_get_remains(smx_action_t comm)
855 smx_req_t req = SIMIX_req_mine();
857 req->call = REQ_COMM_GET_REMAINS;
858 req->comm_get_remains.comm = comm;
860 SIMIX_request_push();
861 return req->comm_get_remains.result;
864 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
866 smx_req_t req = SIMIX_req_mine();
868 req->call = REQ_COMM_GET_STATE;
869 req->comm_get_state.comm = comm;
871 SIMIX_request_push();
872 return req->comm_get_state.result;
875 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
877 smx_req_t req = SIMIX_req_mine();
879 req->call = REQ_COMM_GET_SRC_DATA;
880 req->comm_get_src_data.comm = comm;
882 SIMIX_request_push();
883 return req->comm_get_src_data.result;
886 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
888 smx_req_t req = SIMIX_req_mine();
890 req->call = REQ_COMM_GET_DST_DATA;
891 req->comm_get_dst_data.comm = comm;
893 SIMIX_request_push();
894 return req->comm_get_dst_data.result;
897 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
899 smx_req_t req = SIMIX_req_mine();
901 req->call = REQ_COMM_GET_SRC_PROC;
902 req->comm_get_src_proc.comm = comm;
904 SIMIX_request_push();
905 return req->comm_get_src_proc.result;
908 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
910 smx_req_t req = SIMIX_req_mine();
912 req->call = REQ_COMM_GET_DST_PROC;
913 req->comm_get_dst_proc.comm = comm;
915 SIMIX_request_push();
916 return req->comm_get_dst_proc.result;
919 #ifdef HAVE_LATENCY_BOUND_TRACKING
920 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
922 smx_req_t req = SIMIX_req_mine();
924 req->call = REQ_COMM_IS_LATENCY_BOUNDED;
925 req->comm_is_latency_bounded.comm = comm;
927 SIMIX_request_push();
928 return req->comm_is_latency_bounded.result;
932 smx_mutex_t SIMIX_req_mutex_init(void)
934 smx_req_t req = SIMIX_req_mine();
936 req->call = REQ_MUTEX_INIT;
938 SIMIX_request_push();
939 return req->mutex_init.result;
942 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
944 smx_req_t req = SIMIX_req_mine();
946 req->call = REQ_MUTEX_DESTROY;
947 req->mutex_destroy.mutex = mutex;
949 SIMIX_request_push();
952 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
954 smx_req_t req = SIMIX_req_mine();
956 req->call = REQ_MUTEX_LOCK;
957 req->mutex_lock.mutex = mutex;
959 SIMIX_request_push();
962 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
964 smx_req_t req = SIMIX_req_mine();
966 req->call = REQ_MUTEX_TRYLOCK;
967 req->mutex_trylock.mutex = mutex;
969 SIMIX_request_push();
970 return req->mutex_trylock.result;
973 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
975 smx_req_t req = SIMIX_req_mine();
977 req->call = REQ_MUTEX_UNLOCK;
978 req->mutex_unlock.mutex = mutex;
980 SIMIX_request_push();
984 smx_cond_t SIMIX_req_cond_init(void)
986 smx_req_t req = SIMIX_req_mine();
988 req->call = REQ_COND_INIT;
990 SIMIX_request_push();
991 return req->cond_init.result;
994 void SIMIX_req_cond_destroy(smx_cond_t cond)
996 smx_req_t req = SIMIX_req_mine();
998 req->call = REQ_COND_DESTROY;
999 req->cond_destroy.cond = cond;
1001 SIMIX_request_push();
1004 void SIMIX_req_cond_signal(smx_cond_t cond)
1006 smx_req_t req = SIMIX_req_mine();
1008 req->call = REQ_COND_SIGNAL;
1009 req->cond_signal.cond = cond;
1011 SIMIX_request_push();
1014 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1016 smx_req_t req = SIMIX_req_mine();
1018 req->call = REQ_COND_WAIT;
1019 req->cond_wait.cond = cond;
1020 req->cond_wait.mutex = mutex;
1022 SIMIX_request_push();
1025 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
1029 smx_req_t req = SIMIX_req_mine();
1031 req->call = REQ_COND_WAIT_TIMEOUT;
1032 req->cond_wait_timeout.cond = cond;
1033 req->cond_wait_timeout.mutex = mutex;
1034 req->cond_wait_timeout.timeout = timeout;
1036 SIMIX_request_push();
1039 void SIMIX_req_cond_broadcast(smx_cond_t cond)
1041 smx_req_t req = SIMIX_req_mine();
1043 req->call = REQ_COND_BROADCAST;
1044 req->cond_broadcast.cond = cond;
1046 SIMIX_request_push();
1050 smx_sem_t SIMIX_req_sem_init(int capacity)
1052 smx_req_t req = SIMIX_req_mine();
1054 req->call = REQ_SEM_INIT;
1055 req->sem_init.capacity = capacity;
1057 SIMIX_request_push();
1058 return req->sem_init.result;
1061 void SIMIX_req_sem_destroy(smx_sem_t sem)
1063 smx_req_t req = SIMIX_req_mine();
1065 req->call = REQ_SEM_DESTROY;
1066 req->sem_destroy.sem = sem;
1068 SIMIX_request_push();
1071 void SIMIX_req_sem_release(smx_sem_t sem)
1073 smx_req_t req = SIMIX_req_mine();
1075 req->call = REQ_SEM_RELEASE;
1076 req->sem_release.sem = sem;
1078 SIMIX_request_push();
1081 int SIMIX_req_sem_would_block(smx_sem_t sem)
1083 smx_req_t req = SIMIX_req_mine();
1085 req->call = REQ_SEM_WOULD_BLOCK;
1086 req->sem_would_block.sem = sem;
1088 SIMIX_request_push();
1089 return req->sem_would_block.result;
1092 void SIMIX_req_sem_acquire(smx_sem_t sem)
1094 smx_req_t req = SIMIX_req_mine();
1096 req->call = REQ_SEM_ACQUIRE;
1097 req->sem_acquire.sem = sem;
1099 SIMIX_request_push();
1102 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1104 smx_req_t req = SIMIX_req_mine();
1106 req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1107 req->sem_acquire_timeout.sem = sem;
1108 req->sem_acquire_timeout.timeout = timeout;
1110 SIMIX_request_push();
1113 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1115 smx_req_t req = SIMIX_req_mine();
1117 req->call = REQ_SEM_GET_CAPACITY;
1118 req->sem_get_capacity.sem = sem;
1120 SIMIX_request_push();
1121 return req->sem_get_capacity.result;
1123 /* ************************************************************************** */
1125 /** @brief returns a printable string representing the request kind */
1126 const char *SIMIX_request_name(int kind) {
1127 return request_names[kind];