c++ - signal() : any performance impact? -
i need catch sigabrt, sigsegv , sigill
present user proper critical error message when out of control fails , program need exit.
however program lot of realtime computing, performance important.
does signal()
( http://www.cplusplus.com/reference/csignal/signal/ ) cause performance loss
(some sort of constant monitoring ?) or not @ (only triggered when exception happen, no performance lost otherwise).
edit: software runs on windows (7 , higher) , os x (10.7 , higher).
if time critical process catches signals, there no "special" time wasting. indeed, kernel holds table of signals , actions process has walk through if signal send. every way of sending message process or invoking handler needs time. message queue or waiting on "flag" have same "waste".
but using signals can have other implications should mentioned. every system call can interrupted if signal arrives. return value call eintr
. if have many signals pass process, may slow down application lot, because have check eintr
go again system call. , every system call bit expensive. looping lot on system calls eintr
return values can bad design.
but question, sigabrt
, sigsegv
, sigill
. these signals typically used seldom exceptions. don't fear use them needed. avoid using these signals own ipc. can done bad design. user ipc there better signal names , better methods.
in short: catching exception signals, don't have time critical issues here.
Comments
Post a Comment