How To Enable Native POSIX Threads on Debian Sarge |
Ja, okej, so Sarge is getting a bit ancient but in the 3 years we've been running our server we've only had to reboot once to install a new kernel, so I'm not in a big hurry to upgrade. I did notice today though, while assessing the performance of the server, that our Java app server is spawning one process per thread. And here I was thinking that Java supported native kernel threads. Well, actually it does. My surprise was that, until fairly recently, it was Linux that didn't support kernel threads.
We were using the LinuxThreads library which creates user threads mapped to Linux processes with a shared memory space. The latest way to do threading is with the Native POSIX Thread Library (NPTL) which creates real kernel lightweight processes (LWPs). It needed Linux 2.6 which we had, but despite reading reports of people using it on Sarge, I couldn't find any articles explaining how to switch from LinuxThreads to NPTL.
So... I thought I'd better write one. It's not too hard:
How To Enable Native POSIX Threads on Debian Sarge1. Figure out what threading system you are using:
mong:/# getconf GNU_LIBPTHREAD_VERSION linuxthreads-0.10
2. Check that you have a 2.6 kernel:
mong:/# cat /proc/version Linux version 2.6.8 (root@mong) (gcc version 3.3.5 (Debian 1:3.3.5-13)) #1 Wed Jan 17 15:16:19 EST 2007
3. And the libc6-* package for your architecture, which is built for NPTL:
mong:/# uname -m i686 mong:/# apt-get install libc6-i686
4. Kick-start NPTL (presumably this wouldn't be necessary if you could reboot):
mong:~# export LD_LIBRARY_PATH=/lib/tls/i686/cmov/ mong:~# ldconfig
5. Recheck your setup and restart your apps:
mong:~# getconf GNU_LIBPTHREAD_VERSION NPTL 0.60 mong:~# /etc/init.d/myapp restart
Et voila, no more pesky heavyweight threads!
Roger Keays is an artist, an engineer, and a student of life. He has no fixed address and has left footprints on 40-something different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, the proper use of semicolons, and finding good food. |