This is a discussion on pthread mutex and data alignment within the AIX Operating System forums, part of the Unix Operating Systems category; --> Environment: AIX 4.3.3 - RS6000 H80 - VAC 5.0.2.0 Has anyone had data alignment problems when using pthreads while ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Environment: AIX 4.3.3 - RS6000 H80 - VAC 5.0.2.0 Has anyone had data alignment problems when using pthreads while compiling a program with the "-qalign=packed" directive ???? Is this a known problem??? Our specific problem was in a pthread_mutex_trylock() call .....it incorrectly reports the mutex is locked... unless we force the pthread_mutex_t onto a full-word alignment... ....then it works correctly. Are there other "subsystems" that have a similar problem ??? THANKS, -tony |
| |||
| Nicholas Dronen wrote: > T.R.Bennett <bennett.tony@cnf.com> wrote: > TRB> Has anyone had data alignment problems when using > TRB> pthreads while compiling a program with the > TRB> "-qalign=packed" directive ???? Sounds like the system include files should incorporate wrappers that undo any alignment chosen by the user... > TRB> Our specific problem was in a pthread_mutex_trylock() call > TRB> ....it incorrectly reports the mutex is locked... > TRB> unless we force the pthread_mutex_t onto a full-word alignment... > TRB> ...then it works correctly. > > Whose problem it is depends on whether the mistake happens in the > code (bad assumptions, bad data or variable access methods, whatnot) > or the compiler (invalid behavior for pragma). You don't say under > what exact circumstances the problem occurs. Do you have a small > testcase that you can use to debug the problem outside of your > application? If so, you have a chance to gather some information > that might be useful for you or the vendor. > > And if the behavior disappears when you wrap your pthread code in > '#pragma options align=reset', you're one step closer to knowing > who to blame. :-) It would probably make more sense to "stack" the pragma for system structures, then "pop" back to the prior behavior. > Small testcase. Try using 'reset'. Post what happens. Gary Hook, > AKA Superfly of Linking, will respond. Eventually all will be well. > (And Gary works for free. How much better can it get? :-) Yeah, but I'm setting up a 1-900 number :-) The packing pragma would nominally be applied to all of the code. Unfortunately, certain system structures are going to have be left alone. In this case, a lock had better be word aligned; there are no options, no choices, no changes. Perhaps you only need to wrap your structure definitions in the pack pragma; the compiler should understand how to access the members in that case, but that would leave the rest of the system code alone. -- Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE __________________________________________________ ______________________ |
| |||
| "Gary R. Hook" <nospam@nospammers.net> wrote in message news:<vaq1b.3019$Cp4.696@newssvr22.news.prodigy.co m>... > Nicholas Dronen wrote: > > T.R.Bennett <bennett.tony@cnf.com> wrote: > > TRB> Has anyone had data alignment problems when using > > TRB> pthreads while compiling a program with the > > TRB> "-qalign=packed" directive ???? > > Sounds like the system include files should incorporate > wrappers that undo any alignment chosen by the user... > > > TRB> Our specific problem was in a pthread_mutex_trylock() call > > TRB> ....it incorrectly reports the mutex is locked... > > TRB> unless we force the pthread_mutex_t onto a full-word alignment... > > TRB> ...then it works correctly. > > > > Whose problem it is depends on whether the mistake happens in the > > code (bad assumptions, bad data or variable access methods, whatnot) > > or the compiler (invalid behavior for pragma). You don't say under > > what exact circumstances the problem occurs. Do you have a small > > testcase that you can use to debug the problem outside of your > > application? If so, you have a chance to gather some information > > that might be useful for you or the vendor. > > > > And if the behavior disappears when you wrap your pthread code in > > '#pragma options align=reset', you're one step closer to knowing > > who to blame. :-) > > It would probably make more sense to "stack" the pragma for > system structures, then "pop" back to the prior behavior. > > > Small testcase. Try using 'reset'. Post what happens. Gary Hook, > > AKA Superfly of Linking, will respond. Eventually all will be well. > > (And Gary works for free. How much better can it get? :-) > > Yeah, but I'm setting up a 1-900 number :-) > > The packing pragma would nominally be applied to all of the code. > Unfortunately, certain system structures are going to have be > left alone. In this case, a lock had better be word aligned; > there are no options, no choices, no changes. Perhaps you > only need to wrap your structure definitions in the pack > pragma; the compiler should understand how to access the > members in that case, but that would leave the rest of the > system code alone. Gary, Thanks for the info. Am I correct in my understanding that I should NOT use the "-qalign=packed" compiler argument but instead should put "#pragma option align=packed" in my source or include file before any structure I wish to have packed, and follow those structures with a "#pragma option align=reset" ?? Also, am I correct in assuming that the "-qalign=packed" compiler command line argument will override any "#pragma option align=-" directives in my source and/or include files ??? -tony |
| ||||
| T.R.Bennett wrote: > Am I correct in my understanding that I should NOT use the "-qalign=packed" > compiler argument but instead should put "#pragma option align=packed" > in my source or include file before any structure I wish to have > packed, and follow those structures with a "#pragma option align=reset" ?? It is my understanding that this is the preferred technique. > Also, am I correct in assuming that the "-qalign=packed" compiler command > line argument will override any "#pragma option align=-" directives > in my source and/or include files ??? I'd have to read the docs, but I would think this would be correct. -- Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE __________________________________________________ ______________________ |