C Library Issues
Errno
- The variable errno is now per thread.
- Declaring errno extern int is no longer valid.
- Must include errno.h to get the correct declaration.
Stdio
- All stdio calls inherintly lock the FILE
- A recursive locking mechanizim is provided to lock accross calls.
- For speed previous macro routines have a new name.
void flockfile(FILE * file);
int ftrylockfile(FILE * file);
void funlockfile(FILE * file);
int getc_unlocked(FILE * file);
int getchar_unlocked(void);
int putc_unlocked(FILE * file);
int putchar_unlocked(void);
Reentreant Routines
A function whose effect, when called by two or
more threads, is gaurenteed to be as if the threads
each executed the function one after another in an
undefined order, even if the actual execution is
interleaved.
- All routines which use static data; strtok, ctime, gethostbyname
are nonreentrant
- Non reentrant routines have a _r reentrant counterpart
- Some implementation reimplement functions that return static
data to use thread specific data.
Prepared by
Chris Provenzano (proven@mit.edu)