理解Computer中shared memory systems

  • Shared memory

    shared memory is momory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Shared memory is an efficient means of passing data between programs.

    Depending on context, programs may run on a single processor or on multiple separate processors.

    Using memory for communication inside a single program, e.g. among its multiple threads, is also referred to as shared memory.

  • In hardware

    In computer hardware, shared memory refers to a (typically large) block of random access memory(RAM) that can be accessed by several different central processing units(CPUs) in a multiprocessor comuter system. (这句话很有意思,从硬件角度,shared memory是主存RAM上一个block,可以同时被不同的CPU访问,后面跟着multiprocessor,这就很清楚的说了对进程使用多个CPU实现并行计算。“进程”的英文是process,直接对应着processor“处理器”,也就是CPU,一个CPU运行的那些个东西称为一个进程)

    Shared memory systems may use:

    • uniform memory access(UMA) : all the processors share the physical memory uniformly;
    • non-uniform memory access(NUMA) : memory access tiem depends on the memory location relative to a processor;
    • cache-only memory architecture(COMA) : the local memories for the processors at each node is used as cache instead of as actual main memory.

    Complications:

    1. access time degradation

      tring to access nearby memory locations may cause false sharing.

    2. lack of data coherence

  • In software

    In computer software, shared memory is either:

    • a method of inter-process communication(IPC), i.e. a way of exchanging data between programs running at the same time. One process will create an area in RAM which other processes can access.

    • a method of conserving memory space by directing accesses to what would ordinarily be copies of a piece of data to a single instance instead, by using virtual memory mappings or with explicit support of the program in question. This is most often used for shared libraries and Excecute in place(XIP)

    This is a fast way of communication (as opposed to other mechanisms of IPC such as named pipes, Unix domain sockets or Corba)

    On the other hand, it is less scalable.

    POSIX provides a standardized API for using shared memory, POSIX Shared Memory.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值