All of lore.kernel.org
 help / color / mirror / Atom feed
* Sleeping thread not receive signal until it wakes up
@ 2007-03-07  5:31 Luong Ngo
  2007-03-07 13:19 ` linux-os (Dick Johnson)
  2007-03-07 18:09 ` Sergey Vlasov
  0 siblings, 2 replies; 20+ messages in thread
From: Luong Ngo @ 2007-03-07  5:31 UTC (permalink / raw)
  To: linux-kernel

Hi all,

I am having this problem. I have a process with 2 threads created. One
of the thread will keep calling IOCTL  to get information from the
kernel and will be blocked if there is no new information. If there is
information retured, the thread will be checked to see if any error
happens and trigger an action. Since we have no way to know if the
error is gone (Hardware provides no signal), so what we do is when
trigger an action for the error, we will set an timer using alarm()
and register a SIGALRM handler in the thread by using sigaction. After
setting the alarm, the thread will loop back and call IOCTL, which
could cause it to be put to sleep. The problem is the SIGALRM handler
does not receive the SIGALRM while the thread is being blocked by
IOCTL. And if we generated some event so that the IOCTL is returned
with new information, the SIGALRM handler is invoked right away.
However, as I read the manual, which says a thread/process should be
waken up even when it sleeps if there is a signal delivered to it. Am
I right?
One thing I don't know it mattters or not is that I am not using
sigwait to block the process and wait for signal because the thread
need to go back to the IOCTL call and be slept on that. So I used
sigaction to register the signal handler in hope that this handler wil
be invoked by the kernel when there is an SIGALRM delivered to the
thread.
Could anyone tell me if I did something wrong and what is the correct
way to achieve this task? I tried to avoid creating another thread
which will call sigwait and block until the IOCTL thread send it
explicitly a signal because I want to use timer.


Thank you in advance,
LNgo

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2007-03-10 10:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.kb3wuhac4W+1DqK61+sKe9uZwto@ifi.uio.no>
     [not found] ` <fa.cyXmbtXvYymKHdI0rEXZCxyk+KE@ifi.uio.no>
     [not found]   ` <fa.zPDT1vfJF5MjVXXQH/l+YSaLl84@ifi.uio.no>
     [not found]     ` <fa.HmQN7RhZNBRsiJYADMOsY8DL67k@ifi.uio.no>
     [not found]       ` <fa.PDmHwxZ3arhmED5SLuEONyxUlz4@ifi.uio.no>
     [not found]         ` <fa.ygLhZcCLgDxnwAYYVse/Xshr9IE@ifi.uio.no>
2007-03-09  1:10           ` Sleeping thread not receive signal until it wakes up Robert Hancock
2007-03-09  3:24             ` Luong Ngo
2007-03-09  3:45               ` Parav K Pandit
2007-03-10  0:10                 ` Luong Ngo
2007-03-10  8:22                   ` Sergey Vlasov
2007-03-10 10:54                     ` Luong Ngo
2007-03-07  5:31 Luong Ngo
2007-03-07 13:19 ` linux-os (Dick Johnson)
2007-03-07 19:28   ` Luong Ngo
2007-03-07 20:08     ` linux-os (Dick Johnson)
2007-03-07 21:03       ` Lee Revell
2007-03-08  0:40         ` Luong Ngo
2007-03-08  0:28       ` Luong Ngo
2007-03-08 13:01         ` linux-os (Dick Johnson)
2007-03-08 13:53           ` Thomas Gleixner
2007-03-08 22:52             ` Luong Ngo
2007-03-09 14:58               ` Sergey Vlasov
2007-03-09 19:50                 ` Luong Ngo
2007-03-07 20:20   ` Jan Engelhardt
2007-03-07 18:09 ` Sergey Vlasov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.