Re: Schedule() call in driver context.

2010-02-23 Thread StephanT
Hi Joel, because timers execute in interrupt context, not process context. What do you mean exactly? My understanding is the kernel uses interrupts to count the time and to trigger timer routines - but these routine are executed in the context they were registered. A timer created by a

Re: Schedule() call in driver context.

2010-02-23 Thread Greg Freemyer
On Tue, Feb 23, 2010 at 1:16 PM, StephanT stman937-linew...@yahoo.com wrote: Hi Joel, because timers execute in interrupt context, not process context. What do you mean exactly? My understanding is the kernel uses interrupts to count the time and to trigger timer routines - but these

Re: Schedule() call in driver context.

2010-02-23 Thread Joel Fernandes
Hi Greg, Instead there is an intermediary context that I don't think you've taken into account. I believe timers are also invoked in this intermediary context.  ie. When a timer invokes a function you can't trust the process / task structures to relate to your original userspace app. I

Re: Schedule() call in driver context.

2010-02-23 Thread Joel Fernandes
Like for example when a write() happens, this doesn't have to necessarily go all the way till the disk immediately, instead its Ofcourse, unless the file is opened in O_DIRECT mode -Joel -- To unsubscribe from this list: send an email with unsubscribe kernelnewbies to ecar...@nl.linux.org

Re: Schedule() call in driver context.

2010-02-23 Thread Greg Freemyer
On Tue, Feb 23, 2010 at 2:09 PM, Joel Fernandes agnel.j...@gmail.com wrote: Hi Greg, Instead there is an intermediary context that I don't think you've taken into account. I believe timers are also invoked in this intermediary context.  ie. When a timer invokes a function you can't trust

Re: Schedule() call in driver context.

2010-02-23 Thread Joel Fernandes
My understanding is the kernel uses interrupts to count the time and to trigger timer routines - but these routine are executed in the context they were registered. A timer created by a process executes in process context. A driver registered timer executes in kernel context (not interrupt).

Re: Schedule() call in driver context.

2010-02-23 Thread Joel Fernandes
Hi Greg, I'm relatively new to this stuff but I think I will make some bold statements: With linux today, is there a specific process context (ie. kernel thread) associated with executing functions triggered by timers firing off? No, a timer being fired wouldn't be associated with any single

Re: Schedule() call in driver context.

2010-02-23 Thread StephanT
Hi Greg, Joel, You're missing a tier of complexity and I'm afraid I don't know the... Agreed 100% :-) My intent was not to discuss the whole linux driver topic but to understand the subtleties of using schedule() in linux drivers. This point of view I have to say, you guys you did an

Re: Schedule() call in driver context.

2010-02-23 Thread StephanT
Hi Joel, You need to be clear with yourself on the meaning and the types/differences of different contexts first, because its really confusing when you say kernel context (not interrupt). Could you, please be a little more specific about what is confusing? As this is learning ground it would

Re: Schedule() call in driver context.

2010-02-22 Thread Joel Fernandes
Hi Stephan, I'm no expert this is what I think: 1. What event awakes the process? Has the driver any way to control it? The kernel code executing on behalf of the process is usually waiting for some resource to become available, we sleep because we can't return from the middle and have to wait

Re: Schedule() call in driver context.

2010-02-22 Thread Joel Fernandes
Hi Greg, Thanks for your message. You're right that fewer kernels have this, I thought that since CONFIG_PREEMPT documentation says its for low latency desktops (so that processes don't wait and the UI is more responsive), most desktop distros would have it enabled. But even on my Ubuntu 9.10

Re: Schedule() call in driver context.

2010-02-22 Thread Greg Freemyer
On Sat, Feb 20, 2010 at 2:01 AM, Joel Fernandes agnel.j...@gmail.com wrote: In fact the kernel is not interrupt-able in linux as I recall.  Thus a misbehaving driver that enters an infinite loop will hang the whole machine. ... Another way to ask your question is Why isn't the linux kernel

Re: Schedule() call in driver context.

2010-02-22 Thread StephanT
Hi Joel, 1. What event awakes the process? Has the driver any way to control it? The kernel code executing on behalf of the process is usually waiting for some resource to become available, we sleep because we can't return from the middle and have to wait till we get the resource. For

Re: Schedule() call in driver context.

2010-02-22 Thread Greg Freemyer
On Mon, Feb 22, 2010 at 2:37 PM, StephanT stman937-linew...@yahoo.com wrote: Hi Joel, 1. What event awakes the process? Has the driver any way to control it? The kernel code executing on behalf of the process is usually waiting for some resource to become available, we sleep because we

Re: Schedule() call in driver context.

2010-02-22 Thread StephanT
Hi Greg, driver context? Not really a kernel term to my knowledge. I'll assume you mean in a driver directly associated with a user space call. ie. Not in interrupt mode Sorry for the formulation. And yes I meant exactly what you suggesting. It is not at all uncommon to have access to

Re: Schedule() call in driver context.

2010-02-22 Thread Joel Fernandes
My understanding is in a driver: - use schedule() when waiting for kernel services. - use timers when waiting for the device. Hi Stephan, You got it all right except the fact that you cannot use a timer because timers execute in interrupt context, not process context. When your Process

Re: Schedule() call in driver context.

2010-02-20 Thread Mulyadi Santosa
Hi Stephan... Just sharing my humble thoughts... On Fri, Feb 19, 2010 at 4:39 AM, StephanT stman937-linew...@yahoo.com wrote: Hello all, Why would a linux driver call schedule() ? Basically, to relinquish a certain kernel code path and to switch to the other one (be it user mode or kernel

Re: Schedule() call in driver context.

2010-02-19 Thread Greg Freemyer
On Thu, Feb 18, 2010 at 4:39 PM, StephanT stman937-linew...@yahoo.com wrote: Hello all, Why would a linux driver call schedule() ? The LDD proposes this method to fight systems hangs caused by an infinite loop in the driver. In this case the schedule() call would be a workaround. I think

Re: Schedule() call in driver context.

2010-02-19 Thread Denis Kirjanov
Yeah, schedule() (and __sched prefixed) function call needed when we are waiting for some events. It would de wasteful to lose CPU cycles while checking condition what we are waiting for. So, instead we can just to tell the kernel to switch to another task, and wake up our task when waiting

Schedule() call in driver context.

2010-02-18 Thread StephanT
Hello all, Why would a linux driver call schedule() ? The LDD proposes this method to fight systems hangs caused by an infinite loop in the driver. In this case the schedule() call would be a workaround. I think better fix the infinite loop and abstain to call schedule()... I found more than