3 int MC_request_depend(smx_req_t r1, smx_req_t r2)
5 if (r1->issuer == r2->issuer)
8 if(r1->call == REQ_COMM_ISEND && r2->call == REQ_COMM_IRECV)
11 if(r1->call == REQ_COMM_IRECV && r2->call == REQ_COMM_ISEND)
14 /* FIXME: the following rule assumes that the result of the
15 * isend/irecv call is not stored in a buffer used in the
17 if( (r1->call == REQ_COMM_ISEND || r1->call == REQ_COMM_IRECV)
18 && (r2->call == REQ_COMM_WAIT || r2->call == REQ_COMM_TEST))
21 /* FIXME: the following rule assumes that the result of the
22 * isend/irecv call is not stored in a buffer used in the
24 if( (r2->call == REQ_COMM_ISEND || r2->call == REQ_COMM_IRECV)
25 && (r1->call == REQ_COMM_WAIT || r1->call == REQ_COMM_TEST))
28 if(r1->call == REQ_COMM_ISEND && r2->call == REQ_COMM_ISEND
29 && r1->comm_isend.rdv != r2->comm_isend.rdv)
32 if(r1->call == REQ_COMM_IRECV && r2->call == REQ_COMM_IRECV
33 && r1->comm_irecv.rdv != r2->comm_irecv.rdv)
36 if(r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_WAIT
37 && r1->comm_wait.comm->comm.src_buff == r2->comm_wait.comm->comm.src_buff
38 && r1->comm_wait.comm->comm.dst_buff == r2->comm_wait.comm->comm.dst_buff)
41 if (r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_WAIT
42 && r1->comm_wait.comm->comm.src_buff != NULL
43 && r1->comm_wait.comm->comm.dst_buff != NULL
44 && r2->comm_wait.comm->comm.src_buff != NULL
45 && r2->comm_wait.comm->comm.dst_buff != NULL
46 && r1->comm_wait.comm->comm.dst_buff != r2->comm_wait.comm->comm.src_buff
47 && r1->comm_wait.comm->comm.dst_buff != r2->comm_wait.comm->comm.dst_buff
48 && r2->comm_wait.comm->comm.dst_buff != r1->comm_wait.comm->comm.src_buff)
51 if(r1->call == REQ_COMM_TEST &&
52 (r1->comm_test.comm == NULL
53 || r1->comm_test.comm->comm.src_buff == NULL
54 || r1->comm_test.comm->comm.dst_buff == NULL))
57 if(r2->call == REQ_COMM_TEST &&
58 (r2->comm_test.comm == NULL
59 || r2->comm_test.comm->comm.src_buff == NULL
60 || r2->comm_test.comm->comm.dst_buff == NULL))
63 if(r1->call == REQ_COMM_TEST && r2->call == REQ_COMM_WAIT
64 && r1->comm_test.comm->comm.src_buff == r2->comm_wait.comm->comm.src_buff
65 && r1->comm_test.comm->comm.dst_buff == r2->comm_wait.comm->comm.dst_buff)
68 if(r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_TEST
69 && r1->comm_wait.comm->comm.src_buff == r2->comm_test.comm->comm.src_buff
70 && r1->comm_wait.comm->comm.dst_buff == r2->comm_test.comm->comm.dst_buff)
76 char *MC_request_to_string(smx_req_t req)
78 char *type = NULL, *args = NULL, *str = NULL;
79 smx_action_t act = NULL;
84 type = bprintf("iSend");
85 args = bprintf("src=%s, buff=%p, size=%zu", req->issuer->name,
86 req->comm_isend.src_buff, req->comm_isend.src_buff_size);
89 size = req->comm_irecv.dst_buff_size ? *req->comm_irecv.dst_buff_size : 0;
90 type = bprintf("iRecv");
91 args = bprintf("dst=%s, buff=%p, size=%zu", req->issuer->name,
92 req->comm_irecv.dst_buff, size);
95 act = req->comm_wait.comm;
96 type = bprintf("Wait");
97 args = bprintf("%p [%s(%lu) -> %s(%lu)]", act,
98 act->comm.src_proc ? act->comm.src_proc->name : "",
99 act->comm.src_proc ? act->comm.src_proc->pid : 0,
100 act->comm.dst_proc ? act->comm.dst_proc->name : "",
101 act->comm.dst_proc ? act->comm.dst_proc->pid : 0);
104 act = req->comm_test.comm;
105 type = bprintf("Test");
106 args = bprintf("%p [%s -> %s]", act,
107 act->comm.src_proc ? act->comm.src_proc->name : "",
108 act->comm.dst_proc ? act->comm.dst_proc->name : "");
111 case REQ_COMM_WAITANY:
112 type = bprintf("WaitAny");
114 /* FIXME: improve output */
117 case REQ_COMM_TESTANY:
118 type = bprintf("TestAny");
120 /* FIXME: improve output */
127 str = bprintf("[(%lu)%s] %s (%s)", req->issuer->pid ,req->issuer->name, type, args);
133 unsigned int MC_request_testany_fail(smx_req_t req)
138 xbt_dynar_foreach(req->comm_testany.comms, cursor, action){
139 if(action->comm.src_proc && action->comm.dst_proc)
146 int MC_request_is_visible(smx_req_t req)
148 return req->call == REQ_COMM_ISEND
149 || req->call == REQ_COMM_IRECV
150 || req->call == REQ_COMM_WAIT
151 || req->call == REQ_COMM_WAITANY
152 || req->call == REQ_COMM_TEST
153 || req->call == REQ_COMM_TESTANY;
156 int MC_request_is_enabled(smx_req_t req)
158 unsigned int index = 0;
164 /* FIXME: check also that src and dst processes are not suspended */
166 /* If it has a timeout it will be always be enabled, because even if the
167 * communication is not ready, it can timeout and won't block.
168 * On the other hand if it hasn't a timeout, check if the comm is ready.*/
169 if(req->comm_wait.timeout >= 0){
172 act = req->comm_wait.comm;
173 return (act->comm.src_proc && act->comm.dst_proc);
177 case REQ_COMM_WAITANY:
178 /* Check if it has at least one communication ready */
179 xbt_dynar_foreach(req->comm_waitany.comms, index, act) {
180 if (act->comm.src_proc && act->comm.dst_proc){
188 /* The rest of the request are always enabled */
193 int MC_request_is_enabled_by_idx(smx_req_t req, unsigned int idx)
200 /* FIXME: check also that src and dst processes are not suspended */
201 act = req->comm_wait.comm;
202 return (act->comm.src_proc && act->comm.dst_proc);
205 case REQ_COMM_WAITANY:
206 act = xbt_dynar_get_as(req->comm_waitany.comms, idx, smx_action_t);
207 return (act->comm.src_proc && act->comm.dst_proc);
215 int MC_process_is_enabled(smx_process_t process)
217 if (process->request.call != REQ_NO_REQ && MC_request_is_enabled(&process->request))