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

SCHED_RR

SCHED_OTHER

[_POSIX_PRIORITY_SCHEDULING]

sched_get_priority_min.........................................................

int sched_get_priority_min (

int policy);

Return the minimum integer priority allowed for the specified scheduling policy.

References: 5.5.2 Headers: 

Errors: [ENOSYS] priority scheduling is not supported.

[EINVAL] policy is invalid. Hint: Priority min and max are integer values — you can compute relative

values, for example, half and quarter points in range.

policy
SCHED__FIFORun thread until it blocks;
preempt lower-priority
threads when ready.
SCHED__RRLike SCHED_FIFO, but sub-
ject to periodic timeslicing.
SCHED_OTHERImplementation defined (may
be SCHED_FIFO, SCHED_RR,
or something else).
<p>9.3.9 Fork handlers</p>

Pthreads provides some new functions to help the new threaded environment to coexist with the traditional process-based UNIX environment. Creation of a child process by copying the full address space, for example, causes problems for threaded applications because the fork call is asynchronous with respect to other threads in the process.

pthread_atfork

int pthread_atfork (

void (*prepare)(void),

void (*parent)(void),

void (*child)(void));

Define "fork handlers" that are run when the process creates a child process. Allows protection of synchronization objects and shared data in the child process (which is otherwise difficult to control).

References: 6.1.1

Headers: *[10]

Errors: [ENOMEM] insufficient space to record the handlers.

Hint: All resources needed by child must be protected.

<p><strong>9.3.10</strong><emphasis><strong>Stdio</strong></emphasis></p>

Pthreads provides some new functions, and new versions of old functions, to access ANSI C stdio features safely from a threaded process. For safety reasons, the old forms of single-character access to stdio buffers have been altered to lock the file stream, which can decrease performance. You can change old code to instead lock the file stream manually and, within that locked region, use new character access operations that do not lock the file stream.

flockfile

void flockfile (

FILE *file);

Increase the lock count for a stdio file stream to gain exclusive access to the file stream. If the file stream is currently locked by another thread, the calling thread is blocked until the lock count for the file stream becomes zero. If the calling thread already owns the file stream lock, the lock count is incremented — an identical number of calls to funlockfile is required to release the file stream lock.

Although most stdio functions, such as printf and fgets, are thread-safe, you may sometimes find that it is important that a sequence of printf calls, for example, from one thread cannot be separated by calls made from another thread. Also, a few stdio functions are not thread-safe and can only be used while the file stream is locked by the caller.

References: 6.4.1 Headers: 

Hint: Use to protect a sequence of stdio operations.

ftrylockfile

int ftrylockfile (

FILE *file);

If the file stream is currently locked by another thread, return a nonzero value. Otherwise, increase the lock count for the file stream, and return the value zero.

References: 6.4.1 Headers: 

Hint: Use to protect a sequence of stdio operations.

funlockfile

void funlockfile (

FILE *file);

Decrease the lock count for a stdio file stream that was previously locked by a corresponding call to funlockfile. If the lock count becomes 0, release the lock so that another thread can lock it.

References: 6.4.1 Headers: 

Hint: Use to protect a sequence of stdio operations.

getc_unlocked

int getc_unlocked (

FILE *file);

Return a single character from the stdio stream file, without locking the file stream. This operation must only be used while the file stream has been locked by calling flockfile, or when you know that no other thread may access the file stream concurrently. Returns EOF for read errors or end-of-file condition.

References: 6.4.2 Headers: 

Hint: Replace old calls to getc to retain fastest access.

getchar_unlocked

int getc_unlocked (void);

Return a single character from the stdio stream stdin without locking the file stream. This operation must only be used while the file stream has been locked by calling flockfile, or when you know that no other thread may access the file stream concurrently. Returns EOF for read errors or end-of-file condition.

References: 6.4.2 Headers: 

Hint: Replace old calls to getchar to retain fastest access.

putc_unlocked

int putc_unlocked (

int c,

FILE *file);

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

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

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

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

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

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

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

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

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