Easy-language multi-thread Error

Source: Internet
Author: User

Log_content"

I recently wrote software to the customer and found that I have not found any errors on this side. However, when the customer's software runs multiple threads, an error occurs and the problem cannot be found. After a long time, I found a solution, it turned out to be a CPU problem. multithreading has a problem with dual-core CPU affinity. Now we can find a solution to the problem. By the way, let's record that some friends may encounter the same problem. For more information, see.

DLL command:
. Version 2

. Dll command setprocessaffinitymask, integer type, public, set CPU affinity Process Handle returned CPU number
. Parameter hprocess, integer type
. Parameter hprocess, integer type

. Dll command setthreadaffinitymask, integer type, public, set CPU affinity thread handle
. Parameter hprocess, integer type
. Parameter mask, integer type

. Dll command getcurrentprocess, integer type, public, get a pseudo handle of the current process is generally-1

. Dll command getcurrentthread, integer type, public, get a pseudo handle of the current thread is generally-2

Put the following code into the easy code:
Setprocessaffinitymask (-1, 1)

"

 

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.