下载此文档

字节对齐详解Bytealignment.doc


文档分类:汽车/机械/制造 | 页数:约20页 举报非法文档有奖
1/20
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/20 下载此文档
文档列表 文档介绍
字节对齐详解(Byte alignment)
字节对齐详解(Byte alignment)
Byte alignment detail - jack-wang - C++ blog
Jack-wang
C++ blog home new essays contact polymerization management
Essays, -107 reviews, -17 articles, -0, trackbacks-0
Byte alignment
I. what is byte alignment and why should it be aligned?
The memory space of modern computer are in accordance with the byte classification, in theory seems to be of any type of variable access can start from any address, but the actual situation is when accessing a specific type variables often in
Fixed memory address access, which requires various types of data to be arranged in space in accordance with certain rules, rather than sequential emissions one after another, which is alignment.
The role and reason of alignment: each hardware platform is very different from the processing of storage space. Some platforms can access certain types of data only from certain addresses. For example, some of the schema's CPU is in access
When a variable is not aligned after an error, so in this
framework must be byte aligned. Other programming platform is likely not the case, but the most common is the platform for if not in accordance with the requirements of
Data storage alignment results in loss of access efficiency. Some platforms, for example, start reading from my address at any time, if a int (assuming 32 bit system) is stored at the beginning of my address
A read cycle can read the 32bit, and if stored at the start of the odd address, 2 read cycles are needed, and the number of bits and bytes of the two read results are pieced together to obtain the 32bit number
According to the. Obviously, the reading efficiency has dropped a lot.
Two. Byte alignment affects the program:
Let's look at some examples first (32bit, x86 environment, gcc compiler):
Set the structure as follows:
Struct A
{
Int a;
Char b;
Short c;
};
Struct B
{
Char b;
Int a;
Short c;
};
It is now known that the length of v

字节对齐详解Bytealignment 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数20
  • 收藏数0 收藏
  • 顶次数0
  • 上传人rabbitco
  • 文件大小61 KB
  • 时间2021-01-12