在Linux中,POSIX可靠信号和POSIX实时信号之间有什么区别? [英] What is the difference between POSIX reliable signals and POSIX real-time signals in Linux?

查看:180
本文介绍了在Linux中,POSIX可靠信号和POSIX实时信号之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了使用信号的手册页 人7信号,在这里我看到两种信号.所以,我有一个问题,

I read the man page of a signal using man 7 signal where I see two types of signal. So, I have question,

在Linux中, POSIX可靠信号 POSIX实时信号有什么区别?

What is the difference between POSIX reliable signals and POSIX real-time signals in Linux?

推荐答案

这些天,最好将它们表述为普通信号语义与实时信号语义.

These days, it might be better to phrase these as ordinary signal semantics versus realtime signal semantics.

在某些早期的UNIX系统中,信号不可靠,因为它们可能会丢失",因为没有阻止信号(使信号处于待处理状态)的功能.例如,如果信号刚好在检查之后但在 pause()之前到达,则在检查信号处理程序设置的wake_up_flag后要调用 pause()的代码可能会错过唤醒指令. ).信号阻止和 sigpause() 是对这种情况的可靠改进.

In some early UNIX systems, signals were unreliable in that they could be "lost", because there was no facility to block signals (to keep them pending). For example, code about to call pause() after checking a wake_up_flag set by a signal handler might miss the wake up instruction if the signal arrived just after the check but before the pause(). Signal blocking and sigpause() are reliable improvements to this situation.

此外, signal()的语义意味着用户定义的信号处理程序在进入处理程序后将重置为SIG_DFL.因此,通常的技术是立即将用户定义的处置方式重新安装在信号处理器内.但是,由于无法阻止信号,这意味着在竞争状态下,可能会再次发信号通知程序并遭受SIG_DFL的后果.在现代系统中, sigaction() 可靠地解决了这种情况.

Additionally, the semantics of signal() meant that a user-defined signal handler was reset to SIG_DFL upon entry into the handler. The usual technique, then, was to immediately re-install the user-defined disposition inside the signal hander. However, since signals could not be blocked, that meant that there was a race condition in which a program could be signaled again and suffer the consequences of SIG_DFL. In modern systems, sigaction() addresses this situation reliably.

因此,可靠"的信号是当今我们大多数人所认为的普通信号语义. (有关更多信息,我建议使用Stephens和Rago的 UNIX环境中的高级编程,特别是第10.4节不可靠的信号")

So, "reliable" signals are what most of us these days think of as ordinary signal semantics. (For more information here, I'd recommend Advanced Programming in the UNIX Environment by Stephens and Rago, specifically § 10.4 "Unreliable Signals")

POSIX实时信号比普通信号增加了一些功能例如,用于应用目的的新信号范围(SIGRTMIN ... SIGRTMAX),将待处理信号排队的功能以及使用信号传递数据字的功能.

POSIX realtime signals add a few features over ordinary signals, for example, a new range of signals for application purposes (SIGRTMIN ... SIGRTMAX), the ability to queue pending signals, and the ability to deliver a word of data with a signal.

这篇关于在Linux中,POSIX可靠信号和POSIX实时信号之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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