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

Time sharing 

In the real world, we also perform a number of tasks concurrentlyWe attend to a task and then if another task also needs our attention, we switch to it, attend to it for a while, and then go back to the first task. Let's look at a real-world example of how an office receptionist deals with their tasks. 

When you visit any office, there is usually a receptionist who receives you and asks for your business. Say that, just as they are asking about who you need to meet, the office buzzer rings. They take the call, say "hello," speak for a while, and then ask you to wait for a second. Once the call is finished, they resume talking to you. These actions are shown in the following diagram:

The receptionist is sharing her time among all the parties interested in talking to her. She is working in a way so that everyone gets a slice of her time. 

Now, keeping the toll plaza and the receptionist in mind, replace the toll operators with a CPU core and the cars with tasks, and you get a fairly good mental model of today's concurrent hardware. If we increase the number of toll operators from three to six, we will increase the number of cars getting serviced in parallel (at the exact same time) to six. A pleasant side effect is that the queued cars will also spread out, and every car will get serviced fasterThe same holds true when we execute a concurrent program. Hence, things are faster overall.

Just as the receptionist is doing multiple things at the same time, such as time sharing between the visitors, a CPU shares time with processes (running programs). This is how concurrency gets supported on a single CPU

主站蜘蛛池模板: 民乐县| 盐山县| 南宫市| 重庆市| 客服| 贡山| 彭阳县| 特克斯县| 景东| 年辖:市辖区| 尼勒克县| 永顺县| 余干县| 女性| 沈丘县| 广德县| 株洲县| 舟山市| 美姑县| 宜兴市| 凯里市| 承德市| 漳浦县| 商南县| 桦甸市| 恩施市| 湟源县| 海伦市| 会东县| 奉节县| 安西县| 象州县| 津南区| 静海县| 库车县| 邮箱| 富蕴县| 定西市| 翁源县| 宜良县| 金沙县|