Dan Sugalski wrote:
> I'm torn between doing that and not, since firing up a second OS-level
> thread can add some overhead that we might not need with the "set a flag
> and check on op boundary" setup. I know that VMS won't kick over to the
> slower fully threadsafe version of its runtime libraries until you actually
> start a second thread, and I thought Solaris did something similar.
It's linking to libthread that makes it use the thread-safe versions of
stuff:
$ cat z.c
int main () { abort(); }
$ cc -o z z.c; ./z; pstack core
Abort(coredump)
core 'core' of 193353: ./z
ff3194d0 _kill (ff336000, 0, ff3385a8, 5, 229bc, ff29b784) + 8
0001061c main (1, ffbef8ac, ffbef8b4, 20800, 0, 0) + 4
000105f0 _start (0, 0, 0, 0, 0, 0) + b8
$ cc -o z z.c -mt; ./z; pstack core
Abort(coredump)
core 'core' of 193574: ./z
----------------- lwp# 1 / thread# 1 --------------------
ff369494 __sigprocmask (ff36bdb8, 0, 0, 20860, ff37e000, 0) + 8
ff35da38 _sigon (20860, ff3859a0, 6, ffbef6f4, 20860, 1) + d0
ff360abc _thrp_kill (0, 1, 6, ff37e000, 1, ff33a480) + f8
ff2ca840 raise (6, 0, 0, ffffffff, ff33a3ec, ffffffff) + 40
ff2b4c04 abort (ff336000, 0, ff3385a8, 5, 100d4, 0) + 100
00010624 main (1, ffbef8ac, ffbef8b4, 20800, 0, 0) + 4
000105f8 _start (0, 0, 0, 0, 0, 0) + b8
----------------- lwp# 2 / thread# 2 --------------------
ff318690 _signotifywait (ff37e000, 145, 0, 0, 0, 0) + 8
ff361930 thr_yield (0, 0, 0, 0, 0, 0) + 8c
----------------- lwp# 3 --------------------------------
ff316234 _door_return (3, ff37f6d8, ff37f6f0, 3, ff37e000, 1) + 10
ff35a1cc _lwp_start (ff245d70, 0, 6000, ffbef19c, 0, 0) + 18
ff361930 thr_yield (0, 0, 0, 0, 0, 0) + 8c
-------------------------- thread# 3 --------------------
ff35d6e4 _reap_wait (ff382a50, 20bf8, 0, ff37e000, 0, 0) + 38
ff35d43c _reaper (ff37ee80, ff3847b0, ff382a50, ff37ee58, 1, fe400000)
+ 38
ff36b4a0 _thread_start (0, 0, 0, 0, 0, 0) + 40
Alan Burlison