Training
×

Interthread Communication Summary

Mailboxes, message queues, semaphores and regions allow information AND control to be exchanged between threads. A message is sent to a mailbox or message queue, NOT to a thread.
Semaphores and regions can be used to establish a protocol for mutual exclusion. No specific data or piece of code is associated with either type of object.
The operation of all exchanges is very similar. All have thread queues which are either FIFO or priority based. Specific system calls must be used with each type of exchange. System calls can be made both from INtime or Windows (then prefixed by ntx).
A thread specifies a time, in milliseconds, that it is willing to wait for a message or unit. If that time expires, or the thread is not willing to wait at all, the thread will receive an E_TIME exception code.
If the exchange is deleted while a thread is waiting, the thread is awakened with an E_EXIST exception code.
 
Shared memory allows very efficient exchange of information between threads. Exchange of data with shared memory normally is coordinated using semaphores or regions.
Note: Creation of a memory handle (and allocation of memory) can only be done in INtime, not in Windows (no ntx version).