Re: Re: about linux kernel thread

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

 



Hello Hsieh...

> I think my question should be:
> In linux, a thread seems to be implemented as a light-weight process,
> right?

Yes. it is called "light weight" because:
a) The time needed to create a thread is faster than creating a complete 
process. The reason is because thread shares some resource with its 
parent, usually the process address space and open files, so during the 
thread creation stage, those property are simply marked as shared.

b) Still related with (a), since likely thread doesn't have its own 
process address space (only user mode stack), context switch between 
thread's parend-thread itself and thread-in-the-same-thread-group 
happen faster. No need to reload the CR3 register to point to the new 
page global directory, thus saving the effort to do TLB flush

> if so, a kernel thread is a process from the view point of a
> scheduler. 

Correct. 

>then, *Is there any popular kernel thread(such as
> ksoftirqd,keventd) belonging to a real-time process?? *

I'll try to rephrase. Maybe you mean "kernel thread being scheduled as 
real time process"? AFAIK there isn't. IMHO, the reason why kernel 
thread isn't scheduled as real time process is the fact it is created 
to do something in "deferred style". By "deferred" here means "i 
(kernel) am not in hurry, so take your time". That's why you will 
likely see kernel thread is set in nice -19.

But, nothing prevent you to set kernel thread later as real time 
process.

> and
> *how is the kernel thread scheduled?use the same schedule primitive
> such as nice and count and the same time sharing algorithm ?? or
> there's another scheduler dedicated to schedule kernel thread??  *

Completely identical like how the scheduler manage normal process.

> > this makes the 3 kernel-level threads able of doing 3 blocking
> > calls while user-level threads are not .. cause calling a blocking
> > operation from a user-level thread will end to blocking the whole
> > process owning them

IMHO, that is true if the scheme is M:1, that is many user level threads 
are managed by single kernel level thread. IIRC, in NPTL, it is 1:1, so 
when a thread blocks, other is still able to run. CMIIW

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