简体   繁体   English

信号处理程序与事件处理程序

[英]signal handler vs event handler

Recently in an interview they asked me to point out the difference between signal handlers and event handlers. 最近在一次采访中,他们要求我指出信号处理程序和事件处理程序之间的区别。 I have never encountered event handlers in Linux but after searching with Google I find event handlers are present in Windows. 我从未在Linux中遇到过事件处理程序,但是在使用Google搜索之后,我发现Windows中存在事件处理程序。

I just want some more information regarding this question. 我只想了解有关此问题的更多信息。 Any information is most welcome. 任何信息都是最欢迎的。

I found that user have to write event handler function in order to capture events while default signal handlers are provided by kernel for the program. 我发现用户必须编写事件处理程序函数才能捕获事件,而内核为程序提供了默认信号处理程序。

Event handlers take care of the events external to the program like keyboard interrupt, mouse click etc. Event handlers would be polling continuously on a particular slot for the event to happen. 事件处理程序负责程序外部事件的处理,例如键盘中断,鼠标单击等。事件处理程序将在特定的插槽上连续轮询事件的发生。 So here it might consume the CPU life cycles. 因此,这里可能会消耗CPU生命周期。

Signal handlers also used for interprocess communication between two process. 信号处理程序还用于两个进程之间的进程间通信。 User can define their own signal handler for the process to handle particular signals. 用户可以为过程定义自己的信号处理程序,以处理特定的信号。 In signal handling mechanism I don't think any CPU cycles are consumed unnecessarily. 在信号处理机制中,我认为不会不必要地消耗任何CPU周期。

Please correct me if a not heading in the correct way. 如果标题不正确,请纠正我。

我认为特定于事件的信号处理程序起源于内核,而事件处理程序是信号处理程序的一种更抽象的版本,并且包括“任何”类型的事件(单击事件,网络事件,信号等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM