nptl support for uclibc - elinuxreality diluted, inc. nptl background fully posix compliant...
TRANSCRIPT
![Page 1: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/1.jpg)
NPTL Suppor t fo r uC l ibc
2006 Linux SymposiumJuly 20th, 2006
Steven J. HillReality Diluted, Inc.
![Page 2: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/2.jpg)
Agenda
● What?● Why?● Who?
● How?
NPTL support for uClibc.
uClibc only supports linuxthreads.
Broadcom Corporation
CodePoet Consulting, L.L.C.
Reality Diluted, Inc.
![Page 3: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/3.jpg)
NPTL Background
● Fully POSIX compliant threading library● POSIX signals and high-resolution timers
● Replace the linuxthreads hack● Numerous architectures supported
● x86, x86_64, Itanic 64● PPC, PPC64● Alpha, ARM, PA-RISC, SuperH● MIPS
![Page 4: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/4.jpg)
NPTL fo r Embedded Sys tems?
● Faster and lower power processors● Denser memory devices● Demanding applications and middleware● Cell phones, settop boxes, electric razors● Deeper embedded applications should
use linuxthreads
![Page 5: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/5.jpg)
uC l ibc P ro jec t Goa l s
● Designed for embedded systems● Smaller size● Highly configurable● Smaller size● POSIX Compliance● Smaller size● Simpler toolchains
![Page 6: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/6.jpg)
uC l ibc vs . g l i bc Round 1 . . . F IGHT!
FeatureFull POSIX compliance N Y
N YNSS support N YNIS support N Ydouble math support N YLocale support Y YLGPL Y YNPTL support Y YSmall disk footprint Y NSmall memory footprint Y NMMU-less support Y NHighly configurable Y NSimple build system Y NConfiguration system Y NEase of maintenance Y N
Y NMultiple architectures Y NFast execution speed Y N
uClibc glibc
Binary compatiblity
Linuxthreads support
![Page 7: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/7.jpg)
L inux th reads vs . NPTL FATAL ITY !
Feature Linuxthreads NPTL Disk Storage Size Smallest Largest Run-time Memory Usage Smallest Largest Number of Threads Hard Coded Limit Dynamic Limit Thread Efficiency Slowest Fastest Per-Thread Signals No Yes Inter-Thread Synchronization No Yes POSIX.1 Compliance No Yes
![Page 8: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/8.jpg)
Source Code and Too l Vers ions
Component Version binutils 2.16.1 gcc 4.1.0 glibc 20050823 uClibc-nptl Branch 20060318 Linux Kernel Headers 2.6.15 LTP 20050804 Open POSIX Test Suite 20050804 buildroot 20060328 crosstool 0.38 Linux/MIPS Kernel 2.6.15
![Page 9: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/9.jpg)
NPTL Imp lementat ion fo r uC l ibc
● Initial code import● Futexes● Thread Local Storage (TLS) support● Thread cancellation points● Thread library● POSIX Timers
![Page 10: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/10.jpg)
I n i t i a l Code Impor t and Bu i ld
● Makefiles● Headers● Include paths● Missing macros and functions● Stubs and auto-generated files● Symbol aliases● Unused files
![Page 11: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/11.jpg)
Futexes
● Fast user-level mutexes needed for high-performance threading
● Uses Linux kernel locking primitives● Read Rusty's paper● Futexes used in uClibc I/O subsystem
![Page 12: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/12.jpg)
Thread Loca l S to rage (TLS)
● Dynamic Loader a lot of work– 2200 lines of code changes for loader and
the libdl.so library.– No TLS variables in loader itself for uClibc.
● TLS variables prefixed with __thread.● Statically linked threaded applications
are not supported.● Total of 18 TLS variables in glibc.
![Page 13: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/13.jpg)
Thread Loca l S to rage cont . ' d
● Only 4 TLS variables were implemented.– errno– h_errno– _res– RPC_VARS
● Remaining variables for locale support.● Threaded locales unsupported in uClibc.
![Page 14: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/14.jpg)
Cance l la t i on Po in ts
● Thread cancellation?● Cancellation Points.● Asynchronous Cancellation.● Most cancellation points were ported.● Each library has own enable/disable.● Aliases haunt my dreams.
![Page 15: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/15.jpg)
Thread L ib ra r ies
● uClibc library almost verbatim to glibc.
● All code with SHLIB_COMPAT deleted.
● All files with old_pthread_xxx deleted.● No Asynchronous I/O files ported.
● libthread_db ported near perfectly.
![Page 16: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/16.jpg)
POS IX T imers
● Not original Statement of Work.● Ported for completeness.● Tests with POSIX timers and NPTL pass.
![Page 17: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/17.jpg)
Tes t ing the Imp lementa t ion
● uClibc Testsuite● glibc Testsuite● Linux Test Project (LTP)● Open POSIX Testsuite
![Page 18: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/18.jpg)
uC l ibc and g l i bc Tes tsu i tes
● Entire uClibc testsuite passed.● All TLS tests pass.● All NPTL tests pass.
![Page 19: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/19.jpg)
LTP Tes t Resu l t s
glibc uClibc fcntl 14,23,24,25,26 fcntl 24,25,26 gettimeofday 02 gettimeofday 01,02 mem 02 mem 02 syslog 01,02,03,04,05,06,07,09,10 syslog 12 msgctl 02 gf 01,10,11,14,15,16,17,18,19 msgsnd 01 inode 02 rename 03,04 socketcall 02 rwtest 03,04 sysfs 04,05,06 setregid 02 syscall 01 utime 01,02,03 writev 03,04
![Page 20: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/20.jpg)
Open POS IX Tes tsu i te
glibc uClibc TOTAL 1823 1665 PASSED 1442 1428 FAILED 113 78 UNRESOLVED 146 63 UNSUPPORTED 22 29 UNTESTED 92 60 INTERRUPTED 0 0 HUNG 1 2 SEGV 6 5 OTHERS 1 0
![Page 21: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/21.jpg)
S i ze Mat te rs (Maybe? )
glibc uClibc NPTL uClibc Linuxthreads libc.so 1673805 717128 719836 ld.so 148652 35836 26864 libpthread.so 120825 97189 98940 libthread_db.so 37277 23252 14608
![Page 22: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/22.jpg)
Future Work
● Add other processor architectures.● Get static libraries working.● Implement POSIX message queues.● Implement Asynchronous I/O.● Merge NPTL code into trunk.● Sync with latest glibc NPTL code.
![Page 23: NPTL Support for uClibc - eLinuxReality Diluted, Inc. NPTL Background Fully POSIX compliant threading library POSIX signals and high-resolution timers Replace the linuxthreads hack](https://reader034.vdocument.in/reader034/viewer/2022043013/5faf60091cfefc414230d7a3/html5/thumbnails/23.jpg)
Fur ther I n fo rmat ion
● Symposium Paper● http://www.realitydiluted.com/nptl-uclibc● http://people.redhat.com/drepper/● http://www.uclibc.org/