Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Apr 2012 13:44:46 +0100
From:      "'Chris Hall'" <chris.hall.list@highwayman.com>
To:        <freebsd-threads@freebsd.org>
Subject:   Trying to set PTHREAD_SCOPE_SYSTEM
Message-ID:  <056201cd253c$b43a0860$1cae1920$@highwayman.com>

next in thread | raw e-mail | index | archive | help
For my application (a BGP daemon) I think I should be setting all its
pthreads to PTHREAD_SCOPE_SYSTEM.  (This may be where I am going
wrong, of course, but bear with me.)

I have studied the POSIX specifications and the FreeBSD man pages, and
am stuck.

pthread_init_attr() is supposed to give me the default settings for
everything, including the scope and
PTHREAD_INHERIT_SCHED/_EXPLICIT_SCHED.

First difficulty: if it is PTHREAD_INHERIT_SCHED, what are the scope,
schedpolicy and schedparam set to ?

Second difficulty: if I set PTHREAD_EXPLICIT_SCHED, will that change
the scope/policy/param to the defaults, or leave them unchanged (in
which case are they the appropriate defaults) ?  Or, am I really
expected to set all of scope/policy/param if I override a default
PTHREAD_INHERIT_SCHED ?  (If the default is PTHREAD_SCOPE_SYSTEM, am I
all set having cleared PTHREAD_INHERIT_SCHED ?)

Third difficulty: if I set PTHREAD_SCOPE_SYSTEM and the default is
PTHREAD_SCOPE_PROCESS, do I also need to set policy/param ?  If so,
where do I find suitable default policy/param ?
(I could copy the policy/param from the main thread... but will that
be suitable for PTHREAD_SCOPE_SYSTEM ?)

Fourth difficulty: if I dick about with scope/policy/param, will I
need special privileges (root, say) ?

Fifth difficulty: it is clearly easiest to leave this whole thing
alone and ignore pthread_attr_t altogether.  Is there a way to set
PTHREAD_SCOPE_SYSTEM as the default for a given application from the
outside ?

POSIX appears to define a bunch of stuff in this area... but so much
is implementation defined, or simply not defined I imagine (a) 99.9%
of threaded applications do not attempt to use pthread_attr_t at all,
and (b) that somewhere each implementation will define what it does ?

Help !!

Thanks,

Chris




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?056201cd253c$b43a0860$1cae1920$>