Читаем Programming with POSIX® Threads полностью

const pthread_attr_t *attr, size_t *guardsize);

Determine the size of the guard region for the stack on which threads created with attr will run.

References: 2, 5.2.3

Errors: [EINVAL] attr invalid.

Hint: Specify 0 to fit lots of stacks in an address space, or increase default

guardsize for threads that allocate large buffers on the stack.

pthread_attr_setguardsize

int pthread_attr_setguardsize (

pthread_attr_t *attr,

size_t guardsize);

Threads created with attr will run on a stack with guardsize bytes protected against stack overflow. The implementation may round guardsize up to the next multiple of PAGESIZE. Specifying a value of 0 for guardsize will cause threads created using the attributes object to run without stack overflow protection.

References: 2, 5.2.3

Errors: [EINVAL] guardsize or attr invalid.

Hint: Specify 0 to fit lots of stacks in an address space, or increase default

guardsize for threads that allocate large buffers on the stack.

<p>10.1.5 Parallel I/O</p>

Many high-performance systems, such as database engines, use threads, at least in part, to gain performance through parallel I/O. Unfortunately, Pthreads doesn't directly support parallel I/O. That is, two threads can independently issue I/O operations for files, or even for the same file, but the POSIX file I/O model places some restrictions on the level of parallelism.

One bottleneck is that the current file position is an attribute of the file descriptor. To read or write data from or to a specific position within a file, a thread must call lseek to seek to the proper byte offset in the file, and then read or write. If more than one thread does this at the same time, the first thread might seek, and then the second thread seek to a different place before the first thread can issue the read or write operation.

The X/Open pread and pwrite functions offer a solution, by making the seek and read or write combination atomic. Threads can issue pread or pwrite operations in parallel, and, in principle, the system can process those I/O requests completely in parallel without locking the file descriptor.

pread

size_t pread (

int fildes,

void *buf,

size_t nbyte,

off_t offset);

Read nbyte bytes from offset offset in the file opened on file descriptor fildes, placing the result into buf. The file descriptor's current offset is not affected, allowing multiple pread and/or pwrite operations to proceed in parallel.

References: none

Errors: [EINVAL]offsetisnegative.

[EOVERFLOW] attempt to read beyond maximum.

[ENXIO] request outside capabilities of device.

[ESPiPE] file is pipe. Hint: Allows high-performance parallel I/O.

pwrite

size_t pwrite (

int fildes,

const void *buf,

size_t nbyte,

off_t offset);

Write nbyte bytes to offset offset in the file opened on file descriptor fildes, from buf. The file descriptor's current offset is not affected, allowing multiplepread and/ or pwrite operations to proceed in parallel.

References: none

Errors: [EINVAL] offset is negative.

[ESPIPE] file is pipe. Hint: Allows high-performance parallel I/O.

<p>10.1.6 Cancellation points</p>

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:

Перейти на страницу:

Похожие книги

1С: Бухгалтерия 8 с нуля
1С: Бухгалтерия 8 с нуля

Книга содержит полное описание приемов и методов работы с программой 1С:Бухгалтерия 8. Рассматривается автоматизация всех основных участков бухгалтерии: учет наличных и безналичных денежных средств, основных средств и НМА, прихода и расхода товарно-материальных ценностей, зарплаты, производства. Описано, как вводить исходные данные, заполнять справочники и каталоги, работать с первичными документами, проводить их по учету, формировать разнообразные отчеты, выводить данные на печать, настраивать программу и использовать ее сервисные функции. Каждый урок содержит подробное описание рассматриваемой темы с детальным разбором и иллюстрированием всех этапов.Для широкого круга пользователей.

Алексей Анатольевич Гладкий

Программирование, программы, базы данных / Программное обеспечение / Бухучет и аудит / Финансы и бизнес / Книги по IT / Словари и Энциклопедии
1С: Управление торговлей 8.2
1С: Управление торговлей 8.2

Современные торговые предприятия предлагают своим клиентам широчайший ассортимент товаров, который исчисляется тысячами и десятками тысяч наименований. Причем многие позиции могут реализовываться на разных условиях: предоплата, отсрочка платежи, скидка, наценка, объем партии, и т.д. Клиенты зачастую делятся на категории – VIP-клиент, обычный клиент, постоянный клиент, мелкооптовый клиент, и т.д. Товарные позиции могут комплектоваться и разукомплектовываться, многие товары подлежат обязательной сертификации и гигиеническим исследованиям, некондиционные позиции необходимо списывать, на складах периодически должна проводиться инвентаризация, каждая компания должна иметь свою маркетинговую политику и т.д., вообщем – современное торговое предприятие представляет живой организм, находящийся в постоянном движении.Очевидно, что вся эта кипучая деятельность требует автоматизации. Для решения этой задачи существуют специальные программные средства, и в этой книге мы познакомим вам с самым популярным продуктом, предназначенным для автоматизации деятельности торгового предприятия – «1С Управление торговлей», которое реализовано на новейшей технологической платформе версии 1С 8.2.

Алексей Анатольевич Гладкий

Финансы / Программирование, программы, базы данных