concurrency parallel 并发 并行 parallelism
在传统的多道程序环境下,要使作业运行,必须为它创建一个或几个进程,并为之分配必要的资源。
当进程运行结束时,立即撤销该进程,以便能及时回收该进程所占用的各类资源。进程控制的主要功能是为
作业创建进程,撤销已经结束的进程,以及控制进程在运行过程中的状态转换。在现代os中,进程控制还具有为
为一个进程创建若干个线程的功能和撤销(终止)已完成任务的线程的功能。
并发:同一时刻
并行:同一时间间隔
单处理机系统:每一时刻仅能有一道程序执行,故微观上这些程序只能是分时地交替执行;
多处理机系统:则这些可以并发执行的程序便可被分配到多个处理机上,实现并行执行;
Computer Systems A Programmer's Perspective Second Edition
The general phenomenon of multiple flows executing concurrently is known as concurrency
Assume that a task has two independent parts,A and B. Part B takes roughly 25% of the time of the whole computation. By working very hard, one may be able to make this part 5 times faster, but this only reduces the time for the whole computation by a little. In contrast, one may need to perform less work to make part A be twice as fast. This will make the computation much faster than by optimizing part B, even though part B's speedup is greater by ratio, (5 times versus 2 times).