This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/16549] pthread_cond_wait and pthread_cond_timedwait do not suspend the calling thread
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 12 Feb 2014 17:18:10 +0000
- Subject: [Bug nptl/16549] pthread_cond_wait and pthread_cond_timedwait do not suspend the calling thread
- Auto-submitted: auto-generated
- References: <bug-16549-131 at http dot sourceware dot org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=16549
--- Comment #19 from Rich Felker <bugdal at aerifal dot cx> ---
On Wed, Feb 12, 2014 at 11:34:49AM +0000, vinxxe at gmail dot com wrote:
> the problem is: imagine I have to pack my types to save some memory
This is a fallacy. Unless you have a very large number of objects, the
amount of supporting code bloat to access misaligned objects is orders
of magnitude larger than what you save. Pthread synchronization
objects are also sufficiently large in themselves that they're going
to dominate any "waste" from padding. Moreover, if you just order your
struct members correctly (approximately: from largest to smallest)
you'll ensure that there is little or no padding.
> where is written that a pthread_cond_t variable must be 4 byte aligned?
Nowhere. On a C11 compiler, _Alignof could tell you this, but
otherwise the alignment requirement is not a documented aspect of the
interface because it can vary by target and you're supposed to be
relying on the compiler to align it correctly.
> I'm just talking about this, a way to avoid or to earlier detect such kind of
> errors
Unless you can prove the member in question is aligned, you can simply
never apply the & operator to any member of a packed structure. The
best way to avoid doing this is not using packed structures at all.
--
You are receiving this mail because:
You are on the CC list for the bug.