NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Multiple Threads using Codec Engine Handle
Within a process, all threads can technically share the same Engine handle returned from Engine_open()
. However, as documented in the Engine_open()
API Reference Guide, this Engine handle is not thread-safe, meaning only one thread should use it at a time.
The common and recommended usage for multi-threaded applications is to, rather than have one thread obtain Engine handle and share it, have each thread independently call Engine_open()
to obtain its own Engine handle. As expected, before exiting, each thread should also call Engine_close()
.
The order is not important. In homogeneous multicore systems, the slave will be loaded when the first thread calls Engine_open()
; other Engine_open()
calls will return unique Engine handles, and increment a reference count on the slave device. Once the last thread calls Engine_close()
, the reference count will reach zero and the slave will be unloaded/stopped.
Finally, note that these details are all local to a single process. When multiple applications may need to use a slave processor, they should be configured to use the Link Arbiter Daemon - LAD.