From: "Veda N" <veda74@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: wait interruptible does not work
Date: Wed, 9 Apr 2008 23:03:58 +0530 [thread overview]
Message-ID: <a5eaedfa0804091033t1365f3a2jf1f08ab257cd4e2b@mail.gmail.com> (raw)
I am having a kernel thread that waits on a completion object.
I am also having an ISR that wakes up the thread when ever an interrupt occurs.
The thread calls wait_completion_interruptible and waits for "completion" event.
What is happening is Even though i get the interrupt - The ISR calls 'complete'
The Thread does not wakeup.
I dont know why?.
I notice that i replaced wait_completion_interruptible with
wait_completion_timeout.
What happens is i keep getting the messages. As soon as the ISR
triggers the completion event. The threads stops/gets killed.
I dont know whats happening.
Could anyone help me on this.
Appending my code
Regards,
veda
#include <linux/module.h>
#include<linux/init.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
#include <asm/arch/gpio.h>
#include <linux/delay.h>
MODULE_AUTHOR("Newbee");
MODULE_DESCRIPTION("Wait Interruptible Demo Driver");
static int r_init(void);
static void r_cleanup(void);
module_init(r_init);
module_exit(r_cleanup);
static int information = 0x100;
static int id = 99;
static struct completion touch_completion;
static struct completion thread_comp;
struct task_struct *kthread;
int printmsgd(void *param);
static irqreturn_t attn_isr( int irq, void *info)
{
printk ("Got an Interrupt\n");
complete(&touch_completion);
}
static int r_init(void)
{
int retval;
init_completion(&touch_completion);
init_completion(&thread_comp);
if(omap_request_gpio( 140 ) < 0)
{
printk("Error: failed to request gpio\n");
}
printk ("interrupt mode...\n");
omap_set_gpio_direction( 140, 1);
if(( retval = request_irq(OMAP_GPIO_IRQ(140), attn_isr,
IRQF_TRIGGER_LOW, "test-irq", &information )))
{
printk ("Error: Unable to do request irq\n");
return -1;
}
kthread = kthread_run(&printmsgd, &id, "printmsgd");
printk ("kthread run:%x\n", kthread);
return 0;
}
static void r_cleanup(void)
{
complete(&touch_completion); /* Kick the thread awake */
if (kthread) wait_for_completion(&thread_comp);
return ;
}
int printmsgd(void *param)
{
int ret;
// daemonize("printmsgd");
while (!kthread_should_stop()) {
ret = wait_for_completion_interruptible(&touch_completion);
printk ("printmsgd says hi:%d\n", ret);
}
complete_and_exit(&thread_comp, 0);
}
reply other threads:[~2008-04-09 17:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=a5eaedfa0804091033t1365f3a2jf1f08ab257cd4e2b@mail.gmail.com \
--to=veda74@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome