+static int compare_comm_pattern(mc_comm_pattern_t comm1, mc_comm_pattern_t comm2){
+ if(strcmp(comm1->rdv, comm2->rdv) != 0)
+ return 1;
+ if(comm1->src_proc != comm2->src_proc)
+ return 1;
+ if(comm1->dst_proc != comm2->dst_proc)
+ return 1;
+ if(comm1->data_size != comm2->data_size)
+ return 1;
+ if(memcmp(comm1->data, comm2->data, comm1->data_size) != 0)
+ return 1;
+ return 0;
+}
+
+static void deterministic_pattern(xbt_dynar_t initial_pattern, xbt_dynar_t pattern){
+
+ if(!xbt_dynar_is_empty(incomplete_communications_pattern))
+ xbt_die("Oh oh ...");
+
+ unsigned int cursor = 0, send_index = 0, recv_index = 0;
+ mc_comm_pattern_t comm1, comm2;
+ int comm_comparison = 0;
+ int current_process = 0;
+ while(current_process < simix_process_maxpid){
+ while(cursor < xbt_dynar_length(initial_pattern)){
+ comm1 = (mc_comm_pattern_t)xbt_dynar_get_as(initial_pattern, cursor, mc_comm_pattern_t);
+ if(comm1->type == SIMIX_COMM_SEND && comm1->src_proc == current_process){
+ comm2 = get_comm_pattern_from_idx(pattern, &send_index, comm1->type, current_process);
+ comm_comparison = compare_comm_pattern(comm1, comm2);
+ if(comm_comparison == 1){
+ initial_state_safety->send_deterministic = 0;
+ initial_state_safety->comm_deterministic = 0;
+ return;
+ }
+ send_index++;
+ }else if(comm1->type == SIMIX_COMM_RECEIVE && comm1->dst_proc == current_process){
+ comm2 = get_comm_pattern_from_idx(pattern, &recv_index, comm1->type, current_process);
+ comm_comparison = compare_comm_pattern(comm1, comm2);
+ if(comm_comparison == 1){
+ initial_state_safety->comm_deterministic = 0;
+ if(!_sg_mc_send_determinism)
+ return;
+ }
+ recv_index++;
+ }
+ cursor++;
+ }
+ cursor = 0;
+ send_index = 0;
+ recv_index = 0;
+ current_process++;
+ }
+}
+
+void complete_comm_pattern(xbt_dynar_t list, smx_action_t comm){
+ mc_comm_pattern_t current_pattern;
+ unsigned int cursor = 0;
+ int index;
+ int completed = 0;
+ void *addr_pointed;
+ xbt_dynar_foreach(incomplete_communications_pattern, cursor, index){
+ current_pattern = (mc_comm_pattern_t)xbt_dynar_get_as(list, index, mc_comm_pattern_t);
+ if(current_pattern->comm == comm){
+ current_pattern->src_proc = comm->comm.src_proc->pid;
+ current_pattern->dst_proc = comm->comm.dst_proc->pid;
+ current_pattern->src_host = simcall_host_get_name(comm->comm.src_proc->smx_host);
+ current_pattern->dst_host = simcall_host_get_name(comm->comm.dst_proc->smx_host);
+ if(current_pattern->data_size == -1){
+ current_pattern->data_size = *(comm->comm.dst_buff_size);
+ current_pattern->data = xbt_malloc0(current_pattern->data_size);
+ addr_pointed = *(void **)comm->comm.src_buff;
+ if(addr_pointed > std_heap && addr_pointed < ((xbt_mheap_t)std_heap)->breakval)
+ memcpy(current_pattern->data, addr_pointed, current_pattern->data_size);
+ else
+ memcpy(current_pattern->data, comm->comm.src_buff, current_pattern->data_size);
+ }
+ xbt_dynar_remove_at(incomplete_communications_pattern, cursor, NULL);
+ completed++;
+ if(completed == 2)
+ return;
+ cursor--;
+ }
+ }
+}