Set Constants, Options for Delay and Yield

This morning — silently typing in bed ;) — I wrapped up some work on the SetConstantsStrategy. There are still a few limitations, but for what I’m using it, I think it’s reasonable: It only works on static fields, so I only have to deal with the one <clinit> method, not with a varying number of constructors. It works both for final and non-final fields, but they have to be initialized with a simple value. It cannot be a method call, and it shouldn’t be in a static initializer block with some complicated if-then-else stuff. I only scan through the <clinit> code for the first putstatic referring to the field. Then I check that the preceeding instruction is one that simply loads a value, not one that makes a method call or performs arithmetic. Then I remove that instruction and replace it with one that loads the new data. For setting the probability of a yield to different values from 0.0 to 1.0 or enabling and disabling things by changing a boolean, this is good enough.

I also added boolean flags to control if the yields and delays at different places are actually enabled: Now I can independently control them at

  • before a Thread.start
  • before a Thread.exit
  • before a Thread.run
  • before a Thread.join
  • before an Object.notify
  • after an Object.notify
  • before an Object.wait
  • after an Object.wait
  • before a monitorenter
  • after a monitorenter or monitorexit

I did this because Corky and I agreed that I was placing random delays in too many places, and at least I believe there is some kind of balance between delays at different synchronization points. Switching these on and off could give me a chance of exploring the interactions and finding that balance.

When I finished adding the flags, it occurred to me that maybe I shouldn’t have used one probability for all of the yields and then boolean flags for kind of insertion point; maybe I should have used probabilities for each of them. But for now, I’ll go with this implementation. Just to show some useless detail again, here are the command line arguments that I currently have in the instr.setconstants.xml file:

<args line="-force -nobackup
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_PROB:=1
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_THREAD_START:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_THREAD_EXIT:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_THREAD_RUN:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_THREAD_JOIN:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_PRE_NOTIFY:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_POST_NOTIFY:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_PRE_WAIT:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_POST_WAIT:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_PRE_MONITOR:=false
-X set-const=edu.rice.cs.cunit.SyncPointBuffer::RANDOM_YIELD_POST_MONITOR:=false"/>

It overrides all the yield flags and the probability. The -force flag is there to allow instrumentation of already instrumented files.

Now we’re off to a Christmas party at Dr. Nguyen’s house. Thanks for the invitation!

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing. Bookmark the permalink.

Leave a Reply