zoukankan      html  css  js  c++  java
  • simplify the design of the hardware forming the interface between the processor and thememory system

    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.
  • 相关阅读:
    Sending post
    <<the not so short introduction to Latex2e >> 读书笔记
    Latex 书签中文乱码解决方案
    VisualSVN迁移到其他服务器 子曰
    C#遍历DataSet中数据的几种方法总结 子曰
    Extjs formpanel加载数据的两种方式 子曰
    向老销售取经,学来的一点软件销售技巧 子曰
    extjs 实现 NumberField 即时计算 子曰
    Ext.form.DateField简单用法及日期范围控制 子曰
    解决.aspx中插入浮动广告不滚动问题 子曰
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6137131.html
Copyright © 2011-2022 走看看