- for (int i = 0; i <= maxthreads; i++) {
- action_list_t *threadlist = &threadlists[i];
- if (threadlist->empty())
- continue;
- ModelAction *first = threadlist->front();
- ClockVector *cvfirst = cvmap.get(first);
- if (first->get_seq_number()<act->get_seq_number()) {
- bool candidate=true;
- for (int j = 0; j <= maxthreads; j++) {
- action_list_t *threadlist2 = &threadlists[j];
- if (threadlist2->empty())
+ return count;
+}
+
+ModelAction * SCAnalysis::pruneArray(ModelAction **array,int count) {
+ /* No choice */
+ if (count == 1)
+ return array[0];
+
+ /* Choose first non-write action */
+ ModelAction *nonwrite=NULL;
+ for(int i=0;i<count;i++) {
+ if (!array[i]->is_write())
+ if (nonwrite==NULL || nonwrite->get_seq_number() > array[i]->get_seq_number())
+ nonwrite = array[i];
+ }
+ if (nonwrite != NULL)
+ return nonwrite;
+
+ /* Look for non-conflicting action */
+ ModelAction *nonconflict=NULL;
+ for(int a=0;a<count;a++) {
+ ModelAction *act=array[a];
+ for (int i = 0; i <= maxthreads && act != NULL; i++) {
+ thread_id_t tid = int_to_id(i);
+ if (tid == act->get_tid())
+ continue;
+
+ action_list_t *list = &threadlists[id_to_int(tid)];
+ for (action_list_t::iterator rit = list->begin(); rit != list->end(); rit++) {
+ ModelAction *write = *rit;
+ if (!write->is_write())