• golang 并发 vs 并行 (Concurrency Is Not Parallelism)


    Rob pike发表过一个有名的演讲《Concurrency is not parallelism》(https://blog.golang.org/concurrency-is-not-parallelism),

    演讲胶片在talks.golang.org中可以找到(https://talks.golang.org/2012/waza.slide#1),

    演讲视频地址 :https://vimeo.com/49718712

    The modern world is parallel

    Multicore.

    Networks.

    Clouds of CPUs.

    Loads of users.

    Our technology should help.
    That's where concurrency comes in.

    Go supports concurrency

    Go provides:

    • concurrent execution (goroutines)
    • synchronization and messaging (channels)
    • multi-way concurrent control (select)

    Concurrency is cool! Yay parallelism!!

    NO! A fallacy.

    When Go was announced, many were confused by the distinction.

    "I ran the prime sieve with 4 processors and it got slower!"

    fallacy:

    n. 谬论,谬见;推理谬误;谬误性

    Concurrency

    Programming as the composition of independently executing processes.

    (Processes in the general sense, not Linux processes. Famously hard to define.)

    Parallelism

    Programming as the simultaneous execution of (possibly related) computations.

    Concurrency vs. parallelism

    Concurrency is about dealing with lots of things at once.

    Parallelism is about doing lots of things at once.

    Not the same, but related.

    Concurrency is about structure, parallelism is about execution.

    Concurrency provides a way to structure a solution to solve a problem that may (but not necessarily) be parallelizable.

    An analogy

    Concurrent: Mouse, keyboard, display, and disk drivers.

    Parallel: Vector dot product.

    analogy:

    n. 类比,比拟;用类比方法,进行比照;同功

    Concurrency plus communication

    Concurrency is a way to structure a program by breaking it into pieces that can be executed independently.

    Communication is the means to coordinate the independent executions.

    This is the Go model and (like Erlang and others) it's based on CSP:

    C. A. R. Hoare: Communicating Sequential Processes (CACM 1978)

    并发模型中的csp模型:https://www.zhihu.com/question/26192499

    参考;https://blog.csdn.net/abccheng/article/details/50913795

  • 相关阅读:
    SQL-W3School-高级:SQL ALIAS(别名)
    SQL-W3School-高级:SQL BETWEEN 操作符
    SQL-W3School-高级:SQL IN 操作符
    SQL-W3School-高级:SQL 通配符
    C语言实现定积分求解方法
    android使用webview上传文件(支持相册和拍照)
    POJ2349+Prim
    nyist 740 “炫舞家“ST(动态规划)
    paip.php eclipse output echo 乱码
    Deep Learning论文笔记之(八)Deep Learning最新综述
  • 原文地址:https://www.cnblogs.com/youxin/p/16000573.html
Copyright © 2020-2023  润新知