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

  • Mastering C# Concurrency
  • Eugene Agafonov Andrew Koryavchenko
  • 248字
  • 2021-07-09 21:26:05

Chapter 1. Traditional Concurrency

Speaking of concurrency, we have to start talking about threads. Ironically, the reason behind implementing threads was to isolate programs from each other. Back in the early days of Windows, versions 3.* used cooperative multitasking. This meant that the operating system executed all the programs on a single execution loop, and if one of those programs hung, every other program and the operating system itself would stop responding as well and then it would be required to reboot the machine to resolve this problem.

To create a more robust environment, the OS had to learn how to give every program its own piece of CPU, so if one program entered an infinite loop, the others would still be able to use the CPU for their own needs. A thread is an implementation of this concept. The threads allow implementing preemptive multitasking, where instead of the application deciding when to yield control to another application, the OS controls how much CPU time to give to each application.

When CPUs started to have multiple cores, it became more beneficial to make full use of the computational capability available. The use of the threads directly by applications suddenly became more worthwhile. However, when exploring multithreading issues, such as how to share the data between the threads safely, the set-up time of the threads immediately become evident.

In this chapter, we will consider the basic concurrent programming pitfalls and the traditional approach to deal with them.

主站蜘蛛池模板: 蓝山县| 手游| 永德县| 嫩江县| 揭西县| 佛山市| 双桥区| 西平县| 凤山县| 普洱| 安徽省| 咸宁市| 咸阳市| 云南省| 合水县| 庆阳市| 白玉县| 普宁市| 荣成市| 杨浦区| 杭锦后旗| 施秉县| 平潭县| 来安县| 扎赉特旗| 疏勒县| 咸丰县| 建平县| 邓州市| 闽清县| 西宁市| 平湖市| 延长县| 登封市| 增城市| 大港区| 化州市| 锦屏县| 莎车县| 阿拉善盟| 磐安县|