我是靠谱客的博主 寒冷大侠,最近开发中收集的这篇文章主要介绍Distributed Programming: Two Traditional Communication Mechanism,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

shared memory vs message passing

文章目录

      • Shared Memory
        • Key Abstraction:
        • Feature
        • Synchronisation Mechanism
          • 1. Semaphore
          • 2. Locks
          • 3. Barrier
        • Example
      • The Message-Passing Programming Model
        • Key Abstraction:
        • Feature
        • Example:
      • Comparison

Shared Memory

Key Abstraction:

  • Every task can access any location in an application’s distributed memory space. as is the case with threads in a single process, where all threads share the process address space

Feature

  • Tasks exchange data implicitly via sharing and not by explicitly sending and receiving messages.

  • The shared-memory model, consequently, supports synchronisation mechanisms that distributed programs must use to control the order in which various tasks can perform read/write operations. This goal typically can be achieved using semaphores, locks, and/or barriers.

Synchronisation Mechanism

1. Semaphore

A semaphore is a point-to-point synchronization mechanism that involves two parallel/distributed tasks. Semaphores use two operations: post and wait. The post operation acts like depositing a token, signaling that data has been produced. The wait operation blocks until signaled by the post operation that it can proceed to consume data.

2. Locks

Locks protect critical sections, which are regions that only one task can access (typically write) at a time. Locks involve two operations, lock and unlock, for acquiring and releasing a lock associated with a critical section. A lock can be held by only one task at a time, and other tasks cannot acquire it until released.

3. Barrier

Last, a barrier defines a point beyond which a task is not allowed to proceed until every other task reaches that point.

Example

  • DSM-OpenMP

The Message-Passing Programming Model

Key Abstraction:

  • Resembles processes that, unlike threads, each maintain a private memory space.

Feature

  • To send and receive data via explicit messages, this model incurs communication overheads
  • No explicit synchronization is needed
  • The interacting tasks require no illusion of a single, shared address space.

Example:

  • Message passing interface (MPI)
  • Implementation: MPICH

Comparison

最后

以上就是寒冷大侠为你收集整理的Distributed Programming: Two Traditional Communication Mechanism的全部内容,希望文章能够帮你解决Distributed Programming: Two Traditional Communication Mechanism所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部