pthread and clone

pthread and clone

Post by Andrey Koubyche » Sat, 06 Jul 2002 22:51:19



Hello everyone,

I use Linux 2.4.4.
I had to write multithreaded plug-in for server that don't use pthreads. I
think this server uses some syscalls to make threads. I have noticed that
when my plug-in is called from context of server (non-pthread thread) , I
get many problems : getting errno locks, file descriptor opened in pthread
does not work in non-pthread, pthread_cond_timedwait never returns...
I know that threads in Linux is actually LWPs, but I actually don't really
care how Linux implements POSIX threads, I only worried why there is such a
big problems with it ? (this is actually rhetoric question, now serious
question.. ) Should I expect the same problems with pthreads in FreeBSD and
Solaris also ? Are there in those systems also "some native threads" and
pthreads conflicting ? Also, I don't want to blame or flame, I only want to
know the current trend, is this conflict in Linux solving currently
(improving threading) or it is left all like it is and we should not expect
something better ?

--
Best regards,
Andrey Koubychev

 
 
 

pthread and clone

Post by Paul Pluzhniko » Mon, 08 Jul 2002 22:47:39



> I use Linux 2.4.4.
> I had to write multithreaded plug-in for server that don't use pthreads. I

Most of your rant does not make any sense, but you *should not*
expect to be able to dynamically load a library that will create
threads into a non-multithread-built executable on any UNIX.

Cheers,
--
In order to understand recursion you must first understand recursion.

 
 
 

pthread and clone

Post by Andrey Koubyche » Tue, 09 Jul 2002 16:14:49


This server is multithreaded, it's name Real Server from RealNetworks. It
creates threads by its own way and support plugins. Particularty I have
problems with such plugin that uses pthreads.
If many my rants are senseless, then how to explain that when I want to
printf errno, program locks ?
Or that it forever locks in pthread_cond_timedwait ?
The same piece of code in separate exe works fine.

--
Best regards,
Andrey Koubychev

 
 
 

pthread and clone

Post by David Schwart » Tue, 09 Jul 2002 16:30:44



> This server is multithreaded, it's name Real Server from RealNetworks. It
> creates threads by its own way and support plugins. Particularty I have
> problems with such plugin that uses pthreads.
> If many my rants are senseless, then how to explain that when I want to
> printf errno, program locks ?
> Or that it forever locks in pthread_cond_timedwait ?
> The same piece of code in separate exe works fine.

> --
> Best regards,
> Andrey Koubychev

        Are you compiling with '-pthread'?

        DS

 
 
 

pthread and clone

Post by those who know me have no need of my nam » Tue, 09 Jul 2002 17:02:13


in comp.unix.programmer i read:

Quote:>I had to write multithreaded plug-in for server that don't use pthreads. I
>think this server uses some syscalls to make threads. I have noticed that
>when my plug-in is called from context of server (non-pthread thread) , I
>get many problems :

well duh.

Quote:>I know that threads in Linux is actually LWPs, but I actually don't really
>care how Linux implements POSIX threads, I only worried why there is such a
>big problems with it ?

`it' is not a problem -- your assumption is the problem, all platforms work
this way.  a threaded `plug-in' cannot be safely invoked by a non-threaded
application.  provide a non-threaded plug-in too.

--
bringing you boring signatures for 17 years

 
 
 

pthread and clone

Post by Andrey Koubyche » Tue, 09 Jul 2002 18:32:56


Quote:> Andrey Koubychev

> Are you compiling with '-pthread'?

yes,  -lpthread
Other keys are  -fPIC -DPIC -D_REENTRANT --permissive -shared

Creating threads itself works in exe and so, in exe it's just what I expect,
in .so not always.

Best regards,
Andrey Koubychev

 
 
 

pthread and clone

Post by Andrey Koubyche » Tue, 09 Jul 2002 18:38:13


Quote:

> `it' is not a problem -- your assumption is the problem, all platforms
work
> this way.  a threaded `plug-in' cannot be safely invoked by a non-threaded
> application.  provide a non-threaded plug-in too.

Maybe I have not clarified it, the server is multithreaded but on his own
way.
Plugin uses pthreads - we have conflict.
For example on win32 the same server and same plugin (using native
syncronization/threading mechanism ) works perfect.
thank you for attention to my problem

