[LLVMdev] VMKit Runtime Link Error

nicolas geoffray nicolas.geoffray at gmail.com
Wed Jan 12 04:58:32 PST 2011


Hi Lilissun,

VMKit does not implement all sun.misc.Unsafe methods. Looking at your
example, it looks like GNU Classpath (the library that provides java.*
classes) rely on sun.misc.Unsafe.unpark, and that the method must be
implemented by the VM. Implementing them is not trivial and requires a good
understanding of the threading library in VMKit, but I will be happy to help
if you want to take a look at it.

Cheers,
Nicolas

On Wed, Jan 12, 2011 at 1:04 PM, Lilissun Li <lilissun at gmail.com> wrote:

> 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
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110112/0e429336/attachment.html>


More information about the llvm-dev mailing list