Computer Systems A Programmer's Perspective Second Edition

Many computer systems place restrictions on the allowable addresses for the

primitive data types, requiring that the address for some type of object must be a
multiple of some value K (typically 2, 4, or 8). Such alignment restrictions simplify
the design of the hardware forming the interface between the processor and the
memory system. For example, suppose a processor always fetches 8 bytes from
memory with an address that must be a multiple of 8. If we can guarantee that any
double will be aligned to have its address be a multiple of 8, then the value can
be read or written with a single memory operation.Otherwise, we may need to 
perform two memory accesses, since the object might be split across two 8-byte

memory blocks.
 
Linux follows an alignment policy where 2-byte data types (e.g.,

short) must have an address that is a multiple of 2, while any larger data types
(e.g.,int,int *,float, and double) must have an address that is a multiple of 4.
Note that this requirement means that the least significant bit of the address of
an object of type short must equal zero. Similarly, any object of type int, or any
pointer, must be at an address having the low-order 2 bits equal to zero.
 
Microsoft Windows imposes a stronger alignment requirement—any primitive object of

K bytes, for K=2, 4, or 8, must have an address that is a multiple of K. In particular,
it requires that the address of a double or a long long be a multiple of 8. This
requirement enhances the memory performance at the expense of some wasted space.
The Linux convention, where 8-byte values are aligned on 4-byte boundaries was probably
good for the i386, back when memory was scarce and memory interfaces were
only 4 bytes wide. With modern processors, Microsoft’s alignment is a better design decision.
Data type long double, for which gcc generates IA32 code allocating 12 bytes (even though
the actual data type requires only 10 bytes) has a 4-byte alignment requirement with
both Windows and Linux.

simplify the design of the hardware forming the interface between the processor and thememory system的更多相关文章

  1. Full exploitation of a cluster hardware configuration requires some enhancements to a single-system operating system.

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION Operating System Desi ...

  2. ZYNQ block design警告:[BD 41-968] AXI interface port /axi_lite4 is not associated to any clock port. It may not work correctly.

    前言 在Block design中引出AXI接口给外部,检查设计告警如下: [BD 41-968] AXI interface port /axi_lite4 is not associated to ...

  3. VC++获取计算机Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information)

    转载:http://blog.csdn.net/yapingxin/article/details/50107799 转载:http://zhidao.baidu.com/link?url=A5K6N ...

  4. 【转】【翻】Android Design Support Library 的 代码实验——几行代码,让你的 APP 变得花俏

    转自:http://mrfufufu.github.io/android/2015/07/01/Codelab_Android_Design_Support_Library.html [翻]Andro ...

  5. Android Meterial Design Support Library

    extends:http://inthecheesefactory.com/blog/android-design-support-library-codelab At the moment I be ...

  6. Methods and Systems for Enhancing Hardware Transactions Using Hardware Transactions in Software Slow-Path

    Hybrid transaction memory systems and accompanying methods. A transaction to be executed is received ...

  7. Rocket - 断句 - Diplomatic Design Patterns: A TileLink Case Study

    https://mp.weixin.qq.com/s/afRVgTCYs1Mxu898uSmVaQ 整理一篇介绍Diplomacy和TileLink的文章.   原文链接: https://carrv ...

  8. A Realistic Evaluation of Memory Hardware Errors and Software System Susceptibility

    http://www.cs.rochester.edu/~kshen/papers/usenix2010-li.pdf Abstract Memory hardware reliability is ...

  9. A Full Hardware Guide to Deep Learning

    A Full Hardware Guide to Deep Learning Deep Learning is very computationally intensive, so you will ...

随机推荐

  1. Java Hour 21 Weather

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. 本文作者Java 现经验约为21 Hour,请各位不吝赐教. 继续心情不佳,那 ...

  2. PHP自毁程序

    <?php // +---------------------------------------------------------------------- // | Kill!! // | ...

  3. /dev/ttySn(转)

    1.串行端口终端(/dev/ttySn)     串行端口终端(Serial Port Terminal)是使用计算机串行端口连接的终端设备.    计算机把每个串行端口都看作是一个字符设备.有段时间 ...

  4. 作用域与闭包:this,var

    var 作用域 先来看个简单的例子: var parent = function () { var name = "parent_name"; var age = 13; var ...

  5. XML基础总结2

    在上篇的博客中,我们系统的介绍了一下xml与html之间的异同以及一部分xml的特性或者说是优点,接下来,我们就xml文档的一些语法规则具体向大家阐述一下: 1.xml文档形成了一种"树结构 ...

  6. 浅析C#中的Attribute(转)

    最近用到了,所以静下心来找些资料看了一下,终于把这东西搞清楚了. 一.什么是Attribute 先看下面的三段代码: 1.自定义Attribute类:VersionAttribute [Attribu ...

  7. android native开发时:java.lang.UnsatisfiedLinkError: Native method not found的处理

    这个异常一般是由于JNI的链接器不能正常识别C++的函数名造成的.处理的方法是用exern "C" {},来包裹需要export的C++的native方法. 如果native的方法 ...

  8. 2016.7.9 计算机网络复习要点第四章之虚拟专用网VPN和网络地址转换NAT

    1.虚拟专用网VPN (1)一个机构内,对于那些仅在本机构内部使用的计算机就可以由本季候自行分配其IP地址,让这些计算机使用仅在本机构有效的IP地址(本地地址),不需要申请全球唯一的IP地址(全球地址 ...

  9. Insert Function before and after main function

    Source code: 1: #include<stdio.h> 2: void myStartupFun (void) __attribute__ ((constructor)); 3 ...

  10. linux gdb 没有符号表被读取。请使用 "file" 命令。

    使用gdb时遇到这个问题,刚开始接触linux下使用gdb调试程序,其原因是生成的二进制可执行文件没有使用-g选项. gcc中-g选项是为了获得有关调试信息,要用gdb进行调试,必须使用-g生成二进制 ...