[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Threading
From: |
Richard Frith-Macdonald |
Subject: |
Re: Threading |
Date: |
Sun, 1 Jul 2001 07:05:00 +0100 |
On Sunday, July 1, 2001, at 06:10 AM, Philip Knodle wrote:
Is it possible to mix C/pthreads and objc/NSThread code in a project?
I've
been looking at the code, and it looks like it is not possible. I
guess my
real question is *should* it be possible?
It is possible...
Let me be a bit clearer. It is possible to have C/pthread all by
itself in
a project. However, when the C code calls objective C code, the program
will seg fault. The objective C code has a some thread private
variables that
are not initialized
Does OPENStep say anything about this? My main concern is that if the
threading semantics of GNUStep change, then programs that work on
GNUStep
won't work on other implementation. This may be a a bad thing.
I doubt that the OpenStep spec says anything about it, but my
recollection
is that answers from NeXT used to be that it was a bad idea to try to mix
threads.
The standard API does not provide any mechanism for mixing thread models
safely.
The GNUstep base library adds two functions to the API -
GSRegisterCurrentThread() and GSUnregisterCurrentThread()
You can use these from your pthread code before and after
running GNUstep code, and they will set up the appropriate thread
variables for you.
I don't know of any equivalent in MacOS-X, but there is probably a
private API that does the same sort of job - unless it's built in to
their Java bridge directly, and not accessible from anywhere else
(you have to do something of this sort to lets Java threads work
with ObjC threads in GNUstep).
- Threading, Philip Knodle, 2001/07/01
- Re: Threading,
Richard Frith-Macdonald <=