位置:首頁 > 其他技術 > Unix/Linux係統調用 > get_robust_list()函數 Unix/Linux

get_robust_list()函數 Unix/Linux

get_robust_list, set_robust_list - 獲取/設置強健futexes的清單

內容簡介

#include <linux/futex.h> 
#include <syscall.h> 

long get_robust_list(int pid, struct robust_list_head **head_ptr,                          size_t * long set_robust_list(struct robust_list_head *head, size_t len);

描述

The robust futex implementation needs to maintain per-thread lists of robust futexes which are unlocked when the thread exits. These lists are managed in user space, the kernel is only notified about the location of the head of the list.

get_robust_list returns the head of the robust futex list of the thread with TID defined by the pid argument. If pid is 0, the returned head belongs to the current thread.head_ptr is the pointer to the head of the list of robust futexes. The get_robust_listfunction stores the address of the head of the list here. len_ptr is the pointer to the length variable. get_robust_list stores sizeof(**head_ptr) here.

set_robust_list sets the head of the list of robust futexes owned by the current thread to headlen is the size of *head.

 

返回值

The set_robust_list and get_robust_list functions return zero when the operation is successful, an error code otherwise.

 

錯誤

The set_robust_list function fails with EINVAL if the len value does not match the size of structure struct robust_list_head expected by kernel.

The get_robust_list function fails with EPERM if the current process does not have permission to see the robust futex list of the thread with the TID pidESRCH if a thread with the TID pid does not exist, or EFAULT if the head of the robust futex list can’t be stored in the space specified by the head argument.

 

實際應用信息

一個線程隻能有一個強大的 futex 清單,因此希望使用該功能的應用程序應該使用的glibc提供強大的互斥體。

係統調用是唯一可用於調試目的,不正常操作所需的。

這兩個係統調用是不提供給應用程序的功能,他們可以使用 syscall(3)函數被調用。

 

另請參閱