libc and thread safety

T

Timo Benk

Hi,

Is there any info, list or something else regarding
non thread safe libc functions somewhere on the web?

-timo
 
D

Dan Pop

In said:
Is there any info, list or something else regarding
non thread safe libc functions somewhere on the web?

According to the C standard:

4 The functions in the standard library are not guaranteed to be
reentrant and may modify objects with static storage duration.158)
____________________

158) Thus, a signal handler cannot, in general, call standard
library functions.

Signal handlers are the only form of multithreading supported by the C
standard.

Dan
 
A

Alan Balmer

Is there any info, list or something else regarding
non thread safe libc functions somewhere on the web?
Depends on whose libc. Your implementation should document it, but
there's no guarantee of portability, since the standard doesn't know
about threads, which is why the question is off-topic here.
 
P

pandapower

According to the C standard:
4 The functions in the standard library are not guaranteed to be
reentrant and may modify objects with static storage duration.158)
____________________

158) Thus, a signal handler cannot, in general, call standard
library functions.

Does this mean we can call system calls from a signal handler without
any problems ?
Signal handlers are the only form of multithreading supported by the C
standard.
I didnt get what you meant by this last line.Could you kindly
elaborate

Regards
 
D

Dan Pop

In said:
Does this mean we can call system calls from a signal handler without
any problems ?

Nope, it means that you're reading impaired.
I didnt get what you meant by this last line.Could you kindly
elaborate

By the time you learn to read, you'll get it.

Dan
 
R

Randy Howard

Hi,

Is there any info, list or something else regarding
non thread safe libc functions somewhere on the web?

You will find first of all that comp.programming.threads is a very good
place to ask this type of question, as c.l.c is aimed at pure ISO/ANSI
C only. Unfortunately for you, POSIX threads, or any other thread model
you might care to discuss falls outside of that particular sandbox.

Also, you will find that a number of replacement functions for various
libc routines (typically with the original name, followed by _r() ) were
added for the POSIX pthreads implementation, which should give you some
good hints into which are particularly well known to not be thread safe.
These are defined by POSIX. A good reference book you should be aware of
is "Programming with POSIX Threads" by David R. Butenhof.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,247
Latest member
GabrieleL2

Latest Threads

Top