官术网_书友最值得收藏!

Sequential and parallel programming

We can think of sequential and parallel programming as counterparts.

In sequential programming, we're executing processes in order. This means that a process is started when the preceding process has finished. In other words, there is always only one process being executed. The following figure illustrates this principle:

In parallel programming, multiple processes can be executed concurrently:

To make this easier to understand and more relevant to PHP, we can, instead of processes, think of lines of code. PHP interpreter is always sequential and it never executes code in parallel.

In Chapter 9, Multithreaded and Distributed Computing with pthreads and Gearman, we'll use PHP module pthreads that makes it possible to run PHP code in multiple threads, but we'll see that it's not as simple as it seems. Module pthreads, in fact, creates multiple independent PHP interpreters, each running in a separate thread.

主站蜘蛛池模板: 城市| 安阳市| 东海县| 永德县| 剑阁县| 石城县| 忻州市| 宜兴市| 永靖县| 桃源县| 南通市| 临沂市| 芷江| 梁河县| 巩义市| 石河子市| 招远市| 卓尼县| 星座| 社旗县| 文水县| 兴化市| 莱州市| 章丘市| 新乐市| 洞头县| 东乡县| 盐源县| 威远县| 奈曼旗| 万荣县| 疏附县| 名山县| 襄城县| 桦南县| 虹口区| 鄂托克前旗| 安仁县| 根河市| 天柱县| 平舆县|