Clr_via_c #. 3rd translation [25.1 why Windows supports threads]

Source: Internet
Author: User
Tags windows support

Part V threading

25 thread Basics.

 

In this section, I will introduce some basics about threads, including their concepts and usage. I will also explain why Microsoft creates threads,CPUTrend,CLRThread andWindowsThread relationships, thread overhead,WindowsHow to arrange threads, Microsoft. NetAttributes of threads in the framework class.

 

The fifth part of this book, "Thread" will tell youWindowsAndCLRHow to work together to provide a thread architecture. I hope that when you finish reading this chapter, you can use the learned knowledge to Efficiently build yourProgram.

 

25.1 why does Windows support threads? Why WindowsSupport thread

 

A long time ago, the operating system did not provide the thread concept. In fact, the entire system has only one thread, including the Operating SystemCodeAnd application code. A thread problem is that if a task takes a long time, it will stop other tasks from running. For example16BitWindowsIn the ageOSAnd other applications. And sometimesBug, Will lead to infinite loops and the machine will not be able to operate.

 

For this reason, end users cannot restart their computers. Of course, users do not like this because all running applications are stopped. More importantly, the data being processed in these applications is throw out memory and lost. Microsoft knows that it must be in the leading position in the computer industry, 16BitWindows is not good enough, so their goal is to build a new operating system to meet the needs of enterprises and individuals. This new operating system is requiredRobust, reliable, scalable, and secure, It must be improved16BitWindows. The operating system kernel was originallyMicrosoft Windows NT. Over the years, this kernel has been adjusted a lot and many features have been added. This latest version of kernel comes withWindowsThe latest version of the operating system.

 

When Microsoft designs the kernel of this operating system, they decide (Process. A process is a collection of resources to be used by an instance of an application. Each process has a virtual address space to ensure that the code and data used by one process cannot access another process. This makes the application instance robust because one process cannot destroy the code or data used by another process. In addition, a process cannot access the kernel code and data of the operating system. Therefore, it cannot destroy the operating system code or data on the application code. Therefore, currently, application code cannot destroy other applications or the operating system itself. The entire computing experience provides better end users. In addition, the system is safer because the application code cannot access the username, password, credit card information or other sensitive information of another application or the operating system itself.

 

This is good, but CPU itself ? What if an application enters an infinite loop? If there is only one CPU machine, then it executes an infinite loop and cannot execute anything else. Therefore, even though the data cannot be damaged and is safer, the system can still stop the response. Microsoft needs to solve this problem. The answer to the problem is the thread. As a concept of Windows , the task is virtualization CPU . Windows provide a dedicated thread for each process (this function is similar to a CPU , if the application code enters an infinite loop, the code associated with it will be frozen, but other processes (including their own threads) don't freeze, they continue to run!

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.