Multithreading in Linux environments with multithreaded programming (iii)

Source: Internet
Author: User

The first two articles describe the basics of multithreaded programming in a Linux environment, as well as a typical example. This article mainly compares the Linux environment and the Windows environment of multi-threaded programming differences.

Look at the technical problem to aim at its essence, whether it is WIN32, Linux or VxWorks, its related to the multi-threaded parts are those content, is nothing more than thread control and thread communication, many of their functions are only different names, the essence of the meaning is equivalent, Let's make a list of the three major operating systems in common. Detail form:

Matters WIN32 Linux VxWorks
Thread creation CreateThread Pthread_create Taskspawn
Thread termination

Exit upon completion of execution;

The thread itself calls the ExitThread function to terminate itself;

Call function TerminateThread function by other thread

Exit upon completion of execution;

Called by the thread itself pthread_exit exits;

Call function Pthread_cance terminated by another thread

Exit upon completion of execution;

Exit by calling exit from the thread itself;

Call function Taskdelete terminated by another thread

Get thread ID GetCurrentThreadID Pthread_self Taskidself
Create Mutex CreateMutex Pthread_mutex_init Semmcreate
Get Mutex WaitForSingleObject, WaitForMultipleObjects Pthread_mutex_lock Semtake
Release Mutex ReleaseMutex Phtread_mutex_unlock Semgive
Create semaphore CreateSemaphore Sem_init Sembcreate, Semccreate
Wait for the semaphore WaitForSingleObject Sem_wait Semtake
Release semaphore ReleaseSemaphore Sem_post Semgive

Multithreading in Linux environments with multithreaded programming (iii)

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.