A Ksem question [Was: Re: changes to thread locking layer]

alanlb at rrinc.com alanlb at rrinc.com
Mon Apr 10 20:06:28 PDT 2000


On Mon, 10 Apr 2000, Patrick Tullmann wrote:

| alanlb at rrinc.com wrote:
| > I've made the modifications to the beos-native threading system to
| > use Ksems instead, using a simple mapping to native semaphores.
| 
| Cool.
| 
| > Although I've managed to pass most of the regression tests, I've
| > noticed that the ThreadState test program, among others, gets
| > hopelessly deadlocked because the main thread attempts to acquire a
| > lock it already holds.
| 
| Is it an internal lock (i.e., not a Java object lock)?  If so, do you
| know which one?  A backtrace should provide sufficient information.

Here's a backtrace:

(gdb) info threads
  14 process 97916 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  13 process 97915 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  12 process 97914 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  11 process 97913 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  7 process 97905 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  4 process 97901 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  3 process 97900 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so
  2 process 97899 0xec084a7b in acquire_sem ()
   from /boot/beos/system/lib/libroot.so * 1 process 97897 0xec084a7b in
acquire_sem ()
   from /boot/beos/system/lib/libroot.so (gdb) thread 1 [Switching to
thread 1 (process 97897)] #0 0xec084a7b in acquire_sem () from
/boot/beos/system/lib/libroot.so (gdb) where #0 0xec084a7b in acquire_sem
() from /boot/beos/system/lib/libroot.so #1 0x800406df in slowLockMutex
(lkp=0x801c9c98, where=0xfd2c1e78)
    at ../../kaffe/kaffevm/systems/beos-native/lock-impl.h:33 #2
0x80040d08 in slowLockObject (obj=0x801c9c98, where=0x12) at locks.c:485
#3 0x801dcc17 in ?? () #4 0x80046cd8 in callMethodV (meth=0x67c,
func=0x12, obj=0x12,
    args=0xfd2c2218 "", ret=0xfd2c1ebc) at ../../config/i386/common.h:38
#5 0x800392ef in Kaffe_CallVoidMethodV (env=0x8007c8d0, obj=0x801c9c98,
    meth=0x801c14a0, args=0xfd2c2218 "") at jni.c:1068 #6 0x8003935b in
Kaffe_CallVoidMethod (env=0x8007c8d0, obj=0x801c9c98,
    meth=0x801c14a0) at jni.c:1082 #7 0x80047948 in firstStartThread
(arg=0x801c9c98) at thread.c:387 #8 0x800623fe in start_me_up
(arg=0x801e7ec0) at bjthread.c:530 #9 0xec08558d in thread_start () from
/boot/beos/system/lib/libroot.so
(gdb)


Here's a piece of the 'ps' output:

/boot/usr/kaffe/libexec/Kaffe ThreadState (team 69128) (uid 0) (gid 0)
  97897    Kaffe main thread  sem  11     311     494 Ksem(957140)
  97898 team 69128 debugtask  sem  10       0      37 team 69128 debug(957115)
  97899            finaliser  sem  20       0       0 Ksem(957143)
  97900                   gc  sem  20       0       0 Ksem(957147)
  97913            Thread-11  sem  11       0       0 Ksem(957204)
  97914            Thread-13  sem  11       0       0 Ksem(957251)
  97915            Thread-14  sem  11       0       0 Ksem(957255)
  97916            Thread-16  sem  11       0       0 Ksem(957265)  

The thread id is the leftmost column; the rightmost column tells us
that, for example, the thread named "Kaffe main thread" is waiting
for Ksem #957140.

A little utility I wrote to dump sem info shows:

% dumpsem 957140
Sem 957140   :
  Name   : Ksem
  Count  : -1
  Held by: 97897         

A complete list of the semaphores held by Kaffe (team id = 69128) shows:

[/Momo-chan/home/alanlb/ports/kaffe/test/regression 558] listsem 69128
sem: total: 16384, used:  3680, left: 12704

TEAM 69128 (/boot/usr/kaffe/libexec/Kaffe ThreadState):
     ID                           name  count
---------------------------------------------
 957122                     addon lock      0
 957135                     gen_malloc      0
 957136                     mallocLock      0
 957137                    newInitLock      0
 957138                    socket lock      0
 957139               Kaffe threadLock      1
 957140                           Ksem     -1
 957143                           Ksem     -1
 957147                           Ksem     -1
 957204                           Ksem     -1
 957251                           Ksem     -1
 957255                           Ksem     -1
 957265                           Ksem     -1
[/Momo-chan/home/alanlb/ports/kaffe/test/regression 559]      

/alan


More information about the kaffe mailing list