Content deleted Content added
Wiarthurhu (talk | contribs) |
Sharpen categories. |
||
Line 1:
{{context}}
== Definition ==▼
'''Data structure alignment''' is the way [[Data (computing)|data]] is arranged in [[physical memory]].
▲== Definition ==
An address ''a'', is said to be ''n''-byte aligned when ''a'' is a multiple of ''n'' bytes.
== Problems ==
Because of the way [[computer memory]] works, it is highly desirable for all memory accesses to meet certain alignment requirements. As a rule of thumb, the alignment for a primitive data type should be the same as the size of the data to be accessed, rounded up to a power of two. This avoids crossing any [[word (computer science)|word]], [[cache-line]], or [[paging|page]] boundaries.
Line 16 ⟶ 17:
==Compatibility==
The advantage to supporting unaligned access is that is is easier to write compilers that
do not need to align memory, at the expense of the cost of slower access.
Line 32:
architecture had no such restrictions.
It would also cause difficulties in porting Microsoft Office to Windows NT on [[MIPS]]▼
▲cause difficulties in porting Microsoft Office to Windows NT on [[MIPS]]
and [[PowerPC]] for [[NEC]] and [[IBM]]. Since the software was not written with such restrictions
in mind, designers had to set a bit in the O/S to enable non-aligned data.
Line 42 ⟶ 41:
==Typical aligment of C structs on x86==
[[Data structure]] members are stored sequentially in a memory so that in the structure below the member Data1 will always precede Data2 and Data2 will always precede Data3:
Line 113 ⟶ 111:
*[http://www-306.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF778525699600719DF2 PowerPC Microprocessor Family: The Programming Environments for 32-Bit Microprocessors]
[[Category:
[[Category:
|