public void acquire() {
        Lib.assertTrue(!isHeldByCurrentThread());
        int p;
        boolean intStatus = Machine.interrupt().disable();
        KThread thread = KThread.currentThread();
        if(useSPS)
            temp.printTryLock(thread, this);
        
        // check if highest priority can be changed
        if(useSPS && (p = temp.getPriority(thread)) < highestPriority)
            highestPriority = p;
        
        // thread must wait
        if (lockHolder != null) {
            if(useSPS && useDonation)
                temp.donate(thread, lockHolder, this, true);
            waitQueue.waitForAccess(thread);
            KThread.sleep();
        }
        // can aquire right away
        else {
            lockHolder = thread;
            if(useSPS)
                temp.printAquireLock(lockHolder, this);
            if(useDonation && useSPS)
                temp.addLock(thread,this);
        }

        Lib.assertTrue(lockHolder == thread);

        Machine.interrupt().restore(intStatus);
    }