This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: hash-synchronization for alpha




On 22 Jul 2001, Tom Tromey wrote:
> I can't comment on the correctness of this patch.  I don't know
> anything about the alpha.

How about style, esp. the multi-line asm bits?

> How well does it fare against the test suite?

No change.  (I'm seeing 8 failures, which may be due to local changes in
my tree.)

Note that we don't really have much to properly test synchronization.  I
appended  a simple test that demonstrates atomic increments.  Should this
be part of the libgcj test suite?

> If it causes no regressions, please check it in.

Done; thanks.


// Test synchronization by performing concurrent atomic increments.
public class SyncTest implements Runnable {
  static int counter;

  public void run() {
    for (int n = 0; n < 1000000; n++)
      synchronized (SyncTest.class) {
        counter++;
      }
  }

  public static void main(String[] args) {
    SyncTest test = new SyncTest();
    Thread[] thr = new Thread[4];

    for (int n = 0; n < thr.length; n++) {
      thr[n] = new Thread(test);
      thr[n].start();
    }

    for (int n = 0; n < thr.length; n++) {
      try {
        thr[n].join();
      } catch (InterruptedException ex) {
      }
    }

    System.out.println(counter == 1000000 * thr.length ?
      "ok" : "fail: " + counter);
  }
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]