Windows Programming-basic thread knowledge

Source: Internet
Author: User

A process consists of two parts: a process object and an address space. The thread also has two components: one isThe kernel object of the thread,OneThread stack. 

 

A process is not lively and never chooses anything. It is only a thread dependency. The thread executes code in its process space. And operate in the process address space.

 

Createthread function (a Windows function used to create a thread. However, if you are writing C/C ++ code, you should never call createthread. Instead, use the VisualC ++ Runtime library function _ beginthreadex)

 

 HANDLE CreateThread(
LPSECURITY_ATTRIBUTES psa,
DWORD cbStack,
LPTHREAD_START_ROUTINE lpStartAddr,
LPVOID lpvThreadParam,
DWORD fdwCreate,
LPDWORD pdwThreadID
);

 

 

 

Parameter description:

Psa

Pointer to the security_attributes structure. Pass null, which is the default attribute of the thread's kernel object. Set to the security_attributes structure.

CbStack

The number of address spaces that a high thread may use for its own stack. (Note: The stack space is in the process space .)

LpStartAddr

Specifies the address (name of the thread function) of the thread to be executed by the new thread ).

PvParam

The parameter is the same as the pvparam parameter that was previously passed to createthread. The only thing to do is to pass the data transmission to the thread function when the thread starts execution. It can be a numeric value. It can also be a pointer to a data structure.

FdwCreate

Set other signs used to control the creation of fire fighting tanks. There are two values0(Schedule now ),

 Create_suincluded(The system can completely create a thread and initialize it. It is not commonly used to suspend the running of the thread and the thread cannot be scheduled.

PdwThreadID

It must be a valid address of DWORD, which is used to store the ID assigned to the new thread by the system.

 

Fangsh

2010-12-27

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.