//since we dont store param length, we have to evaluate everytime static inline int param_compare (char *s, char *t) { for ( ;EQUALS(*s, *t); s++, t++) { if (ENDS(*s)) { return 0; } } return *s - *t; }
TESTCASE() { MAX_WAIT_TIME(3*USECSPERSEC); for (int i = 0; i < NUM_THREADS; i++) { CREATE_THREAD(i+1, increment_routine, (void*)counter); } //----------------------------------------- printf("counter->x: %lx\n", &counter->x); printf("counter->lock: %lx\n", &counter->mutex); EXISTS(t1, PTRUE, "Select thread t1"); EXISTS(t2, NOT(t1), "Select thread t2"); // RUN_UNTIL(BY(t1), ENDS(), __, "Reads from x"); // // RUN_UNTIL(NOT_BY(t1), WRITES(&counter->x, t2), __, "Writes to x"); // // RUN_UNTIL(PTRUE, ENDS(t1), __, "Ends..."); // WHILE_STAR // { // FORALL(t, (TID == t1 || TID == t2), "Select thread t"); // RUN_UNTIL(BY(t), ENDS(), __, "Run until ends"); // } // FORALL(t, PTRUE, "Select thread t"); // RUN_UNTIL(BY(t), ENDS(), __, "Run until ends"); // FORALL(t, PTRUE, "Select thread t"); // RUN_UNTIL(BY(t), PTRUE, __, "Run until ends"); // } }
TESTCASE() { MAX_WAIT_TIME(0); FUNCT(bounded_buf_get); FUNCT(bounded_buf_put); TVAR(P1); TVAR(C1); TVAR(C2); WAIT_FOR_THREAD(P1, ENTERS(bounded_buf_put), "Wait for a producer."); WAIT_FOR_DISTINCT_THREADS((C1, C2), ENTERS(bounded_buf_get), "Wait for 2 consumers."); RUN_THREAD_THROUGH(P1, RETURNS(bounded_buf_put), "Producer inserts an item."); RUN_THREAD_THROUGH(C1, HITS_MANUAL_PC(42), "First consumer runs first phase."); RUN_THREAD_THROUGH(C2, RETURNS(bounded_buf_get), "Second consumer removes the item."); // ERROR! RUN_THREAD_THROUGH(C1, ENDS(), "First consumer runs the second phase."); }
TESTCASE() { ThreadVarPtr t_ip1 = CREATE_THREAD(insertpair_routine1, (void*)&multiset); ThreadVarPtr t_ip2 = CREATE_THREAD(insertpair_routine2, (void*)&multiset); ThreadVarPtr t_ip3 = CREATE_THREAD(insertpair_routine3, (void*)&multiset); ThreadVarPtr t_lu1 = CREATE_THREAD(lookup_routine1, (void*)&multiset); ThreadVarPtr t_lu2 = CREATE_THREAD(lookup_routine2, (void*)&multiset); ThreadVarPtr t_lu3 = CREATE_THREAD(lookup_routine3, (void*)&multiset); printf("=============================================\n" "=============================================\n"); //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- FORALL(t1, BY(t_ip1) || BY(t_ip2) || BY(t_ip3)); RUN_UNTIL(BY(t1), ENDS(), __); FORALL(t2, (BY(t_ip1) || BY(t_ip2) || BY(t_ip3)) && NOT(t1)); RUN_UNTIL(BY(t2), ENDS(), __); FORALL(t3, (BY(t_ip1) || BY(t_ip2) || BY(t_ip3)) && NOT(t1) && NOT(t2)); RUN_UNTIL(BY(t3), ENDS(), __); RUN_UNTIL(BY(t_lu2), ENDS(), __); RUN_UNTIL(BY(t_lu1), ENDS(), __); RUN_UNTIL(BY(t_lu3), ENDS(), __); WHILE_STAR { EXISTS(t); RUN_UNTIL(PTRUE && !FINAL(), FINAL(t)) } RUN_UNTIL(PTRUE, FINAL()) }