我怎么能知道一个Linux系统调用是线程安全的? [英] how can i know whether a linux syscall is thread safe?

查看:954
本文介绍了我怎么能知道一个Linux系统调用是线程安全的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux标志的一些功能线程安全的_r(例如gmtime_r)
但是大部分的系统调用都没有被标记,也不能在手册页提及。
所以我的问题是:
我怎样才能konw一个Linux系统调用是线程安全的?
谢谢!

some functions in linux mark "thread safe" by _r (e.g. gmtime_r ) but most of the syscalls are not be marked and also not mentioned in manpages. So my question is : How can i konw whether a linux syscall is thread safe? Thank you!

推荐答案

我觉得你的意思是库函数系统调用应,凭借对线程的内核端数据进行操作,是线程安全的。

I think you mean "library functions"; syscalls should, by virtue of operating on the thread's kernel-side data, be thread-safe.

答案是:检查有问题的功能的手册页。是专门为这是非重入函数提供的_r变种,这意味着传递给他们额外的参数进行了静态声明,并在非改装 - _ R版

And the answer is: check the manual pages for the functions in question. The "_r" variants are provided specifically for functions which were non-reentrant, meaning that the extra parameters passed to them were statically declared and modified in the non-"_r" versions.

大多数的glibc应该是,IIRC,线程安全的,但你的总是的需要检查手册页;或者,如果你不相信这些,在code本身。有没有银弹将您删除的理解,你是对编程接口的责任。

Most of glibc should be, IIRC, thread-safe, but you always need to check manual pages; or, if you don't trust those, the code itself. There's no silver bullet that will remove from you the responsibility of understanding the interfaces which you are programming against.

这篇关于我怎么能知道一个Linux系统调用是线程安全的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