Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

12


Thread Control


12.1 Introduction


In Chapter 11, we learned the basics about threads and thread synchronization. In this
chapter, we will learn the details of controlling thread behavior.Wewill look at thread
attributes and synchronization primitive attributes, which we ignored in the previous
chapter in favor of the default behavior.
We will follow this with a look at how threads can keep data private from other
threads in the same process. Then we will wrap up the chapter with a look at how
some process-based system calls interact with threads.

12.2 Thread Limits


We discussed thesysconffunction in Section 2.5.4. The Single UNIX Specification
defines several limits associated with the operation of threads, which we didn’t show in
Figure2.11. As with other system limits, the thread limits can be queried using
sysconf.Figure12.1 summarizes these limits.
As with the other limits reported bysysconf,use of these limits is intended to
promote application portability among different operating system implementations.
For example, if your application requires that you create four threads for every file you
manage, you might have to limit the number of files you can manage concurrently if the
system won’t let you create enough threads.

425
Free download pdf