JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Multithreaded Programming Guide
search filter icon
search icon

Document Information

Preface

1.  Covering Multithreading Basics

2.  Basic Threads Programming

Lifecycle of a Thread

The Pthreads Library

Creating a Default Thread

pthread_create Syntax

pthread_create Return Values

Waiting for Thread Termination

pthread_join Syntax

pthread_join Return Values

Simple Threads Example

Detaching a Thread

pthread_detach Syntax

pthread_detach Return Values

Creating a Key for Thread-Specific Data

pthread_key_create Syntax

pthread_key_create Return Values

Deleting the Thread-Specific Data Key

pthread_key_delete Syntax

pthread_key_delete Return Values

Setting Thread-Specific Data

pthread_setspecific Syntax

pthread_setspecific Return Values

Getting Thread-Specific Data

pthread_getspecific Syntax

pthread_getspecific Return Values

Global and Private Thread-Specific Data Example

Getting the Thread Identifier

pthread_self Syntax

pthread_self Return Values

Comparing Thread IDs

pthread_equal Syntax

pthread_equal Return Values

Calling an Initialization Routine for a Thread

pthread_once Syntax

pthread_once Return Values

Yielding Thread Execution

sched_yield Syntax

sched_yield Return Values

Setting the Thread Policy and Scheduling Parameters

pthread_setschedparam Syntax

pthread_setschedparam Return Values

Getting the Thread Policy and Scheduling Parameters

pthread_getschedparam Syntax

pthread_getschedparam Return Values

Setting the Thread Priority

pthread_setschedprio Syntax

pthread_setschedprio Return Values

Sending a Signal to a Thread

pthread_kill Syntax

pthread_kill Return Values

Accessing the Signal Mask of the Calling Thread

pthread_sigmask Syntax

pthread_sigmask Return Values

Forking Safely

pthread_atfork Syntax

pthread_atfork Return Values

Terminating a Thread

pthread_exit Syntax

pthread_exit Return Values

Finishing Up

Cancel a Thread

Cancellation Points

Placing Cancellation Points

Cancelling a Thread

pthread_cancel Syntax

pthread_cancel Return Values

Enabling or Disabling Cancellation

pthread_setcancelstate Syntax

pthread_setcancelstate Return Values

Setting Cancellation Type

pthread_setcanceltype Syntax

pthread_setcanceltype Return Values

Creating a Cancellation Point

pthread_testcancel Syntax

pthread_testcancel Return Values

Pushing a Handler Onto the Stack

pthread_cleanup_push Syntax

pthread_cleanup_push Return Values

Pulling a Handler Off the Stack

pthread_cleanup_pop Syntax

pthread_cleanup_pop Return Values

3.  Thread Attributes

4.  Programming with Synchronization Objects

5.  Programming With the Solaris Software

6.  Programming With Solaris Threads

7.  Safe and Unsafe Interfaces

8.  Compiling and Debugging

9.  Programming Guidelines

A.  Extended Example: A Thread Pool Implementation

Index

Chapter 2

Basic Threads Programming

This chapter introduces the basic threads programming routines for POSIX threads. This chapter describes default threads, or threads with default attribute values, which are the kind of threads that are most often used in multithreaded programming. This chapter explains how to create and use threads with nondefault attributes.