I don’t understand usage for these: msleep and msleep_interruptible … I know one interruptible and other is non-interruptible but couldn’t find certain usage where I can actually see. I tried calling thread with function to msleep and print say “Hello!” and msleep(msleep_interruptible) after that, but couldn’t see any difference. Can anyone help me with that, may be with example?
I don’t understand usage for these: msleep and msleep_interruptible … I know one interruptible
Share
The difference is in what happens when a signal (e.g. SIGINT) is raised and you set a signal handler for that signal.
msleepgoes back to sleepmsleep_interruptiblereturns to the caller (with a non-zero value representing the sleep time remaining).An example of an interruptible sleep:
It slept for 3 seconds instead of 5 because it got interrupted by a handled signal. The other version would print the following:
In other words, the signal handler gets called either way, but one version doesn’t return even if a signal comes in.