Android SystemProperties set and get may have latency analysis, androidsetget
First, the set and get implementations of SystemProperties are different. During set, you must use a local socket to communicate with the property service (init process,
After receiving the request, the property service then sets it to the property workspace (shared memory ).
But the property service (init process) is a single thread, so sometimes it may respond slowly (for example, it is shutting down a sub-process or is doing other things ),
Android found this problem during the design, so they took the measure to wait 250 ms after the set to ensure that read-after-write can work correctly most of the time,
However, Ms does not guarantee that the job can be correctly performed at all times, so we can consider this as a design defect. The annotations in the Android source code have already explained this point as follows:
In addition, the get of SystemProperties is obtained directly from the property workspace (shared memory) mapped to the process,
If the property service is busy waiting for MS, it still cannot be set to the property workspace (shared memory,
In this case, the old value of the error is obtained, instead of the new value just sent to the property service.
The implementation framework of SystemProperties is as follows:
How can I obtain the permission to call the "androidosSystemPropertiesset ()" method?
The SystemProperties. set () method of JNI is native.
How to add androidosSystemProperties in android
The tag of android. OS. SystemProperties is marked with @ hide, so the sdk does not exist.
If you need to use it, you must have the android source code support.