2010-11-23 10:54:29     msleep() inside work queue

Document created by Aaronwu Employee on Aug 23, 2013
Version 1Show Document
  • View in full screen mode

2010-11-23 10:54:29     msleep() inside work queue

Dimitar Penev (BULGARIA)

Message: 96140   

 

Hi Guys,

 

I have pretty basic question related with the work queues in Blackfin uClinux.

 

I run an Interrupt service routine (on our BF532 custom hardware) connected to the events from the CPU SPORT. 

Inside the ISR the code 'shedue_work'  (once per minute) (using work queue techniques) for later execution - 'bottom half'.

In the bottom half function we have some pretty long msleep() functions as we need few timeouts up to 5 seconds.

 

Everything seems to work as expected but during those 5 seconds timeouts we get the serial console blocked (no shell prompt, no echo from the serial console). After each timeout we get all the characters we have entered during the timeout echoed back.

 

The 'top' command doesn't report increased CPU utilization during the timeouts and the SSH connection seems not affected.

I am wondering if my bottom half sleeps properly without blocking the kernel and why my serial console (bfin-uart) is affected of those msleep() invocations?

 

I'll appreciate anyone comments related with this.

Dimitar

QuoteReplyEditDelete

 

 

2010-11-23 21:36:51     Re: msleep() inside work queue

Aaron Wu (CHINA)

Message: 96146   

 

maybe you can share us some sample code showing how you actually get the job done.

QuoteReplyEditDelete

 

 

2010-11-23 22:33:40     Re: msleep() inside work queue

Aaron Wu (CHINA)

Message: 96149   

 

Also you may try if the delayed version of the schedule_work, like schedule_delayed_work will help in your case, which is based on the softirq timer instead of the sleep.

QuoteReplyEditDelete

 

 

2010-11-23 22:41:00     Re: msleep() inside work queue

Sonic Zhang (CHINA)

Message: 96150   

 

Why do you call msleep in walk queue? callbacks in walk queue are run by a kernel thread, if you sleep in one callback, you may block other callback from running. Start a timer of  5 seconds instead.

QuoteReplyEditDelete

 

 

2010-11-23 22:54:40     Re: msleep() inside work queue

steven miao (CHINA)

Message: 96151   

 

You can try to create a single thread workqueue to do bottom half instead of using the global workqueue.

 

create_single_thead_workqueue()

 

use queue_work() to enqueue or queue_delayed_work() to enqueue a delayed work

QuoteReplyEditDelete

 

 

2010-11-24 04:20:22     Re: msleep() inside work queue

Dimitar Penev (BULGARIA)

Message: 96171   

 

Hi Guys,

 

Thank you for the ideas. I will try them. Let me put my code so my question is better defined: 

 

static void work_interrupt_processing(struct work_struct *test);

static DECLARE_WORK(work_interrupt, work_interrupt_processing);

 

//This function is called each 1ms from the SPORT DMA interrupt

void interrupt_processing(void) {

        ...

        schedule_work(&work_interrupt);

}

 

//Bottom half

static void work_interrupt_processing(struct work_struct *test) {

...

//Here once per 60000 bottom_half invocations (once in 1 minute) we need 5sec delay.

//Up to now I have tested two variants but both are blocking my serial console

//Case 1

msleep(5000);

 

//Case 2

set_current_state(TASK_INTERRUPTIBLE);

         schedule_timeout(5*HZ);

...

}

 

 

>Why do you call msleep in walk queue? callbacks in walk queue are run by a kernel thread, if you sleep in one callback, you may block other callback from running. Start a timer of  5 seconds instead.

 

Thanks Sonic.  Which function do you suggest actually? Should I loop inside the bottom half function until the timer expires or I have misunderstood your suggestion?

 

Thank you!

Dimitar

Attachments

    Outcomes