Re: pthread creates one extra thread

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

 



Hi Shesha Sreenivasamurthy ,

I am sorry if I am wrong.
I tested your code. But I could
see only one process with the name 
"thread" with "two threads". I think
u might be mistaken.

And when I included one more thread
in the code, I could see the total number 
threads is three. So I think its working
fine.
 
Note:
For ps I used additional options 'm'.
i.e, ps -efm

Regards,
Shine Mohamed

On Tuesday 06 January 2004 03:21, Shesha Sreenivasamurthy wrote:
> Hi All,
>   I Have the following small code for creating threads.
>
> #include <stdio.h>
> #include <pthread.h>
>
> void my_func_1 (void *arg) {
>         while(1) {}
>  }
>
>
> int main() {
>   pthread_t thread_1;
>   pthread_create(&thread_1, NULL,(void*)& my_func_1, NULL);
>
>   while(1) { }
>   exit(0);
> }
>
> gcc -lpthread -o thread test.c
>
> I expect to have created 2 threads. But when I do ps -ef | grep thread I
> see 3.
> Say If i use pthread_create and create one more thread, then instead of
> 3 I see
> 4. Does any one know what is the reason for this behavior?
>
> Any help is highly regarded.
>
> -Shesha
>
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/


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