Xbsd implementations of the sockets interface it

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nix thread-safe version asctime r ctime r gethostbyaddr r gethostbyname r (none) localtime r rand r Figure 11.29: Common thread-unsafe library functions. The asctime, ctime, and localtime functions are commonly used functions for converting back and forth between different time and data formats. The gethostbyname, gethostbyaddr, and inet nota functions are commonly used network programming functions that we will encounter in the next chapter. With the exception of rand, all of these thread-unsafe functions are of the class-3 variety that return a pointer to a static variable. If we need to call one of these functions in a threaded program, the simplest approach is to lock-and-copy as in Figure 11.27. The disadvantage is that the additional synchronization will slow down the program. Further, this approach will not work for a class-2 thread-unsafe function such as rand that relies on static state across calls. Therefore, Unix systems provide reentrant versions of most thread-unsafe functions that end with the “ r” suffix. Unfortunately, these functions are poorly documented and the interfaces dif...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online