Re: processes, threads and thread groups

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

 



On Thu, 3 Apr 2008, Mulyadi Santosa wrote:

> Hi
>
> On Wed, Apr 2, 2008 at 9:52 PM, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
> >
> >   just to make *absolutely* sure that i'm using the terminology
> >  correctly, here's how i understand processes and threads:
> >
> >  * threads are, of course, just another type of process -- these are
> >  commonly referred to simply as "tasks"
>
> yup, with additional note: threads likely share something e.g memory
> space, open files and so on...

yes, i'm pretty versed in the creation of threads, having perused the
code and noticed how you can use creation flags to identify what gets
shared between threads.

> > * all processes have a process ID (PID), but related threads
> > (those in the same multithreaded application) have the *same* PID
> > as returned by getpid().  this is the PID of the "thread group
> > leader" -- the initial thread in that application.

> yeah correct

i did notice that, if you examine the layout of "struct task_struct"
in sched.h, there are the two data:

        pid_t pid;
        pid_t tgid;

the thread's personal PID and the thread's thread group leader ID, and
a call to getpid() actually returns the value of tgid -- which it
should, of course, since that's the POSIX definition of "PID", at
least the way i read it.

> >  * only the thread group leader of a multithreaded application is on
> >  the system-wide task list.  the additional threads in that thread
> >  group are on a separate list managed by the thread group leader.

> uhm, i don't think so. AFAIK in new CFS scheduler, they are just
> treated "differently" to avoid excessive scheduling latency between
> them.. something you probably need because in user space programming
> we usually expect fast switching between threads.

i'm inclined to agree with you here -- i was working off of a diagram
in some notes i was given, and that diagram seemed to suggest that
only the thread group leader was on the system-side task list.  but
that doesn't make any sense so i'm just going to assume the diagram is
misleading and that *all* threads are on the task list.  thanks.

rday
--

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
    Have classroom, will lecture.

http://crashcourse.ca                          Waterloo, Ontario, CANADA
========================================================================

--
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