Re: Doubt in bottom halves.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello Vijay....

>  I am sorry i was not able to present my requirement clearly..infact
> of the two options that u mentioned,
> the 1st one is wat i require..If i get 5 interrupts, then i want the
> tasklet to get executed 5 times.Since this is the
> requirement, the linked list implementation doesnt solve the purpose.

OK....sounds like what you are trying to do is similar with how timer's 
softirq try to catch up the running clock. The popular term is clock 
drift.

before I am going to explain a little idea, please try this simple test. 
Create a kernel module that declare and schedule tasklet. Try to 
schedule a simple tasklet 4-5 times in a row and inside the handler, do 
something that you plan to do on your real tasklet. From there, 
watch...is that tasklet executed 5 times or not? If it is....merry 
Christmast :) No need to sweat...if it isn't....let's continue...

In summary, here is the idea you can use. WARNING: UNTESTED!!

1. declare a global counter. You can use "int", "long" or whatever you 
want. Declare it as volatile so it won't be cached on CPU register 
during certain interval. let's name it "actual_interrupt_counter". 
Declare another global counter and name it "current_tasklet_counter". 
Initialize both as 0 somewhere....

2. Atomically increase the "actual_interrupt_counter" everytime your 
handler is called.

3. Schedule your tasklet as usual. 

4. Your tasklet handler will be executed (sooner or later) . Now assume 
this is the first time your tasklet handler is called and also the 
first time your interupt handler is called. So 
"actual_interrupt_counter" is 1 and "current_tasklet_counter" is 0. 
Just before the end of handler's function, atomically increase the 
"current_tasklet_counter"...and then compare it with 
"actual_interrupt_counter""

If they are equal or "current_tasklet_counter" is greater (which is 
unlikely,but who knows? :) ), just exit the function. If 
"current_tasklet_counter" is less, re-schedule your tasklet. 

For initial test, set the maximum limit of "current_tasklet_counter", 
e.g 100. So whenever it hit 100, it won't be scheduled anymore. This is 
intended to prevent unlimited scheduling caused by coding mistake 
somewhere..

Hope it helps and let me us know if the idea works....

regards

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux