What is the difference between concurrency and parallelism?

前端 未结 30 2667
清歌不尽
清歌不尽 2020-11-22 00:21

What is the difference between concurrency and parallelism?

Examples are appreciated.

30条回答
  •  礼貌的吻别
    2020-11-22 01:04

    Parallelism is simultaneous execution of processes on a multiple cores per CPU or multiple CPUs (on a single motherboard).

    Concurrency is when Parallelism is achieved on a single core/CPU by using scheduling algorithms that divides the CPU’s time (time-slice). Processes are interleaved.

    Units:

    • 1 or many cores in a single CPU (pretty much all modern day processors)
    • 1 or many CPUs on a motherboard (think old school servers)
    • 1 application is 1 program (think Chrome browser)
    • 1 program can have 1 or many processes (think each Chrome browser tab is a process)
    • 1 process can have 1 or many threads from 1 program (Chrome tab playing Youtube video in 1 thread, another thread spawned for comments section, another for users login info)
    • Thus, 1 program can have 1 or many threads of execution
    • 1 process is thread(s)+allocated memory resources by OS (heap, registers, stack, class memory)

提交回复
热议问题