--
Best regards,
Andrey Koubychev

 
 
 

pthread and clone

Post by Paul Pluzhniko » Wed, 10 Jul 2002 00:04:51



> This server is multithreaded, it's name Real Server from RealNetworks. It
> creates threads by its own way and support plugins. Particularty I have
> problems with such plugin that uses pthreads.
> If many my rants are senseless, then how to explain that when I want to
> printf errno, program locks ?
> Or that it forever locks in pthread_cond_timedwait ?

The most likely explanation is that you have a bug in your program,
perhaps at the interface to the RealServer, or to pthreads.

Quote:> The same piece of code in separate exe works fine.

That is *often* the case with heap and stack corruption bugs ...


> Maybe I have not clarified it, the server is multithreaded but on his own
> way.

What do you mean? Does it use pthreads or does it use some other
threading mechanism? What is the 'ldd exe' output?

Quote:> Plugin uses pthreads - we have conflict.

Where is the conflict?

Quote:> For example on win32 the same server and same plugin (using native
> syncronization/threading mechanism ) works perfect.

You are using a different API on Win32. Therefore it is *different*
plugin on Win32.

What gives you confidence that you have completely understood POSIX
API and are using it correctly?

Cheers,
--
In order to understand recursion you must first understand recursion.

 
 
 

pthread and clone

Post by John Reise » Wed, 10 Jul 2002 08:39:36


 >>Are you compiling with '-pthread'?
 >>
 >
 > yes,  -lpthread
 > Other keys are  -fPIC -DPIC -D_REENTRANT --permissive -shared

"-pthread" (note no 'l') is different and better than "-lpthread".
There are differences at compile time, not just at static link time.
[Run with  "gcc -v -pthread ..." and see what you're getting.]

 
 
 

1. Linux clone() + pthreads library _problem_! Please, help!

Hello!

I tried to compile a simple program (by Linus Thorvalds) that demonstrates
using Linux clone() system call (used for creating threads-aka child
processes that can share stuff with it's parent).

After compiling with: 'gcc clone.c', and executing it -  everything is ok,
program runs fine - as expected.

Then I linked libpthread-0.8.so in the program with: 'gcc -lpthread clone.c',
but _didn't_ use any of pthreads functions, nor did I include
pthread.h in clone.c. Just linking! Running the program one can see it's
not working as in the first case (when libpthread.so is _not_ linked in).

Here's what happens:
child process that is normaly created and executed get's ZOMBIFIED right
after it is created, before it runs!

Did anyone come across this problem?
Does anyone have any idea at all why this happens?
Am I missing or doing something wrong?
Any ideas, advice, anything at all would be greatly appreciated!
Thanks for help!

Best regards,

                                Mario Zagar

P.S.

Here's the program output without libpthread.so linked in, and with it.
Also, there's some 'top' log of the processes being run:

program run WITHOUT libpthread linked in:
----------------------------------------
mother:  fd = 3
mother:  vm = 10
child:   got argument 3 as fd
child:   vm =5
mother:  vm = 5
mother:  child closed our file descriptor

top statistics:
--------------

PID USER     PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
========================================================================
1921 user      0   0   356  356   288 S       0  0.0  0.2   0:00 a.out
1922 user      0   0   356  356   288 S       0  0.0  0.2   0:00 a.out

++++

program run WITH libpthread linked in:
-------------------------------------
mother:  fd = 3
mother:  vm = 10
mother:  vm = 10

top statistics:
--------------

PID USER     PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
========================================================================
1877 user      0   0   412  412   328 S       0  0.0  0.3   0:00 a.out
1878 user      0   0     0    0     0 Z       0  0.0  0.0   0:00 a.out <defunct>

2. can't read boot floppy anymore!

3. pthread and clone function

4. inittab problems.

5. clone() or PThreads ???

6. Sparcstation 10 CPU Upgrades

7. Q: clone() and pthreads - I'm lost

8. Pleasant Linux adventures. NOT. Large HDD problem.

9. pthreads and clone

10. pthread vs clone/fork

11. Need advice on fork(), clone(), pthread() ...

12. pthread vs clone vs ?; setjmp and signals

13. clone(), pthreads, tasking GNAT?