Re: kthread_create() vs tasklet

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

 



On Tue, May 13, 2008 at 5:02 PM, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote:
>
> On Tue, May 13, 2008 at 4:40 PM, Rajat Jain <Rajat.Jain@xxxxxxxxxxxx> wrote:
>  > Hi,
>  >
>  >  >>
>  >  >>  >
>  >  >>  > On Wed, May 7, 2008 at 12:55 PM, Peter Teoh
>  >  >> <htmldeveloper@xxxxxxxxx>  > wrote:
>  >  >>  >> Not sure why....but under the drivers directory, u can see a lot
>  >  >> more  >> tasklet than kthread_create().
>  >  >>  >>
>  >  >>
>  >  >>  Huh? I'm not sure if I understand this right ... But I thought they
>  >  >> are  completely different things (rather than two comparable items).
>  >  >>
>  >  >>  kthread_create() is to create a kernel thread (A thread that'll
>  >  >> always  execute in kernel mode and will have no user context). Where
>  >  >> as tasklet  is a mechanism to implement bottom halves - hence they
>  >  >> are generally  "scheduled" to be executed in ISRs. They are run upon
>  >  >> return from IRQ or  by ksoftirq.
>  >  >>
>  >  >>  Did I understand the question right?
>  >  >>
>  >  >>  Rajat
>  >  >>
>  >  >
>  >  > Yes, u are right.   And my questions rightfully may not have any
>  >  > specific answer....case by case basis.   Specifically I am looking for
>  >  > rewriting the tasklets as kernelthreads, if possible.   Tasklets does
>  >  > not migrate from CPU to CPU, right?   whereas kernelthread do, so it
>  >  > may provide better load balancing?
>  >
>  >  Yes, but you really won't write a code that needs load balancing, in a
>  >  tasklet. In fact you would often want the tasklet to run on the same CPU
>  >  (per-CPU variables, better cache hit etc.). Tasklets are a bottom half
>  >  mechanism to shorten the ISR and yet be able to respond to interrupts
>  >  quickly.
>  >
>  >
>  >  >
>  >  > Correct me if wrong...thanks.
>  >
>  >
>  >  Kernel threads aren't meant to be a replacement for tasklets. They have
>  >  completely different characteristics and objectives. And there are
>  >  restrictions that apply to tasklets (no sleeping etc.).
>  >
>  >  Although work queues (another bottom half mechanism) and kernel threads
>  >  can share some amount of common things, since work queues are in process
>  >  context.
>  >
>  Sorry, just check the source code, wrong comparison :-).
>
>  kernel_thread() called do_fork() and do_fork() (kernel/fork.c) will
>  create an image copy....wow...too much overhead..
>
>  A better comparison will be tasklet vs workqueue.....sorry for
>  that...I think that should be better:
>
>  http://lkml.org/lkml/2007/6/22/6
>

And the following is a summary by Ingo on work queue concept:

http://www.cs.helsinki.fi/linux/linux-kernel/2002-39/0176.html

i'd like to introduce the following interfaces:

- create_work_queue(wq, handler_fn)

- destroy_work_queue(wq)

- queue_work(wq, work_fn, work_data)

- flush_work_queue(wq)

this is an extension of the keventd concept. A work queue is a simplified
interface to create a kernel thread that gets work queued from IRQ and
process contexts. No more, no less.

BTW....what are the difference betwen keventd and tasklet?   Or with
Workqueue (since Ingo made this extension remark)?

If it is getting work queued from IRQ, so it means that tasklet are
handling stuff that CANNOT be queued, right?   And btw, can work queue
be assigned to different processor, or it is automatically balanced
(ie, different CPU will pull work from the work queue for execution?)

Thanks for the sharing....CONFUSED...:-).


-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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