Hi Norman,
Apologies, I did mean to say recursive mutex - and I mean one that allows
the owning thread to nest calls to reserve it and releases it only when the
appropriate number of release calls have been received.
I have since found that -D_GNU_SOURCE, I think, will permit recursive
mutexes (by looking at pthread.h) but am not using it so far. I found no way
of specifying recursion with the default compile.
My programs works ok so far (a lot more modules to go yet!) using the
defaults (as you suggest) for stack and mutex_attr.
However, any thread finishing will stop the whole program. The 'man' implies
exit from the thread function given in start thread just finishes the
thread. I tried pthread_exit(0) to no avail. I suspect a simple 'error' -
perhaps you can suggest something?
Many thanks for your assistance
Ivor
> > 3. I need a recursive semaphore and 'man' documentation seems to support
> > this. However the compile will not work as the recursive bits of the
> header
> There is no such thing as a recursive semaphore. Semaphores are not
"owned"
> by any thread. Mutexes are owned and can be recursive or not.
> Did you intend to say "mutex" instead of semaphore, or what exactly do you
> mean by recursive.
> > 2. the app compiles but either crashes with seg violation with no set
> stack
> > size for the threads, or the thread start is failed (1) if I set a stack
> I do not set a stack size for my threads. I just take the Linux pthreads
> default, which I believe is 2MB, from a gander at the source code. What
does
> your pthread_create call look like.
> --
> Norman Black
> Stony Brook Software
> the reply, fubar => ix.netcom
> > Hi,
> > I am porting a multi-thread application to linux. The app is stable and
> > gives no nasties under windows and also QNX-neutrino.
> > I am using Red Hat purchased in December.
> > I am in the first stages of compilation and have some problems:
> > 1. I am not sure if I need special compile flags for multi-thread
> > (reentrant)
> > 2. the app compiles but either crashes with seg violation with no set
> stack
> > size for the threads, or the thread start is failed (1) if I set a stack
> > size. (app running at normal user level - not root)
> > 3. I need a recursive semaphore and 'man' documentation seems to support
> > this. However the compile will not work as the recursive bits of the
> header
> > are conditional on __USE_GNU. I can't set this, it seems, unless I copy
> the
> > header and edit it (as an experiment - this can't be expected to be
> right.)
> > Can anyone advise me - I am a linux newbie - on the basics for threads
in
> > linux. I understand threads in principle and have a working app for
> > win/neutrino - I need to know the basics for linux re recursive
semahores
> > and compiler options etc for multi-thread.
> > (I do read the documentation, but it does not always stack!)
> > Cheers
> > Ivor Cox