| Subject: | 32 bit or 64 bit allignment ?! gcc options?? |
|---|---|
| From: | mynickmynick <mynickmynick@xxxxxxxxx> |
| Date: | Tue, 29 Jul 2008 01:01:12 -0700 (PDT) |
| Newsgroups: | gnu.gcc.help |
I am trying to read the man of gcc but I have not figured out what sort of problem I might have with data alignment for ints, doubles, structs and arrays. Let's summarize in a few questions: (1) I guess for a relatively recent 32bit Intel x86 , data alignment must be 32 bit for all ints, doubles, struct fileds, array elements or any other data. Because otherwise pthread_mutex_locking for multithreading data protection would be not sufficient to protect shared data? Is this a default option of the compiler? How would be this option changed? (2) For a 64 bit more recent Intel do I have to require 32 or 64 bit alignment of all data? What is the default? (3) Are most recent and most used Intels 64 bits? (4) What if an array is shared but each single element is not shared or a struct is shared but each single element is not shared. Example: Thread 1 uses struct.field1 and a[0] while Thread2 uses struct.field2 and a[1] What if my code does not use mutexes to protect these data cause they are not effectively shared? Is there some probability that the compiler does not align field1 and field2 or a[0] and a[1] so that I have errors?! Can it happen for instance the following? field1 and field2 have size x while the CPU 2x (for instance x=32bits and CPU 64 bits) Thread1 reads struct.field1 (but also field2 as a side effect) Thread2 reads struct.field2 Thread2 writes struct.field2 Thread1 writes struct.field1 OVERWRITING struct.field2 with its old value??!! Please help me understand! Thank you |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Is this code in gcc 4.3.1 valid C or is Sun compiler wrong ??, David Eisner |
|---|---|
| Next by Date: | Where to find gcc-3.3.2-1.i386.rpm?, Derekasaurus Rex |
| Previous by Thread: | Re: Is this code in gcc 4.3.1 valid C or is Sun compiler wrong ??, David Eisner |
| Next by Thread: | Where to find gcc-3.3.2-1.i386.rpm?, Derekasaurus Rex |
| Indexes: | [Date] [Thread] [Top] [All Lists] |