From: "Luong Ngo" <luong.ngo@gmail.com>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Sleeping thread not receive signal until it wakes up
Date: Wed, 7 Mar 2007 11:28:21 -0800 [thread overview]
Message-ID: <1b2aacd80703071128v5227382do2277d0b85ca3b20c@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0703070813070.12338@chaos.analogic.com>
Hi Dick,
Thanks for your response. In my ioctl in the kernel, I use
interruptible_sleep_on to sleep on a queue and will be wake up by the
the ISR routine when interrupt happens, so isn't
interruptible_sleep_on supposed to be interruptable, from its name? I
am using kernel 2.6.14.
Thanks again,
LNgo
On 3/7/07, linux-os (Dick Johnson) <linux-os@analogic.com> wrote:
>
> On Wed, 7 Mar 2007, Luong Ngo wrote:
>
> > 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
> > -
>
> Later versions of the kernel lock the kernel when an ioctl() is
> entered. This means that if you sleep in the ioctl(), nothing
> will get scheduled.
>
> You can do the following (possibly unsafe) in your ioctl():
>
> int locked = kernel_locked();
>
> ......... code
> ......... code
>
> if(locked) // Before sleeping section
> unlock_kernel();
> .......... sleeping code
> if(locked) // After sleeping section
> lock_kernel();
>
>
>
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.6.16.24 on an i686 machine (5592.71 BogoMips).
> New book: http://www.AbominableFirebug.com/
> _
> \x1a\x04
>
> ****************************************************************
> The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.
>
> Thank you.
>
next prev parent reply other threads:[~2007-03-07 19:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-07 5:31 Luong Ngo
2007-03-07 13:19 ` linux-os (Dick Johnson)
2007-03-07 19:28 ` Luong Ngo [this message]
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
[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 ` 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b2aacd80703071128v5227382do2277d0b85ca3b20c@mail.gmail.com \
--to=luong.ngo@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®