Re: pthread creates one extra thread

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

 



> >     The linux kernel does not support the concept of threads (there are
> > no thread system calls). the only system calls for achieving this
> > somultaneous mechanism would be fork() and exec(). The pthreads library
> > used these system calls.
>
> you are mistaken.
> threads (roughly speaking) are two active entities, running in the same
> address space, so using exec or fork can not (EVER) achieve such
> behavior.
> pthread uses the clone system call, which does implements
> threads (of some kind, anyway).
>
> (actually, pthread uses clone with the following flags:
>  flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND. look at man 2 clone
> for explanations.)
>

yes what nir said is right since fork or exec create a seperate process
context, whereas two threads
run in a single process context both having access to the memory of the
process that creates them.
Hence, i think creating threads using exec() and fork() is not possible.


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