diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-14 20:38:19 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2024-10-14 20:38:19 +0530 |
commit | 86a968c3f424cb70e03cccb24cabf9751f6f636d (patch) | |
tree | 5aedd15a754e4c0de8a015a4fd2c2e5c0698a22b /wifi/wifi_legacy_service/1.0-legacy/THREADING.README | |
parent | ea30e6e77df9c7a651f22bcc5797b8a3f33703dc (diff) |
update gps stack
Diffstat (limited to 'wifi/wifi_legacy_service/1.0-legacy/THREADING.README')
-rw-r--r-- | wifi/wifi_legacy_service/1.0-legacy/THREADING.README | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/wifi/wifi_legacy_service/1.0-legacy/THREADING.README b/wifi/wifi_legacy_service/1.0-legacy/THREADING.README new file mode 100644 index 0000000..8366ca0 --- /dev/null +++ b/wifi/wifi_legacy_service/1.0-legacy/THREADING.README @@ -0,0 +1,35 @@ +Vendor HAL Threading Model +========================== +The vendor HAL service has two threads: +1. HIDL thread: This is the main thread which processes all the incoming HIDL +RPC's. +2. Legacy HAL event loop thread: This is the thread forked off for processing +the legacy HAL event loop (wifi_event_loop()). This thread is used to process +any asynchronous netlink events posted by the driver. Any asynchronous +callbacks passed to the legacy HAL API's are invoked on this thread. + +Synchronization Concerns +======================== +wifi_legacy_hal.cpp has a bunch of global "C" style functions to handle the +legacy callbacks. Each of these "C" style function invokes a corresponding +"std::function" version of the callback which does the actual processing. +The variables holding these "std::function" callbacks are reset from the HIDL +thread when they are no longer used. For example: stopGscan() will reset the +corresponding "on_gscan_*" callback variables which were set when startGscan() +was invoked. This is not thread safe since these callback variables are +accesed from the legacy hal event loop thread as well. + +Synchronization Solution +======================== +Adding a global lock seems to be the most trivial solution to the problem. +a) All of the asynchronous "C" style callbacks will acquire the global lock +before invoking the corresponding "std::function" callback variables. +b) All of the HIDL methods will also acquire the global lock before processing +(in hidl_return_util::validateAndCall()). + +Note: It's important that we only acquire the global lock for asynchronous +callbacks, because there is no guarantee (or documentation to clarify) that the +synchronous callbacks are invoked on the same invocation thread. If that is not +the case in some implementation, we will end up deadlocking the system since the +HIDL thread would have acquired the global lock which is needed by the +synchronous callback executed on the legacy hal event loop thread. |