0

if a process sets the SIGALARM signal by executing alarm(10). Meaning in 10 seconds the SIGALARM will be sent by operating system.

What happens if there is a context switch - will the system still send the signal regardless of the context switch? or will it return to the process and wait until it has run (in total) for 10 seconds and only then send the signal?

2

alarm() counts real time, the text in POSIX states this clearly even though the Linux man page isn't explicit about that. Hence, the timer will run regardless of if the process is running or not. Usually, the signal would wake up the process if it was sleeping, but the OS might still decide not to actually run the process, if there are other, higher priority processes that need to run.

There's also setitimer(), which can provide a timer that only runs when the process is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.