Processing of threads (1)

xiaoxiao2021-03-06  66

The operating system uses the process to separate the different applications they are performing. The thread is an operating system allocated the basic unit of the processor time, and the process can have multiple threads simultaneously execute code. Each thread maintains an exception handler, scheduling priority, and a set of systems for saving the context context before scheduking the thread. The thread context includes all of the information required to continuously perform the desired information in the host process address space of the thread, including the CPU register group and the stack of the thread.

.NET Framework further segments the operating system process

System.appdomain

Representing, a lightweight hosted sub-process in the application domain. One or more trust threads (by

System.Threading.Thread

Indicates that it can be run in one or any number of application domains in the same non-hosting process. Although each application domain is started with a single thread, the code in the application domain can create additional application domains and additional threads. The result is that the hosted thread can be moved between the application domains in the same non-hosting process; you may have only one thread moves between several applications. By the way, talk about Appdomain. The application domain is represented by the AppDomain object to provide isolation, uninstall, and security boundaries for execution managed code. Multiple application domains can run in a process; however, there is no one-to-one association between the application domain and the thread. Multiple threads can belong to an application domain, although the given thread is not limited to an application domain, but at any given time, the thread is executed in an application domain. The application domain is created by using the CREATEDOMAIN method. AppDomain instances are used to load and execute assemblies. When you no longer use Appdomain, you can uninstall it.

Support for a first multitasking operating system can create multiple threads in multiple processes simultaneously executed. It implements this in the following way: dividing the processor time between the threads that require the processor time, and rotates the processor time slice for each thread. The currently executed thread is suspended at the end of its time, and the other thread continues to run. When the system switches from one thread to another, it saves the thread context of the predetermined thread and reloads the saved thread context of the next thread in the thread queue.

The length of the time sheet depends on the operating system and processor. Since each time the tablets are small, even if there is only one processor, multiple threads seem to be executed at the same time. This is actually the case where the multiprocessor system occurs, in which the thread distribution can be executed in a plurality of available processors. When to use multiple threads

Software that requires users to interact must react as quickly as possible to provide a variety of user experience. But it must perform the necessary calculations to present data to the user as quickly as possible. If the application uses only one execution thread, you can use the asynchronous programming with .NET remote processing or XML Web Services created with ASP.NET, using other computers, using your own computer processing time, Thereby increasing the response speed of the user and reducing the data processing time of the application. If you are working on a lot of input / output, you can also use I / O to complete ports to improve the response speed of the application.

转载请注明原文地址:https://www.9cbs.com/read-106641.html

New Post(0)