This discussion is archived
3 Replies Latest reply: Sep 30, 2012 10:01 AM by 800381 RSS

SPARC V8 pthread_mutex_t alignment

963805 Newbie
Currently Being Moderated
KU 137111-01 (only link I found is 3rd party: seems to indicate that the alignment requirement for pthread_mutex_t on SPARC V8 is on 8 bytes boundary. IIUC, such variables and types are correct wrt the new requirements:

pthread_mutex_t g_mutex;
struct S {
pthread_mutex_t mutex_;
static pthread_mutex_t s_mutex_;
} s;

Moreover, variables can be aligned using the #pragma align. The docs clearly indicate that the arguments to align must be variables, not types; also, that sometimes they must be indicated by their mangled name. Is my understanding correct?


Edited by: 960802 on Sep 23, 2012 5:29 PM
  • 1. Re: SPARC V8 pthread_mutex_t alignment
    803026 Newbie
    Currently Being Moderated
    I'm not really sure what the question is.

    Yes, pthread_mutex_t is and must be aligned by 8.
    Yes, the align #pragma acts on variables, AFAIK,
    but you shouldn't need to use it.
    No, I did not click on your link.

  • 2. Re: SPARC V8 pthread_mutex_t alignment
    963805 Newbie
    Currently Being Moderated
    Thanks Peter.

    I thought I was being clever and courteous by not posting a long link, heh. Here is the complete link to a Fujitsu note about the patch: Information about the mutex alignment is in the second half of the note/page.

    I have posted initially because I have received contradictory information about this topic in another forum and I wanted to clarify the issue. The information I received there was that a user must place alignment pragma's in the program to explicitly align pthread_mutex_t/mutex_t objects wherever they appear. E.g., the strongly suggested approach was like:

    #pragma pack(8)
    #pragma align 8(S)

    struct S {
    #pragma align 8(lock)
    mutex_t lock;

    I found it highly suspicious that Sun/Oracle would ask a user to explicitly align their mutex objects; also, I found it odd that the pragma docs do not mention aligning types (!).

    Thanks again.

    Edited by: 960802 on Sep 26, 2012 5:52 AM
  • 3. Re: SPARC V8 pthread_mutex_t alignment
    800381 Explorer
    Currently Being Moderated
    I've never seen any requirement to explicitly align mutex structures.

    That Fujitsu patch you linked to was to fix code that caused problems because it explicitly forced a mutex address off an 8-byte boundary.

    One wonders how on God's good Earth that ever made it past their testing. Heck, one wonders how it got past unit testing.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points