Why does Windows support threads?

Source: Internet
Author: User
Tags windows support

Why does Windows support threads? What is the connection and difference between processes and threads?

In the early years of the computer, the operating system did not provide the thread concept. In fact, the entire system only runs one execution thread, which simultaneously contains the operating system code and applications. The problem with using only one execution thread is that long-running tasks prevent other tasks from being executed. For example, in 16-bit windows, applications that print a document can easily "freeze" the entire machine, causing the OS and other applications to stop responding. Some applications contain bugs, which may lead to infinite loops, which may also cause the entire machine to stop working.

In this case, you have to press the reset key or power switch to restart the computer. Users are deeply disgusted with this (in fact, it will happen now) because all running applications will be terminated. More importantly, the data being processed by these applications will be lost without reason. Microsoft understands that 16-bit windows is not an ideal operating system. As the computer industry continues to grow, it is not enough to maintain Microsoft's leading position. Therefore, they plan to build a new OS to meet the needs of enterprises and individuals. This new OS must be robust, reliable, easy to scale, and secure, and it must improve many of the 16-bit windows. This OS kernel was originally released in Microsoft Windows NT. After years of development, this kernel has been greatly improved and many features have been added. Every time Microsoft releases the latest version of the client and server Windows operating system, the latest version of the kernel is used.

When Microsoft designed the OS kernel, they decidedProcess)To run each instance of the application. A process is a collection of resources used by an instance of an application. Each process is assigned a virtual address space to ensure that the code and data used by one process cannot be accessed by another process. This ensures the robustness of the application instance, because one component cannot destroy the code or data used by another process. In addition, the OS kernel code and data cannot be accessed by the process. Therefore, the application code cannot damage the operating system code or data. Because the application code cannot damage other applications or OS itself, the user's computing experience has become better. In addition, the system becomes safer than ever because the application code cannot access the username, password, credit card information, or other sensitive information used by another application or the OS itself.

It sounds good, but what about the CPU itself? What happens if an application enters an infinite loop? If the machine has only one CPU, it will execute an infinite loop and cannot execute anything else. Therefore, although the data cannot be damaged and is safer, the system may still stop responding. Microsoft needs to fix this problem. The solution they come up with is thread. As a Windows concept,Thread)It is responsible for virtualizing the CPU. Windows provides a dedicated thread for each process (equivalent to a CPU, which can be understood as a logical CPU ). If the application code enters an infinite loop, the processes associated with the code will be frozen, but other processes (they have their own threads) will not be frozen: they will continue to execute.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.