I know that some processors fail with misaligned data, and others like the oh-so-common x86, would just be slower with that.
My question is why? Why is it harder for an x86 processor to get the data from the pointer 0x12345679
than it is from the pointer 0x12345678
? Just to be clear, I'm aware that page faults may happen if the data is in multiple pages, and I understand that more data may need to be fetched from memory (one part for the start of the value and one for the end), but that isn't always true and this isn't what my question is about. I'm asking, why is it always slower?
Suppose the memory starts at 0x10000000
. Why is it harder for the processor to get a 2-byte short
from 0x10000001
than it is from 0x10000002
? Why is it harder to get a 4-byte int
from 0x10000001
than it is from 0x10000000
? And so forth.
Alignment refers to an adjustment of a vehicle's suspension – the system that connects a vehicle to its wheels. It is not an adjustment of the tires or wheels themselves. The key to proper alignment is adjusting the angles of the tires which affects how they make contact with the road.
Improper wheel alignment and balancing can cause issues with how your vehicle handles. Besides being a safety hazard, it negatively affects your tyre tread and stability, markedly reduces your vehicle's fuel efficiency, and greatly affects the overall performance of your vehicle.
Organizational alignment is important because it helps to encourage collaboration and a mutual pursuit of company goals, which has several long-term benefits to the success and productivity of an organization. Organizational alignment may also improve the happiness of employees and improve customer experiences.
Because the data bus is wider than eight bits.
Let assume that the data bus is 32 bits. To get 16 bits from address 0x10000001, it has to get the four bytes that starts at 0x10000000 and shift the value to get the two bytes in the middle.
To get 16 bits from the address 0x10000003, it has to get the words that start at 0x10000000 and 0x10000004, and use one byte from each value.
The processor can only access memory in an aligned fashion. This is a consequence of how the interconnect between the processor and memory functions.
When a processor supports unaligned reads, what's really happening is the processor issuing two separate reads (or one read of larger size) and stitching the parts together, which is why it's slower than an aligned read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With