You are not logged in.

#1 2009-07-11 20:47:32

knob
Member
Registered: 2009-01-30
Posts: 48

structures padding C

I noticed that, if a struct doesn't have variables for which, sizeof() for all of them summed up is a multiple of 4 in my case, the difference of memory is automatically filled . So I searched about this and found that the padding at the end of the structure is used to to preserve alignment for the information. I also found that some machines cannot perform unaligned accesses at all and I was wondering "why all these?".

Thank you

Last edited by knob (2009-07-11 21:29:27)

Offline

#2 2009-07-11 21:37:00

Hohoho
Member
Registered: 2007-06-23
Posts: 222

Re: structures padding C

Google's I'm feeling lucky result for "structures padding C":
http://www.openasthra.com/embedded-syst … explained/

Basically, padded data is faster to access due to architectural specifics of processors, aligned data can be accessed faster.

Offline

#3 2009-07-11 21:54:09

knob
Member
Registered: 2009-01-30
Posts: 48

Re: structures padding C

Hohoho wrote:

Google's I'm feeling lucky result for "structures padding C":
http://www.openasthra.com/embedded-syst … explained/

Basically, padded data is faster to access due to architectural specifics of processors, aligned data can be accessed faster.

Using memory to fill in the gaps therefor faster access over more memory and normal access is better?
I mean, when working with large amounts of data isn't it better to have more memory? Is the speed of access distinguishable?

Last edited by knob (2009-07-11 21:59:52)

Offline

#4 2009-07-11 22:24:36

Hohoho
Member
Registered: 2007-06-23
Posts: 222

Re: structures padding C

http://www.ibm.com/developerworks/library/pa-dalign/
Here, found a better source with a lot of focus on the performance issue, studying it myself right now.

Offline

Board footer

Powered by FluxBB