Problems
A computer accesses memory by a single memory word at a time. As long as the memory word size is at least as large as the largest primitive data type supported by the computer, aligned accesses will always access a single memory word. This may not be true for misaligned data accesses.
If the highest and lowest bytes in a datum are not within the same memory word the computer must split the datum access into multiple memory accesses. This requires a lot of complex circuitry to generate the memory accesses and coordinate them. To handle the case where the memory words are in different memory pages the processor must either verify that both pages are present before executing the instruction or be able to handle a TLB miss or a page fault on any memory access during the instruction execution.
When a single memory word is accessed the operation is atomic, i.e. the whole memory word is read or written at once and other devices must wait until the read or write operation completes before they can access it. This may not be true for unaligned accesses to multiple memory words, e.g. the first word might be read by one device, both words written by another device and then the second word read by the first device so that the value read is neither the original value nor the updated value. Although such failures are rare, they can be very difficult to identify.
Read more about this topic: Data Structure Alignment
Famous quotes containing the word problems:
“I have a horror of people who speak about the beautiful. What is the beautiful? One must speak of problems in painting!”
—Pablo Picasso (18811973)
“Our [adult] children have an adults right to make their own choices and have the responsibility of living with the consequences. If we make their problems ours, they avoid that responsibility, and we are faced with problems we cant and shouldnt solve.”
—Jane Adams (20th century)
“The problems of society will also be the problems of the predominant language of that society. It is the carrier of its perceptions, its attitudes, and its goals, for through it, the speakers absorb entrenched attitudes. The guilt of English then must be recognized and appreciated before its continued use can be advocated.”
—Njabulo Ndebele (b. 1948)