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_WAIT && r2->call == REQ_COMM_IRECV)
31 if(r1->call == REQ_COMM_ISEND && r2->call == REQ_COMM_ISEND
32 && r1->comm_isend.rdv != r2->comm_isend.rdv)
35 if(r1->call == REQ_COMM_IRECV && r2->call == REQ_COMM_IRECV
36 && r1->comm_irecv.rdv != r2->comm_irecv.rdv)
39 if(r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_WAIT
40 && r1->comm_wait.comm->comm.src_buff == r2->comm_wait.comm->comm.src_buff
41 && r1->comm_wait.comm->comm.dst_buff == r2->comm_wait.comm->comm.dst_buff)
44 if (r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_WAIT
45 && r1->comm_wait.comm->comm.src_buff != NULL
46 && r1->comm_wait.comm->comm.dst_buff != NULL
47 && r2->comm_wait.comm->comm.src_buff != NULL
48 && r2->comm_wait.comm->comm.dst_buff != NULL
49 && r1->comm_wait.comm->comm.dst_buff != r2->comm_wait.comm->comm.src_buff
50 && r1->comm_wait.comm->comm.dst_buff != r2->comm_wait.comm->comm.dst_buff
51 && r2->comm_wait.comm->comm.dst_buff != r1->comm_wait.comm->comm.src_buff)
54 if(r1->call == REQ_COMM_TEST &&
55 (r1->comm_test.comm == NULL
56 || r1->comm_test.comm->comm.src_buff == NULL
57 || r1->comm_test.comm->comm.dst_buff == NULL))
60 if(r2->call == REQ_COMM_TEST &&
61 (r2->comm_test.comm == NULL
62 || r2->comm_test.comm->comm.src_buff == NULL
63 || r2->comm_test.comm->comm.dst_buff == NULL))
66 if(r1->call == REQ_COMM_TEST && r2->call == REQ_COMM_WAIT
67 && r1->comm_test.comm->comm.src_buff == r2->comm_wait.comm->comm.src_buff
68 && r1->comm_test.comm->comm.dst_buff == r2->comm_wait.comm->comm.dst_buff)
71 if(r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_TEST
72 && r1->comm_wait.comm->comm.src_buff == r2->comm_test.comm->comm.src_buff
73 && r1->comm_wait.comm->comm.dst_buff == r2->comm_test.comm->comm.dst_buff)
79 char *MC_request_to_string(smx_req_t req)
81 char *type = NULL, *args = NULL, *str = NULL;
82 smx_action_t act = NULL;
87 type = bprintf("iSend");
88 args = bprintf("src=%s, buff=%p, size=%zu", req->issuer->name,
89 req->comm_isend.src_buff, req->comm_isend.src_buff_size);
92 size = req->comm_irecv.dst_buff_size ? *req->comm_irecv.dst_buff_size : 0;
93 type = bprintf("iRecv");
94 args = bprintf("dst=%s, buff=%p, size=%zu", req->issuer->name,
95 req->comm_irecv.dst_buff, size);
98 act = req->comm_wait.comm;
99 type = bprintf("Wait");
100 args = bprintf("%p [%s(%lu) -> %s(%lu)]", act,
101 act->comm.src_proc ? act->comm.src_proc->name : "",
102 act->comm.src_proc ? act->comm.src_proc->pid : 0,
103 act->comm.dst_proc ? act->comm.dst_proc->name : "",
104 act->comm.dst_proc ? act->comm.dst_proc->pid : 0);
107 act = req->comm_test.comm;
108 type = bprintf("Test");
109 args = bprintf("%p [%s -> %s]", act,
110 act->comm.src_proc ? act->comm.src_proc->name : "",
111 act->comm.dst_proc ? act->comm.dst_proc->name : "");
114 case REQ_COMM_WAITANY:
115 type = bprintf("WaitAny");
117 /* FIXME: improve output */
120 case REQ_COMM_TESTANY:
121 type = bprintf("TestAny");
123 /* FIXME: improve output */
130 str = bprintf("[(%lu)%s] %s (%s)", req->issuer->pid ,req->issuer->name, type, args);
136 unsigned int MC_request_testany_fail(smx_req_t req)
141 xbt_dynar_foreach(req->comm_testany.comms, cursor, action){
142 if(action->comm.src_proc && action->comm.dst_proc)
149 int MC_request_is_visible(smx_req_t req)
151 return req->call == REQ_COMM_ISEND
152 || req->call == REQ_COMM_IRECV
153 || req->call == REQ_COMM_WAIT
154 || req->call == REQ_COMM_WAITANY
155 || req->call == REQ_COMM_TEST
156 || req->call == REQ_COMM_TESTANY;
159 int MC_request_is_enabled(smx_req_t req)
161 unsigned int index = 0;
167 /* FIXME: check also that src and dst processes are not suspended */
169 /* If there is a timeout it will be always enabled because, if the
170 * communication is not ready, it can timeout.
171 * This avoids false positives on dead-locks */
172 if(req->comm_wait.timeout >= 0)
175 act = req->comm_wait.comm;
176 return (act->comm.src_proc && act->comm.dst_proc);
179 case REQ_COMM_WAITANY:
180 xbt_dynar_foreach(req->comm_waitany.comms, index, act) {
181 if (act->comm.src_proc && act->comm.dst_proc){
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))