Three-dimensional engine design-multi-threaded rendering (Platform API Basics and Encapsulation outline framework)

Source: Internet
Author: User
Tags mutex semaphore

Part I: Linux Threading API Basics
One: thread creation and end
(1) pthread_t//thread identifier type
(2) pthread_create//used to create a thread, parameter thread identifier, thread property, thread run function address
(3) Pthread_join//used to wait for the end of a thread, the parameter is waiting for the thread identifier, the user-defined pointer
(4) pthread_exit//thread abnormal end, parameter thread return code

Two: Modify thread properties
(1) pthread_attr_t//thread attribute structure type
(2) pthread_attr_init//Initialize thread properties, call before Pthread_create
(3) Pthread_attr_setscope//Set Thread binding state
(4) Pthread_attr_setdetachstate//Set the separation state of the thread
(5) Sched_param//Storage Thread Priority type
(6) Pthread_attr_getschedparam get thread Priority
(7) Pthread_attr_setschedparam set thread priority

Three: Threading Data processing
1: Data usage
(1) Thread data classification: Global variables, local variables, thread data
(2) Pthread_key_create//For a key to develop thread data, parameter key pointers, data destructor
(3) Pthread_once//Combined with the above function, initialize only once
(4) Pthread_getspecific//Bind the thread data with a key
(5) Pthread_key_delete//used to delete a key

2: Mutex
(6) pthread_mutex_t//Mutual exclusion lock variable type
(7) Pthread_mutex_init//Generate a mutex
(9) Pthread_mutexattr_init//Generate mutex for specific attributes
(ten) pthread_mutexattr_setpshared//set mutually exclusive scope
(one) Pthread_mutexattr_settype//Set Mutex type
(Pthread_mutex_lock)//Mutex lock
(Pthread_mutex_unlock)//Mutex lock unlocked
PTHREAD_DELAY_NP//Let the thread sleep for a period of time, in combination with the above function
(a) Pthread_mutex_trylock//locked non-blocking version, method of avoiding deadlock

3: Condition variable
(+) pthread_cond_t//structure of the condition variable
(+) Pthread_cond_init//Initialize a condition variable
pthread_condattr_t//attribute structure of a condition variable
(+) Pthread_cond_destroy//releasing a condition variable
(pthread_cond_wait)//thread blocking on a condition variable
Pthread_cond_timedwait//thread blocking on a condition variable for a period of time
Pthread_cond_signal//Releasing a thread that is blocking on the condition variable cond
Pthread_cond_broadcast//Wake up all threads that are blocked on cond

4: Semaphore: Non-negative integer counter
Sem_post//Increase signal volume
(+) sem_wait//Wait for signal volume
(sem_trywait)//Wait semaphore non-blocking, similar to Phtread_mutex_trylock
(sem_t)//Semaphore type
Sem_init//initialization of a semaphore
() Sem_destroy//release semaphore

Four: Thread revocation
(1) pthread_setcancelstate//Set thread to cancel status
(2) Pthread_setcanceltype//Set thread cancellation type
(3) Pthread_testcancel//Set up a revocation point
(4) Pthread_cleanup_push/phtread_cleanup_pop//Set Cancel function execution interval

Part Two: Windows Threading API Basics
(1): CreateThread//Create thread
(2): ExitThread//End Thread
(3): WaitForSingleObject//wait for the end of a thread
(4): waitformultipleobjects//wait for multiple threads to end
(5): InitializeCriticalSection//Initialize critical section
(6): deletecriticalsection//Release critical area
(7): EnterCriticalSection//Enter the critical area
(8): LeaveCriticalSection//Exit critical section
(9): CreateMutex//Create a mutex
(Ten): ReleaseMutex//release of exclusive rights
(one): CreateSemaphore//Create Semaphore
(): ReleaseSemaphore//Release semaphore
(+): CreateEvent//Create an event
(+): SetEvent//set to excitation status
(): ResetEvent//set to non-excitation status
(en): PulseEvent//Reset


Part III: OSG Threading Framework
Cross-platform Abstraction thread
|-barrier
|-block
|-condition
|-mutex
|-readwritemutex
|-reentrantmutex
|-scopedlock
|-thread
Linux implementations
|
Windows implementation


Part IV: Ogre Threading Framework
Ogrethreadheaders
|-ogrethreadheadersboost
|-ogrethreadheaderspoco
|-ogrethreadtbb

Ogrethreaddefines
|-ogrethreaddefinesnone
|-ogrethreaddefinesboost
|-ogrethreaddefinespoco
|-ogrethreaddefinestbb

Ogredefaultworkqueue
|-ogredefaultworkqueuestandard
|-ogredefaultworkqueuetbb

Part V: My implementation with Apr line libraries Llthread



Three-dimensional engine design-multi-threaded rendering (Platform API Basics and Encapsulation outline framework)

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.