pthread_mutex_getprioceiling 或 pthread_mutex_setprioceiling 子例程

用途

获取并设置互斥对象的优先级上限。

语法

#include <pthread.h>

int pthread_mutex_getprioceiling(const pthread_mutex_t *restrict mutex,
       int *restrict prioceiling);
int pthread_mutex_setprioceiling(pthread_mutex_t *restrict mutex,
       int prioceiling, int *restrict old_ceiling);

描述

pthread_mutex_getprioceiling 子例程返回互斥对象的当前优先级上限。

pthread_mutex_setprioceiling 子例程要么锁定互斥对象 (如果它被解锁) ,要么阻塞直到它成功锁定互斥对象,然后它更改互斥对象的优先级上限并释放互斥对象。 更改成功时,将在 old_天花板中返回优先级上限的前一个值。 锁定互斥对象的过程无需遵循优先级保护协议。

如果 pthread_mutex_setprioceiling 子例程失败,那么不会更改互斥优先级上限。

返回值

如果成功,那么 pthread_mutex_getprioceilingpthread_mutex_setprioceiling 子例程将返回零; 否则,将返回错误号以指示错误。

错误代码

如果返回以下错误代码,那么 pthread_mutex_getprioceilingpthread_mutex_setprioceiling 子例程将失败:
描述
[缺省值] prioceiling 参数请求的优先级超出范围。
[缺省值] mutex 参数指定的值不引用当前存在的互斥对象。
[ENOSYS] 此功能不受支持 (草稿 7)。
[ENOTSUP] 此功能与 checkpoint/restart 一起不受支持。
[EPERM] 调用者没有特权在严格符合环境变量 XPG_SUS_ENV=ON的标准的环境中执行操作。

由于下列其中一个错误, pthread_mutex_setprioceiling 子例程可能失败:

描述
无法恢复 无法恢复互斥对象的受保护状态。
EOWNERDEAD 互斥对象是一个坚固的互斥对象,拥有互斥对象的线程的进程在持有互斥对象锁时终止。