3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
5 static const char* request_names[] = {
6 #define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
7 #include "smx_req_enum.h"
8 #undef SIMIX_REQ_ENUM_ELEMENT
12 * \brief Returns a host given its name.
14 * \param name The name of the host to get
15 * \return The corresponding host
17 smx_host_t SIMIX_req_host_get_by_name(const char *name)
19 smx_req_t req = SIMIX_req_mine();
21 req->call = REQ_HOST_GET_BY_NAME;
22 req->host_get_by_name.name = name;
24 return req->host_get_by_name.result;
28 * \brief Returns the name of a host.
30 * \param host A SIMIX host
31 * \return The name of this host
33 const char* SIMIX_req_host_get_name(smx_host_t host)
35 smx_req_t req = SIMIX_req_mine();
37 req->call = REQ_HOST_GET_NAME;
38 req->host_get_name.host = host;
40 return req->host_get_name.result;
44 * \brief Returns a dict of the properties assigned to a host.
47 * \return The properties of this host
49 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
51 smx_req_t req = SIMIX_req_mine();
53 req->call = REQ_HOST_GET_PROPERTIES;
54 req->host_get_properties.host = host;
56 return req->host_get_properties.result;
60 * \brief Returns the speed of the processor.
62 * The speed returned does not take into account the current load on the machine.
63 * \param host A SIMIX host
64 * \return The speed of this host (in Mflop/s)
66 double SIMIX_req_host_get_speed(smx_host_t host)
68 smx_req_t req = SIMIX_req_mine();
70 req->call = REQ_HOST_GET_SPEED;
71 req->host_get_speed.host = host;
73 return req->host_get_speed.result;
77 * \brief Returns the available speed of the processor.
79 * \return Speed currently available (in Mflop/s)
81 double SIMIX_req_host_get_available_speed(smx_host_t host)
83 smx_req_t req = SIMIX_req_mine();
85 req->call = REQ_HOST_GET_AVAILABLE_SPEED;
86 req->host_get_available_speed.host = host;
88 return req->host_get_available_speed.result;
92 * \brief Returns the state of a host.
94 * Two states are possible: 1 if the host is active or 0 if it has crashed.
95 * \param host A SIMIX host
96 * \return 1 if the host is available, 0 otherwise
98 int SIMIX_req_host_get_state(smx_host_t host)
100 smx_req_t req = SIMIX_req_mine();
102 req->call = REQ_HOST_GET_STATE;
103 req->host_get_state.host = host;
104 SIMIX_request_push();
105 return req->host_get_state.result;
109 * \brief Returns the user data associated to a host.
111 * \param host SIMIX host
112 * \return the user data of this host
114 void* SIMIX_req_host_get_data(smx_host_t host)
116 smx_req_t req = SIMIX_req_mine();
118 req->call = REQ_HOST_GET_DATA;
119 req->host_get_data.host = host;
120 SIMIX_request_push();
121 return req->host_get_data.result;
125 * \brief Sets the user data associated to a host.
127 * The host must not have previous user data associated to it.
128 * \param A host SIMIX host
129 * \param data The user data to set
131 void SIMIX_req_host_set_data(smx_host_t host, void *data)
133 smx_req_t req = SIMIX_req_mine();
135 req->call = REQ_HOST_SET_DATA;
136 req->host_set_data.host = host;
137 req->host_set_data.data = data;
138 SIMIX_request_push();
141 /** \brief Creates an action that executes some computation of an host.
143 * This function creates a SURF action and allocates the data necessary
144 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
146 * \param name Name of the execution action to create
147 * \param host SIMIX host where the action will be executed
148 * \param amount Computation amount (in bytes)
149 * \return A new SIMIX execution action
151 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
152 double computation_amount)
154 smx_req_t req = SIMIX_req_mine();
156 req->call = REQ_HOST_EXECUTE;
157 req->host_execute.name = name;
158 req->host_execute.host = host;
159 req->host_execute.computation_amount = computation_amount;
160 SIMIX_request_push();
161 return req->host_execute.result;
164 /** \brief Creates an action that may involve parallel computation on
165 * several hosts and communication between them.
167 * \param name Name of the execution action to create
168 * \param host_nb Number of hosts where the action will be executed
169 * \param host_list Array (of size host_nb) of hosts where the action will be executed
170 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
171 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
172 * amount between each pair of hosts
173 * \param amount the SURF action amount
174 * \param rate the SURF action rate
175 * \return A new SIMIX execution action
177 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
179 smx_host_t *host_list,
180 double *computation_amount,
181 double *communication_amount,
185 smx_req_t req = SIMIX_req_mine();
187 req->call = REQ_HOST_PARALLEL_EXECUTE;
188 req->host_parallel_execute.name = name;
189 req->host_parallel_execute.host_nb = host_nb;
190 req->host_parallel_execute.host_list = host_list;
191 req->host_parallel_execute.computation_amount = computation_amount;
192 req->host_parallel_execute.communication_amount = communication_amount;
193 req->host_parallel_execute.amount = amount;
194 req->host_parallel_execute.rate = rate;
195 SIMIX_request_push();
196 return req->host_parallel_execute.result;
200 * \brief Destroys an execution action.
202 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
203 * \param action The execution action to destroy
205 void SIMIX_req_host_execution_destroy(smx_action_t execution)
207 smx_req_t req = SIMIX_req_mine();
209 req->call = REQ_HOST_EXECUTION_DESTROY;
210 req->host_execution_destroy.execution = execution;
211 SIMIX_request_push();
215 * \brief Cancels an execution action.
217 * This functions stops the execution. It calls a surf function.
218 * \param action The execution action to cancel
220 void SIMIX_req_host_execution_cancel(smx_action_t execution)
222 smx_req_t req = SIMIX_req_mine();
224 req->call = REQ_HOST_EXECUTION_CANCEL;
225 req->host_execution_cancel.execution = execution;
226 SIMIX_request_push();
230 * \brief Returns how much of an execution action remains to be done.
232 * \param Action The execution action
233 * \return The remaining amount
235 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
237 smx_req_t req = SIMIX_req_mine();
239 req->call = REQ_HOST_EXECUTION_GET_REMAINS;
240 req->host_execution_get_remains.execution = execution;
241 SIMIX_request_push();
242 return req->host_execution_get_remains.result;
246 * \brief Returns the state of an execution action.
248 * \param execution The execution action
251 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
253 smx_req_t req = SIMIX_req_mine();
255 req->call = REQ_HOST_EXECUTION_GET_STATE;
256 req->host_execution_get_state.execution = execution;
257 SIMIX_request_push();
258 return req->host_execution_get_state.result;
262 * \brief Changes the priority of an execution action.
264 * This functions changes the priority only. It calls a surf function.
265 * \param execution The execution action
266 * \param priority The new priority
268 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
270 smx_req_t req = SIMIX_req_mine();
272 req->call = REQ_HOST_EXECUTION_SET_PRIORITY;
273 req->host_execution_set_priority.execution = execution;
274 req->host_execution_set_priority.priority = priority;
275 SIMIX_request_push();
279 * \brief Waits for the completion of an execution action.
281 * \param execution The execution action
283 void SIMIX_req_host_execution_wait(smx_action_t execution)
285 smx_req_t req = SIMIX_req_mine();
287 req->call = REQ_HOST_EXECUTION_WAIT;
288 req->host_execution_wait.execution = execution;
289 SIMIX_request_push();
293 * \brief Creates and runs a new SIMIX process.
295 * The structure and the corresponding threada are created and put in the list of ready processes.
297 * \param name a name for the process. It is for user-level information and can be NULL.
298 * \param code the main function of the process
299 * \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.
300 * It can be retrieved with the function \ref SIMIX_req_process_get_data.
301 * \param hostname name of the host where the new agent is executed.
302 * \param argc first argument passed to \a code
303 * \param argv second argument passed to \a code
304 * \param properties the properties of the process
305 * \return The new process
307 smx_process_t SIMIX_req_process_create(const char *name,
308 xbt_main_func_t code,
310 const char *hostname,
311 int argc, char **argv,
312 xbt_dict_t properties)
314 smx_req_t req = SIMIX_req_mine();
316 req->call = REQ_PROCESS_CREATE;
317 req->process_create.name = name;
318 req->process_create.code = code;
319 req->process_create.data = data;
320 req->process_create.hostname = hostname;
321 req->process_create.argc = argc;
322 req->process_create.argv = argv;
323 req->process_create.properties = properties;
324 SIMIX_request_push();
325 return req->process_create.result;
328 /** \brief Kills a SIMIX process.
330 * This function simply kills a process.
332 * \param process poor victim
334 void SIMIX_req_process_kill(smx_process_t process)
336 smx_req_t req = SIMIX_req_mine();
338 req->call = REQ_PROCESS_KILL;
339 req->process_kill.process = process;
340 SIMIX_request_push();
344 * \brief Migrates an agent to another location.
346 * This function changes the value of the host on which \a process is running.
348 * \param process the process to migrate
349 * \param source name of the previous host
350 * \param dest name of the new host
352 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
354 smx_req_t req = SIMIX_req_mine();
356 req->call = REQ_PROCESS_CHANGE_HOST;
357 req->process_change_host.process = process;
358 req->process_change_host.source = source;
359 req->process_change_host.dest = dest;
360 SIMIX_request_push();
364 * \brief Suspends a process.
366 * This function suspends the process by suspending the action
367 * it was waiting for completion.
369 * \param process a SIMIX process
371 void SIMIX_req_process_suspend(smx_process_t process)
373 smx_req_t req = SIMIX_req_mine();
375 req->call = REQ_PROCESS_SUSPEND;
376 req->process_suspend.process = process;
377 SIMIX_request_push();
381 * \brief Resumes a suspended process.
383 * This function resumes a suspended process by resuming the action
384 * it was waiting for completion.
386 * \param process a SIMIX process
388 void SIMIX_req_process_resume(smx_process_t process)
390 smx_req_t req = SIMIX_req_mine();
392 req->call = REQ_PROCESS_RESUME;
393 req->process_resume.process = process;
394 SIMIX_request_push();
398 * \brief Returns the amount of SIMIX processes in the system
400 * Maestro internal process is not counted, only user code processes are
402 int SIMIX_req_process_count(void)
404 smx_req_t req = SIMIX_req_mine();
406 req->call = REQ_PROCESS_COUNT;
407 SIMIX_request_push();
408 return req->process_count.result;
412 * \brief Return the user data of a #smx_process_t.
414 * 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.
415 * \param process SIMIX process
416 * \return A void pointer to the user data
418 void* SIMIX_req_process_get_data(smx_process_t process)
420 smx_req_t req = SIMIX_req_mine();
422 req->call = REQ_PROCESS_GET_DATA;
423 req->process_get_data.process = process;
424 SIMIX_request_push();
425 return req->process_get_data.result;
429 * \brief Set the user data of a #m_process_t.
431 * 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.
432 * \param process SIMIX process
433 * \param data User data
435 void SIMIX_req_process_set_data(smx_process_t process, void *data)
437 smx_req_t req = SIMIX_req_mine();
439 req->call = REQ_PROCESS_SET_DATA;
440 req->process_set_data.process = process;
441 req->process_set_data.data = data;
442 SIMIX_request_push();
446 * \brief Return the location on which an agent is running.
448 * 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.
449 * \param process SIMIX process
452 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
454 smx_req_t req = SIMIX_req_mine();
456 req->call = REQ_PROCESS_GET_HOST;
457 req->process_get_host.process = process;
458 SIMIX_request_push();
459 return req->process_get_host.result;
463 * \brief Return the name of an agent.
465 * This functions checks whether \a process is a valid pointer or not and return its name.
466 * \param process SIMIX process
467 * \return The process name
469 const char* SIMIX_req_process_get_name(smx_process_t process)
471 smx_req_t req = SIMIX_req_mine();
473 req->call = REQ_PROCESS_GET_NAME;
474 req->process_get_name.process = process;
475 SIMIX_request_push();
476 return req->process_get_name.result;
480 * \brief Returns true if the process is suspended .
482 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
483 * \param process SIMIX process
484 * \return 1, if the process is suspended, else 0.
486 int SIMIX_req_process_is_suspended(smx_process_t process)
488 smx_req_t req = SIMIX_req_mine();
490 req->call = REQ_PROCESS_IS_SUSPENDED;
491 req->process_is_suspended.process = process;
492 SIMIX_request_push();
493 return req->process_is_suspended.result;
496 /** \ingroup m_process_management
497 * \brief Return the properties
499 * This functions returns the properties associated with this process
501 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
503 smx_req_t req = SIMIX_req_mine();
505 req->call = REQ_PROCESS_GET_PROPERTIES;
506 req->process_get_properties.process = process;
507 SIMIX_request_push();
508 return req->process_get_properties.result;
511 /** \brief Creates a new sleep SIMIX action.
513 * This function creates a SURF action and allocates the data necessary
514 * to create the SIMIX action. It can raise a host_error exception if the
515 * host crashed. The default SIMIX name of the action is "sleep".
517 * \param duration Time duration of the sleep.
518 * \return A result telling whether the sleep was successful
520 e_smx_state_t SIMIX_req_process_sleep(double duration)
522 smx_req_t req = SIMIX_req_mine();
524 req->call = REQ_PROCESS_SLEEP;
525 req->process_sleep.duration = duration;
526 SIMIX_request_push();
527 return req->process_sleep.result;
531 * \brief Creates a new rendez-vous point
532 * \param name The name of the rendez-vous point
533 * \return The created rendez-vous point
535 smx_rdv_t SIMIX_req_rdv_create(const char *name)
537 smx_req_t req = SIMIX_req_mine();
539 req->call = REQ_RDV_CREATE;
540 req->rdv_create.name = name;
542 SIMIX_request_push();
543 return req->rdv_create.result;
548 * \brief Destroy a rendez-vous point
549 * \param name The rendez-vous point to destroy
551 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
553 smx_req_t req = SIMIX_req_mine();
555 req->call = REQ_RDV_DESTROY;
556 req->rdv_destroy.rdv = rdv;
558 SIMIX_request_push();
561 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
563 xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
564 smx_req_t req = SIMIX_req_mine();
566 req->call = REQ_RDV_GEY_BY_NAME;
567 req->rdv_get_by_name.name = name;
568 SIMIX_request_push();
569 return req->rdv_get_by_name.result;
573 * \brief counts the number of communication requests of a given host pending
574 * on a rendez-vous point
575 * \param rdv The rendez-vous point
576 * \param host The host to be counted
577 * \return The number of comm request pending in the rdv
579 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
581 smx_req_t req = SIMIX_req_mine();
583 req->call = REQ_RDV_COMM_COUNT_BY_HOST;
584 req->rdv_comm_count_by_host.rdv = rdv;
585 req->rdv_comm_count_by_host.host = host;
587 SIMIX_request_push();
588 return req->rdv_comm_count_by_host.result;
592 * \brief returns the communication at the head of the rendez-vous
593 * \param rdv The rendez-vous point
594 * \return The communication or NULL if empty
596 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
598 smx_req_t req = SIMIX_req_mine();
600 req->call = REQ_RDV_GET_HEAD;
601 req->rdv_get_head.rdv = rdv;
603 SIMIX_request_push();
604 return req->rdv_get_head.result;
607 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
608 void *src_buff, size_t src_buff_size,
609 int (*match_fun)(void *, void *), void *data)
611 smx_req_t req = SIMIX_req_mine();
613 xbt_assert0(rdv, "No rendez-vous point defined for isend");
615 req->call = REQ_COMM_ISEND;
616 req->comm_isend.rdv = rdv;
617 req->comm_isend.task_size = task_size;
618 req->comm_isend.rate = rate;
619 req->comm_isend.src_buff = src_buff;
620 req->comm_isend.src_buff_size = src_buff_size;
621 req->comm_isend.match_fun = match_fun;
622 req->comm_isend.data = data;
624 SIMIX_request_push();
625 return req->comm_isend.result;
628 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
629 int (*match_fun)(void *, void *), void *data)
631 smx_req_t req = SIMIX_req_mine();
633 xbt_assert0(rdv, "No rendez-vous point defined for isend");
635 req->call = REQ_COMM_IRECV;
636 req->comm_irecv.rdv = rdv;
637 req->comm_irecv.dst_buff = dst_buff;
638 req->comm_irecv.dst_buff_size = dst_buff_size;
639 req->comm_irecv.match_fun = match_fun;
640 req->comm_irecv.data = data;
642 SIMIX_request_push();
643 return req->comm_irecv.result;
646 void SIMIX_req_comm_destroy(smx_action_t comm)
648 smx_req_t req = SIMIX_req_mine();
650 req->call = REQ_COMM_DESTROY;
651 req->comm_destroy.comm = comm;
653 SIMIX_request_push();
656 void SIMIX_req_comm_cancel(smx_action_t comm)
658 smx_req_t req = SIMIX_req_mine();
660 req->call = REQ_COMM_CANCEL;
661 req->comm_cancel.comm = comm;
663 SIMIX_request_push();
666 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
668 smx_req_t req = SIMIX_req_mine();
670 req->call = REQ_COMM_WAITANY;
671 req->comm_waitany.comms = comms;
673 SIMIX_request_push();
674 return req->comm_waitany.result;
677 int SIMIX_req_comm_testany(xbt_dynar_t comms)
679 smx_req_t req = SIMIX_req_mine();
680 if (xbt_dynar_length(comms)==0)
683 req->call = REQ_COMM_TESTANY;
684 req->comm_testany.comms = comms;
686 SIMIX_request_push();
687 return req->comm_testany.result;
690 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
692 smx_req_t req = SIMIX_req_mine();
694 req->call = REQ_COMM_WAIT;
695 req->comm_wait.comm = comm;
696 req->comm_wait.timeout = timeout;
698 SIMIX_request_push();
703 * \brief Set the category of an action.
705 * This functions changes the category only. It calls a surf function.
706 * \param execution The execution action
707 * \param category The tracing category
709 void SIMIX_req_set_category(smx_action_t action, const char *category)
711 if (category == NULL) {
715 smx_req_t req = SIMIX_req_mine();
717 req->call = REQ_SET_CATEGORY;
718 req->set_category.action = action;
719 req->set_category.category = category;
721 SIMIX_request_push();
725 int SIMIX_req_comm_test(smx_action_t comm)
727 smx_req_t req = SIMIX_req_mine();
729 req->call = REQ_COMM_TEST;
730 req->comm_test.comm = comm;
732 SIMIX_request_push();
733 return req->comm_test.result;
736 double SIMIX_req_comm_get_remains(smx_action_t comm)
738 smx_req_t req = SIMIX_req_mine();
740 req->call = REQ_COMM_GET_REMAINS;
741 req->comm_get_remains.comm = comm;
743 SIMIX_request_push();
744 return req->comm_get_remains.result;
747 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
749 smx_req_t req = SIMIX_req_mine();
751 req->call = REQ_COMM_GET_STATE;
752 req->comm_get_state.comm = comm;
754 SIMIX_request_push();
755 return req->comm_get_state.result;
758 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
760 smx_req_t req = SIMIX_req_mine();
762 req->call = REQ_COMM_GET_SRC_DATA;
763 req->comm_get_src_data.comm = comm;
765 SIMIX_request_push();
766 return req->comm_get_src_data.result;
769 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
771 smx_req_t req = SIMIX_req_mine();
773 req->call = REQ_COMM_GET_DST_DATA;
774 req->comm_get_dst_data.comm = comm;
776 SIMIX_request_push();
777 return req->comm_get_dst_data.result;
780 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
782 smx_req_t req = SIMIX_req_mine();
784 req->call = REQ_COMM_GET_SRC_BUFF;
785 req->comm_get_src_buff.comm = comm;
787 SIMIX_request_push();
788 return req->comm_get_src_buff.result;
791 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
793 smx_req_t req = SIMIX_req_mine();
795 req->call = REQ_COMM_GET_DST_BUFF;
796 req->comm_get_dst_buff.comm = comm;
798 SIMIX_request_push();
799 return req->comm_get_dst_buff.result;
802 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
804 smx_req_t req = SIMIX_req_mine();
806 req->call = REQ_COMM_GET_SRC_BUFF_SIZE;
807 req->comm_get_src_buff_size.comm = comm;
809 SIMIX_request_push();
810 return req->comm_get_src_buff_size.result;
813 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
815 smx_req_t req = SIMIX_req_mine();
817 req->call = REQ_COMM_GET_DST_BUFF_SIZE;
818 req->comm_get_dst_buff_size.comm = comm;
820 SIMIX_request_push();
821 return req->comm_get_dst_buff_size.result;
824 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
826 smx_req_t req = SIMIX_req_mine();
828 req->call = REQ_COMM_GET_SRC_PROC;
829 req->comm_get_src_proc.comm = comm;
831 SIMIX_request_push();
832 return req->comm_get_src_proc.result;
835 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
837 smx_req_t req = SIMIX_req_mine();
839 req->call = REQ_COMM_GET_DST_PROC;
840 req->comm_get_dst_proc.comm = comm;
842 SIMIX_request_push();
843 return req->comm_get_dst_proc.result;
846 #ifdef HAVE_LATENCY_BOUND_TRACKING
847 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
849 smx_req_t req = SIMIX_req_mine();
851 req->call = REQ_COMM_IS_LATENCY_BOUNDED;
852 req->comm_is_latency_bounded.comm = comm;
854 SIMIX_request_push();
855 return req->comm_is_latency_bounded.result;
859 smx_mutex_t SIMIX_req_mutex_init(void)
861 smx_req_t req = SIMIX_req_mine();
863 req->call = REQ_MUTEX_INIT;
865 SIMIX_request_push();
866 return req->mutex_init.result;
869 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
871 smx_req_t req = SIMIX_req_mine();
873 req->call = REQ_MUTEX_DESTROY;
874 req->mutex_destroy.mutex = mutex;
876 SIMIX_request_push();
879 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
881 smx_req_t req = SIMIX_req_mine();
883 req->call = REQ_MUTEX_LOCK;
884 req->mutex_lock.mutex = mutex;
886 SIMIX_request_push();
889 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
891 smx_req_t req = SIMIX_req_mine();
893 req->call = REQ_MUTEX_TRYLOCK;
894 req->mutex_trylock.mutex = mutex;
896 SIMIX_request_push();
897 return req->mutex_trylock.result;
900 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
902 smx_req_t req = SIMIX_req_mine();
904 req->call = REQ_MUTEX_UNLOCK;
905 req->mutex_unlock.mutex = mutex;
907 SIMIX_request_push();
911 smx_cond_t SIMIX_req_cond_init(void)
913 smx_req_t req = SIMIX_req_mine();
915 req->call = REQ_COND_INIT;
917 SIMIX_request_push();
918 return req->cond_init.result;
921 void SIMIX_req_cond_destroy(smx_cond_t cond)
923 smx_req_t req = SIMIX_req_mine();
925 req->call = REQ_COND_DESTROY;
926 req->cond_destroy.cond = cond;
928 SIMIX_request_push();
931 void SIMIX_req_cond_signal(smx_cond_t cond)
933 smx_req_t req = SIMIX_req_mine();
935 req->call = REQ_COND_SIGNAL;
936 req->cond_signal.cond = cond;
938 SIMIX_request_push();
941 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
943 smx_req_t req = SIMIX_req_mine();
945 req->call = REQ_COND_WAIT;
946 req->cond_wait.cond = cond;
947 req->cond_wait.mutex = mutex;
949 SIMIX_request_push();
952 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
956 smx_req_t req = SIMIX_req_mine();
958 req->call = REQ_COND_WAIT_TIMEOUT;
959 req->cond_wait_timeout.cond = cond;
960 req->cond_wait_timeout.mutex = mutex;
961 req->cond_wait_timeout.timeout = timeout;
963 SIMIX_request_push();
966 void SIMIX_req_cond_broadcast(smx_cond_t cond)
968 smx_req_t req = SIMIX_req_mine();
970 req->call = REQ_COND_BROADCAST;
971 req->cond_broadcast.cond = cond;
973 SIMIX_request_push();
977 smx_sem_t SIMIX_req_sem_init(int capacity)
979 smx_req_t req = SIMIX_req_mine();
981 req->call = REQ_SEM_INIT;
982 req->sem_init.capacity = capacity;
984 SIMIX_request_push();
985 return req->sem_init.result;
988 void SIMIX_req_sem_destroy(smx_sem_t sem)
990 smx_req_t req = SIMIX_req_mine();
992 req->call = REQ_SEM_DESTROY;
993 req->sem_destroy.sem = sem;
995 SIMIX_request_push();
998 void SIMIX_req_sem_release(smx_sem_t sem)
1000 smx_req_t req = SIMIX_req_mine();
1002 req->call = REQ_SEM_RELEASE;
1003 req->sem_release.sem = sem;
1005 SIMIX_request_push();
1008 int SIMIX_req_sem_would_block(smx_sem_t sem)
1010 smx_req_t req = SIMIX_req_mine();
1012 req->call = REQ_SEM_WOULD_BLOCK;
1013 req->sem_would_block.sem = sem;
1015 SIMIX_request_push();
1016 return req->sem_would_block.result;
1019 void SIMIX_req_sem_acquire(smx_sem_t sem)
1021 smx_req_t req = SIMIX_req_mine();
1023 req->call = REQ_SEM_ACQUIRE;
1024 req->sem_acquire.sem = sem;
1026 SIMIX_request_push();
1029 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1031 smx_req_t req = SIMIX_req_mine();
1033 req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1034 req->sem_acquire_timeout.sem = sem;
1035 req->sem_acquire_timeout.timeout = timeout;
1037 SIMIX_request_push();
1040 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1042 smx_req_t req = SIMIX_req_mine();
1044 req->call = REQ_SEM_GET_CAPACITY;
1045 req->sem_get_capacity.sem = sem;
1047 SIMIX_request_push();
1048 return req->sem_get_capacity.result;
1050 /* ************************************************************************** */
1052 /** @brief returns a printable string representing the request kind */
1053 const char *SIMIX_request_name(int kind) {
1054 return request_names[kind];