org.jikesrvm.mm.mmtk
Class Lock

java.lang.Object
  extended by org.mmtk.vm.Lock
      extended by org.jikesrvm.mm.mmtk.Lock

public class Lock
extends Lock

Adaptive mutex with a spinlock fast path. Designed for good performance on native threaded systems. This implementation has the following specific properties:

Author:
Filip Pizlo

Field Summary
private static int CLEAR
          Lock is not held and the queue is empty.
private static int CLEAR_QUEUED
          Lock is not held but the queue is non-empty.
private  int id
           
private static int lockCount
           
private static int LOCKED
          Lock is held and the queue is empty.
private static int LOCKED_QUEUED
          Lock is held and the queue is non-empty.
private  String name
           
private  ThreadQueue queue
           
private static int QUEUEING
          Some thread is currently engaged in an enqueue or dequeue operation, and will return the lock to whatever it was in previously once that operation is done.
private static int SPIN_LIMIT
           
private  int state
           
private  RVMThread thread
           
private  int where
           
 
Constructor Summary
Lock()
           
Lock(String name)
           
 
Method Summary
 void acquire()
          Try to acquire a lock and spin-wait until acquired.
 void check(int w)
          Perform sanity checks on the lock.
 void release()
          Release the lock by incrementing serving counter.
 void setName(String str)
          Set the name of this lock instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private String name

id

private final int id

lockCount

private static int lockCount

SPIN_LIMIT

private static final int SPIN_LIMIT
See Also:
Constant Field Values

CLEAR

private static final int CLEAR
Lock is not held and the queue is empty. When the lock is in this state, there may be a thread that just got dequeued and is about to enter into contention on the lock.

See Also:
Constant Field Values

LOCKED

private static final int LOCKED
Lock is held and the queue is empty.

See Also:
Constant Field Values

CLEAR_QUEUED

private static final int CLEAR_QUEUED
Lock is not held but the queue is non-empty. This state guarantees that there is a thread that got dequeued and is about to contend on the lock.

See Also:
Constant Field Values

LOCKED_QUEUED

private static final int LOCKED_QUEUED
Lock is held and the queue is non-empty.

See Also:
Constant Field Values

QUEUEING

private static final int QUEUEING
Some thread is currently engaged in an enqueue or dequeue operation, and will return the lock to whatever it was in previously once that operation is done. During this states any lock/unlock attempts will spin until the lock reverts to some other state.

See Also:
Constant Field Values

queue

private ThreadQueue queue

state

private int state

thread

private RVMThread thread

where

private int where
Constructor Detail

Lock

public Lock(String name)

Lock

public Lock()
Method Detail

setName

public void setName(String str)
Description copied from class: Lock
Set the name of this lock instance

Specified by:
setName in class Lock
Parameters:
str - The name of the lock (for error output).

acquire

public void acquire()
Description copied from class: Lock
Try to acquire a lock and spin-wait until acquired.

Specified by:
acquire in class Lock

check

public void check(int w)
Description copied from class: Lock
Perform sanity checks on the lock. For debugging.

Specified by:
check in class Lock
Parameters:
w - Identifies the code location in the debugging output.

release

public void release()
Description copied from class: Lock
Release the lock by incrementing serving counter.

Specified by:
release in class Lock