On Thu, Mar 14, 2002 at 05:46:52PM +0530, Vinay wrote: > Hi all, Could somebody explain the concept of data alignment in Linux. A lot of hardware requires that data be aligned to some magic value for use. A typical example is that four-byte quantities must be aligned in memory at addresses evenly divisible by four (or, congruent to zero mod four). Sometimes the consequences of non-aligned memory accesses are simply running slow (such as accessing a four-byte quantity that is aligned congruent to one mod four on the x86 platform), SIGBUS (such as accessing a four-byte quantity that is aligned congruent to one mod four on the SPARC platform), or plain not being able to use those memory adresses (say, if the device has a register memory mapped at a specific location .. unaligned accesses would simply be impossible). Usually, memory alignment is used for speed -- the hardware is easier to build if it has restrictions. Sometimes, they build in slower hardware to deal with unaligned accesses, sometimes they build the hardware to throw an error condition rather than be forced to run slowly. I hope this helps. :) -- http://www.wirex.com/
Attachment:
pgp00046.pgp
Description: PGP signature