- Concurrent Patterns and Best Practices
- Atul S. Khot
- 322字
- 2021-07-16 17:32:27
Time sharing
In the real world, we also perform a number of tasks concurrently. We 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 faster. The 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.
- Windows Vista基礎與應用精品教程
- FreeRTOS實時內核應用指南
- Windows Server 2012 Hyper-V Cookbook
- Microsoft Operations Management Suite Cookbook
- 8051軟核處理器設計實戰
- Linux使用和管理指南:從云原生到可觀測性
- 細說Linux基礎知識
- ElasticSearch Cookbook
- Red Hat Enterprise Linux 6.4網絡操作系統詳解
- 從實踐中學習Windows滲透測試
- Web Penetration Testing with Kali Linux(Third Edition)
- VMware vSphere 5.1 Cookbook
- 辦公自動化教程(Windows7+Office2010)
- Linux指令從初學到精通
- OpenSolaris紅寶書