Bus error occurs when hardware tells the OS about a problematic memory reference. In practice, a bus error is almost always caused by a misaligned read or write. It’s called a bus error, because the address bus is the component that chokes if a misaligned load or store is requested.
union { char a[10]; int i;}u;
A [...]
Archive for the ‘Embedded Systems Programming’ Category
Bus Error
Structure padding
What is padding in C?
All modern CPUs expect that the fundamental types — int’s, float’s and long’s — are stored in the memory at their natural boundary; typically, at addresses that are multiples of their length. Some CPU work efficiently if the memory is properly aligned, and some can work in either case.
For the [...]
Structure padding explained
What is Padding?Aligning members of a structre to a byte boundary. Padding is done by compiler to gain the performance. Most hardware architecturesaccess addresses fast if they are aligned properly, otherwise there will be performance penalty. In order to increase performance compiler pads structures.
How Padding done?Normally processors require members of the structure aligned to [...]