Книга: Programming with POSIX® Threads

10.1.6 Cancellation points

10.1.6 Cancellation points

Most UNIX systems support a substantial number of interfaces that do not come from POSIX. The select and poll interfaces, for example, should be deferred cancellation points. Pthreads did not require these functions to be cancellation points, however, because they do not exist within POSIX. 1.

The select and poll functions, however, along with many others, exist in X/Open. The XSH5 standard includes an expanded list of cancellation points covering X/Open interfaces.

Additional functions that must be cancellation points in XSH5:

getmsg pread sigpause

getpmsg putmsg usleep

lockf putpmsg wait3

msgrcv pwrite waitid

msgsnd readv writev

poll select

Additional functions that may be cancellation points in XSH5:

Condition variable wait clock:

int pthread_condattr_getclock (

const pthread_condattr_t *attr,

clockid_t *clock_id); int pthread_condattr_setclock (

pthread_condattr_t *attr,

clockid_t clock_id);

Barriers:

int barrier_attr_init (barrier_attr_t *attr); int barrier_attr_destroy (barrier_attr_t *attr); int barrier_attr_getpshared (

const barrier_attr_t *attr, int *pshared); int barrier_attr_setpshared (

barrier_attr_t *attr, int pshared); int barrier_init (barrier_t *barrier,

const barrier_attr_t *attr, int count); int barrier_destroy (barrier_t *barrier); int barrier_wait (barrier_t *barrier);

catclose

catgets

catopen

closelog

dbm_close

dbm_delete

dbm_fetch

dbm_nextkey

dbm_open

dbm_store

dlclose

dlopen

endgrent

endpwent

endutxent

fgetwc

fgetws

fputwc

fputws

fseeko

fsetpos

ftello

ftw

fwprintf

fwscanf

getgrent

getpwent

getutxent

getutxid

getutxline

getw

getwc

getwchar

iconv_close

iconv_open

ioctl

mkstemp

nftw

openlog

pclose

popen

pututxline

putw

putwc

putwchar

readdir_r

seekdir

semop

setgrent

setpwent

setutxent

syslog

ungetwc

vfprintf

vfwprintf

vprintf

vwprintf

wprintf

wscanf

10.2 POSIX 1003.1j

Reader/writer locks:

int rwlock_attr_init (rwlock_attr_t *attr); int rwlock_attr_destroy (rwlock_attr_t *attr); int rwlock_attr_getpshared (

const rwlock_attr_t *attr, int *pshared); int rwlock_attr_setpshared (

rwlock_attr_t *attr, int pshared); int rwlock_init (

rwlock_t *lock, const rwlock_attr_t *attr); int rwlock_destroy (rwlock_t *lock); int rwlock_rlock (rwlock_t *lock); int rwlock_timedrlock (rwlock_t *lock,

const struct timespec *timeout); int rwlock_tryrlock (rwlock_t *lock); int rwlock_wlock (rwlock_t *lock); int rwlock_timedwlock (rwlock_t *lock,

const struct timespec *timeout); int rwlock_trywlock (rwlock_t *lock); int rwlock_unlock (rwlock_t *lock);

Spinlocks:

int spin_init (spinlock_t *lock);

int spin_destroy (spinlock_t *lock);

int spin_lock (spinlock_t *lock);

int spin_trylock (spinlock_t *lock);

int spin_unlock (spinlock_t *lock);

int pthread_spin_init (pthread_spinlock_t *lock);

int pthread_spin_destroy (pthread_spinlock_t *lock);

int pthread_spin_lock (pthread_spinlock_t *lock);

int pthread_spin_trylock (pthread_spinlock_t *lock);

int pthread_spin_unlock (pthread_spinlock_t *lock);

Thread abort:

int pthread_abort (pthread_t thread);

The same POSIX working group that developed POSIX. lb and Pthreads has developed a new set of extensions for realtime and threaded programming. Most of the extensions relevant to threads (and to this book) are the result of proposals developed by the POSIX 1003.14 profile group, which specialized in "tuning" the existing POSIX standards for multiprocessor systems.

POSIX. lj adds some thread synchronization mechanisms that have been common in a wide range of multiprocessor and thread programming, but that had been omitted from the original Pthreads standard. Barriers and spinlocks are primarily useful for flne-grained parallelism, for example, in systems that automatically

generate parallel code from program loops. Read/write locks are useful in shared data algorithms where many threads are allowed to read simultaneously, but only one thread can be allowed to update data.

Оглавление книги


Генерация: 0.038. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз