Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Programming Threads > threads vs memo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 4053 of 4146
Post > Topic >>

threads vs memory layout

by Hallvard B Furuseth <h.b.furuseth@[EMAIL PROTECTED] > Sep 25, 2008 at 10:43 PM

What do POSIX and other thread APIs have to say about memory layout
of data accessed by different treads?  E.g.:

    struct Foo {
        pthread_mutex_t ma, mb;
        int a, b; /* protected by ma and mb respectively */
        int c; /* not mutex-protected, only accessed by 1 thread */
    };

I expect that is wrong if I replace int with char or short, since the
machine might not have instructions to access smaller units than a word.
OTOH I hope I can trust it with int - or sig_atomic_t.  But then there
are pointers, floats etc, with who knows what widths...  Is there e.g.
any reason to worry that someone might make a machine with 4-byte float
but 8-byte word, and 1-word minimum memory access?

-- 
Hallvard
 




 7 Posts in Topic:
threads vs memory layout
Hallvard B Furuseth <h  2008-09-25 22:43:10 
Re: threads vs memory layout
David Schwartz <davids  2008-09-25 13:47:32 
Re: threads vs memory layout
Dave Butenhof <david.b  2008-09-26 06:25:06 
Re: threads vs memory layout
"Sergey P. Derevyago  2008-10-03 18:30:17 
Re: threads vs memory layout
Hallvard B Furuseth <h  2008-10-07 15:48:42 
Re: threads vs memory layout
"Chris M. Thomasson&  2008-10-07 09:24:06 
Re: threads vs memory layout
"Chris M. Thomasson&  2008-10-07 09:32:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 8:33:28 CST 2008.