Return the current value of key in the calling thread. If no value has been set for key in the thread, NULL is returned.

References: 5.4, 7.2, 7.3.1 Headers: <pthread.h>

Errors: The effect of calling pthread_getspecific with an invalid key is un-

defined. No errors are detected.

Hint: Calling pthread_getspecific in a destructor function will return

NULL. Use destructor's argument instead.

pthread_key_create

int pthread_key_create (

pthread_key_t *key,

void (*destructor)(void *));

Create a thread-specific data key visible to all threads. All existing and new threads have value NULL for key until set using pthread_setspecific. When any thread with a non-NULL value for key terminates, destructor is called with key's current value for that thread.

References: 5.4,7.2,7.3.1 Headers: <pthread.h>

Errors: [EAGAIN] insufficientresourcesorPTHREAD_KEYS_MAxexceeded.

[ENOMEM] insufficient memory to create the key. Hint: Each key (pthread_key_t variable) must be created only once; use

a mutex or pthread_once.

pthread_key_delete

int pthread_key_delete (

pthread_key_t key);

Delete a thread-specific data key. This does not change the value of the thread-specific data key for any thread and does not run the key's destructor in any thread, so it should be used with great caution.

References: 5.4

Headers: <pthread.h>

Errors: [EINVAL]keyisinvalid.

Hint: Use only when you know all threads have NULL value.

pthread_setspecific

int pthread_setspecific (

pthread_key_t key, const void *value);

Associate a thread-specific value within the calling thread for the specified key.

References: 5.4, 7.2, 7.3.1

Headers: <pthread.h>

Errors: [ENOMEM]insufficient memory.

[EINVAL] key is invalid. Hint: If you set a value of NULL, the key's destructor will not be called at

thread termination.

9.3.8 Realtime scheduling

Realtime scheduling provides a predictable response time to important events within the process. Note that 'predictable' does not always mean 'fast,' and in many cases realtime scheduling may impose overhead that results in slower execution. Realtime scheduling is also subject to synchronization problems such as priority inversion (Sections 5.5.4 and 8.1.4), although Pthreads provides optional facilities to address some of these problems.

pthread_attr_getinheritsched....................................... [_POSIX_THREAD_PRIORITY_SCHEDULING]

int pthread_attr_getinheritsched (

const pthread_attr_t *attr,

int *inheritsched);

Determine whether threads created with attr will run using the scheduling policy and parameters of the creator or those specified in the attributes object. The default inheritsched is implementation-defined.

inheritsched

PTHREAD_INHERIT_SCHED

Use creator's scheduling policy and parameters.

PTHREAD_EXPLICIT_SCHED

Use scheduling policy and parameters in attributes object.

References: 5.2.3, 5.5 Headers: <pthread.h>

Errors: [ENOSYS] priority scheduling is not supported.

[EINVAL] attr invalid.

pthread_attr_getschedparam......................................[_POSIX_THREAD_PRIORITY_SCHEDLLING]

int pthread_attr_getschedparam (

const pthread_attr_t *attr, struct sched_param *param);

Determine the scheduling parameters used by threads created with attr. The default param is implementation defined.

References: 5.2.3, 5.5 Headers: <pthread.h>

Errors: [ENOSYS] priority schedulingis not supported.

[EINVAL] attr invalid.

pfhread_attr_getschedpolicy....................................... [_POSIX_THREAD_PRIORITY_SCHEDULING]

int pthread_attr_getschedpolicy (

const pthread_attr_t *attr, int *policy);

Determine the scheduling policy used by threads created with attr. The default policy is implementation defined.

SCHED_FIFO

SCHED_RR

SCHED_OTHER

policy

Run thread until it blocks; preempt lower-priority threads when ready.

Like SCHED_FIFO, but subject to periodic timeslicing.

Implementation defined (may be SCHED_FIFO, SCHED_RR, or something else).

References: 5.2.3, 5.5 Headers: <pthread.h>

Errors: [ENOSYS] priority scheduling is not supported.

[EINVAL] attr invalid.

pthread_attr_getscope................................................. [_POSIX_THREAD_PRIORITY_SCHEDULLING]

int pthread_attr_getscope (

const pthread_attr_t *attr,

int *contentionscope);

Determine the contention scope used by threads created with attr. The default is implementation defined.

contentionscope

PTHREAD_SCOPE_PROCESS

Thread contends with other threads in the process for processor resources.

PTHREAD SCOPE SYSTEM

Thread contends with threads in all processes for processor resources.

References: 5.2.3, 5.5 Headers: <pthread.h>

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату