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. Harris角点

    1. 不同类型的角点 在现实世界中,角点对应于物体的拐角,道路的十字路口.丁字路口等.从图像分析的角度来定义角点可以有以下两种定义: 角点可以是两个边缘的角点: 角点是邻域内具有两个主方向的特征点: ...

  2. MATLAB学习笔记(十)——MATLAB图形句柄

    (一)图形对象及其句柄 一.图形对象 MATLAB图形对象包括: 1.MATLAB每一个具体图形一定包括计算机屏幕和图形窗口两个对象 二.图形对象句柄 1.定义 MATLAB在创建每一个图形对象时,都 ...

  3. cocos2d 消息映射

    alayer #include "ALayer.hpp" ALayer::ALayer(void) { } ALayer::~ALayer(void) { } bool ALaye ...

  4. cocos2d CCArray

    CCArray* arr=CCArray::create(); arr->retain();//如果不加这个东西,CCArray会被清空 arr->addObject(CCSprite:: ...

  5. NOI2010 : 超级钢琴

    求出前缀和 对于每个结尾i,设现在取的区间是[j+1,i],则i-R<=j<=i-L,取出该区间sum[j]的最小值,将sum[i]-sum[j]放入堆中 建立一个大根堆,每次取出堆顶元素 ...

  6. [leetCode][013] Two Sum 2

    题目: Given an array of integers that is already sorted in ascending order, find two numbers such that ...

  7. TYVJ P1083 分糖果 Label:bfs

    描述 童年的我们,将和朋友分享美好的事物作为自己的快乐.这天,C小朋友得到了Plenty of candies,将要把这些糖果分给要好的朋友们.已知糖果从一个人传给另一个人需要1 秒的时间,同一个小朋 ...

  8. TYVJ P1082 找朋友 Label:字符串

    描述 童年的我们,对各种事物充满了好奇与向往.这天,小朋友们对数字产生了兴趣,并且想和数字交朋友.可是,怎么分配这些数字才能使得每个小朋友都唯一地找到一个数字朋友呢?C小朋友说:咱们按自己名字的字典序 ...

  9. [转] - JAR文件包及jar命令详解 ( MANIFEST.MF的用法 )

    常常在网上看到有人询问:如何把 java 程序编译成 .exe 文件.通常回答只有两种,一种是制作一个可执行的 JAR 文件包,然后就可以像. chm 文档一样双击运行了:而另一种是使用 JET 来进 ...

  10. [转] - C++程序启动过程

    先说编译.链接过程1.预编译展开宏2.为每一个.cxx源文件编译一个目标文件3.编译器合成这些目标文件成一个库文件,同时解析可以找到的符号引用4.连接器把目标的库文件和所需要的引用的静.动态链接库进行 ...