Package org.jcsp.lang

Class SpuriousLog


  • public class SpuriousLog
    extends Object
    This holds the log of spurious wakeups and early timeouts.

    Description

    The java.lang.Object.wait method sometimes returns spuriously - i.e. without being notify'd by another thread or interrupted or timed-out! This class is an optional (static) repository holding and reporting counts of any such spurious wakeups. JCSP handles all spurious wakeups cleanly.

    Some JVMs also timeout on calls of wait(timeout) early. This class enables the specification of how early will be acceptable to JCSP. ``Timeouts'' returned earlier than the set threshold are treated as spurious wakeups (i.e. the process is put back to sleep). Provision is also made for counting and reporting the accepted early timeouts.

    To operate, this logging must first be switched on (start()).

    Author:
    P.H. Welch
    • Field Detail

      • One2OneChannelIntWrite

        public static final int One2OneChannelIntWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2OneChannelIntXWrite

        public static final int One2OneChannelIntXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2OneChannelWrite

        public static final int One2OneChannelWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2OneChannelXWrite

        public static final int One2OneChannelXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2OneChannelIntWrite

        public static final int Any2OneChannelIntWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2OneChannelIntXWrite

        public static final int Any2OneChannelIntXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2OneChannelWrite

        public static final int Any2OneChannelWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2OneChannelXWrite

        public static final int Any2OneChannelXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2AnyChannelIntWrite

        public static final int One2AnyChannelIntWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2AnyChannelIntXWrite

        public static final int One2AnyChannelIntXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2AnyChannelWrite

        public static final int One2AnyChannelWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • One2AnyChannelXWrite

        public static final int One2AnyChannelXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2AnyChannelIntWrite

        public static final int Any2AnyChannelIntWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2AnyChannelIntXWrite

        public static final int Any2AnyChannelIntXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2AnyChannelWrite

        public static final int Any2AnyChannelWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • Any2AnyChannelXWrite

        public static final int Any2AnyChannelXWrite
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • AlternativeSelectWithTimeout

        public static final int AlternativeSelectWithTimeout
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • BucketFallInto

        public static final int BucketFallInto
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
      • AltingBarrierCoordinateStartEnable

        public static final int AltingBarrierCoordinateStartEnable
        This indexes the counts of spurious wakeups (getSpuriousWakeUpCounts()), indicating the class and operation that suffered.

        Note: this field is not operative in the current JCSP release. Spurious wakeups on AltingBarriers are handled correctly -- just not recorded.

        See Also:
        Constant Field Values
      • StopRun

        public static final int StopRun
        This indexes the counts of spurious wakeups (report()), indicating the class and operation that suffered.
        See Also:
        Constant Field Values
    • Method Detail

      • start

        public static void start()
        Start logging of spurious wakeups. This should be set before any concurrency is started. It should only be set once. There is no concurrency protection!
      • finish

        public static void finish()
        Finish logging of spurious wakeups. This should be set after any concurrency has finished. There is no concurrency protection!
      • numberSpuriousWakeUps

        public static int numberSpuriousWakeUps()
        Returns the number of spurious wakeups so far.
        Returns:
        the number of spurious wakeups so far.
      • getSpuriousWakeUpCounts

        public static int[] getSpuriousWakeUpCounts()
        Returns the counts of spurious wakeups so far. This array is indexed by the public constants in this class. Only a clone is returned.
        Returns:
        the counts of spurious wakeups so far.
      • setEarlyTimeout

        public static void setEarlyTimeout​(long earlyTimeout)
        This sets the allowed early timeout (in msecs). Some JVMs timeout on calls of wait(timeout) early - this specifies how early JCSP will tolerate. ``Timeouts'' returned earlier than the set threshold are treated as spurious wakeups (i.e. the process is put back to sleep).

        This should be set before any concurrency is started. It should only be set once. There is no concurrency protection!

        Parameters:
        earlyTimeout - the allowed early timeout (in msecs).
      • getEarlyTimeout

        public static long getEarlyTimeout()
        This returns the allowed early timeout (in msecs).
        Returns:
        the allowed early timeout (in msecs).
      • numberEarlyTimeouts

        public static int numberEarlyTimeouts()
        Returns the number of early timeouts accepted so far.
        Returns:
        the number of early timeouts accepted so far.
      • report

        public static String report()
        This returns a report on the counts of spurious wakeups and early timeouts so far. A breakdown of spurious wakeup counts is given only if there are some.
        Returns:
        the report.