[LLVMdev] VMKit Runtime Link Error

Lilissun Li lilissun at gmail.com
Wed Jan 12 04:04:26 PST 2011


Hi!

I build VMKit and run some programs successfully. But when
using java.util.concurrent.locks.ReentrantLock and
java.util.concurrent.locks.Condition,
I catch a Throwable :

    java.lang.UnsatisfiedLinkError:
sun.misc.Unsafe.unpark(Ljava/lang/Object;)V

after using the function :

   void java.util.concurrent.locks.Condition.await()

My test program is as follows:

*import* *java.lang*.*;

*import* *java.util.Map*;

*import* *java.io*.*;

*import* java.util.concurrent.locks.*;



*class* BoundedBuffer {

         Lock lock;

         Condition notFull;

         Condition notEmpty;



         *final* Object[] items = *new* Object[100];

         *int* putptr, takeptr, count;



         *public* BoundedBuffer(*int* init_count)

         {

                   lock = *new* ReentrantLock();

                   notFull  = lock.newCondition();

                   notEmpty = lock.newCondition();



                   count = init_count;

                   putptr = takeptr = 0;

         }



         *public* *void* put(Object x) *throws* InterruptedException {

                   lock.lock();

                   *try* {

                            *while* (count == items.length)

                                     notFull.await();

                            items[putptr] = x;

                            *if* (++putptr == items.length)

                                     putptr = 0;

                            ++count;

                            notEmpty.signal();

                   } *finally* {

                            lock.unlock();

                   }

         }



         *public* Object take() *throws* InterruptedException {

                   Object x = *null*;

                   lock.lock();

                   *try* {

                            *while* (count == 0)

                                     notEmpty.await();

                            x = items[takeptr];

                            *if* (++takeptr == items.length)

                                     takeptr = 0;

                            --count;

                            notFull.signal();

                   } *catch* (Throwable t){

                            System.*out*.println("BoundedBuffer.catch " +
t.toString());

                   } *finally* {

                            lock.unlock();

                   }



                   *return* x;

         }



         *public* *static* *void* main(String[] args)
*throws*InterruptedException

         {

                   BoundedBuffer buffer = *new* BoundedBuffer(0);

                   buffer.take();



                   *return* ;

         }

}


Can anyone please tell me why the error?

Thanks!

Li Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110112/e588b9c6/attachment.html>


More information about the llvm-dev mailing list