Sharing dwContext across multiple processes

We have a setup where we run a separate process for different types of sensor captures (like camera, Lidar, GPS, etc.). Recently, we realized that a single context must be shared across all these processes. (Rather than requesting an independent context from Driveworks for each process)

We have a couple of related questions:

  • What's the recommended way to share a single instance of the context across separate processes?
  • Should we use a single instance of the SensorAbstractionLayer across processes as well?

Dear animeshramesh,
Sharing same context could lead to thread safety issues. Can you share more details about your use case on why you need same context to be shared?

Ok, that’s good to know. The documentation states:

"The NVIDIA® DriveWorks Context module stores all global components, such as:

  • Pointer logging callbacks
  • NvMedia Device instance
  • Global timesource
  • Platform information
  • Virtual file system"

We need all the sensor data to be timestamped against a common timeline (I believe this would be the system time). Since the context is responsible for a global timesource, we assumed that a single instance of the context must be shared across all the processes.

Could you please confirm if the sensor data is timestamped against the common system time if we use a separate context/SAL instance for each sensor?

Dear animeshramesh,
In mutlithread cases you can use one DwContext, but in multiprocess case you will have to use multiple contexts.

we only guarantee synced timestamps within the same context, however timestamps from multiple DwContext instances initialised from the same platform should return synced timestamps.