How to Fix the OS timestamp?

I am using the following settings:

timeSettings = world.get_settings()
timeSettings.synchronous_mode = True
timeSettings.fixed_delta_seconds = 0.1

Output of following is 0.1 and I am saving images at that rate.

deltaSeconds = world.get_snapshot().timestamp.delta_seconds

But I want to send data through serial and this is related to OS time. I am calculating OS time to process like this:

beforeOsTimestamp = world.get_snapshot().timestamp.platform_timestamp
print(“BEFORE Time register of the frame at which this measurement was taken”, beforeOsTimestamp)

world.tick()

afterOsTimestamp = world.get_snapshot().timestamp.platform_timestamp
print(“AFTER Time register of the frame at which this measurement was taken”, afterOsTmestamp)
print(“Os timestamp diff:ms”,(afterOsTimestamp-beforeOsTimestamp)*1000)

The OS time difference varies from 35 ms to 120 ms. How Do I get a fix OS timestamp (10 Hz or 0.1 s) to send data through serial at that rate?

I might be understanding you incorrectly but the fixed_delta_seconds has nothing to do with how long it takes the simulator to tick() once. fixed_delta_seconds defines the seconds simulated with each tick. The amount of time it takes to actually perform those calculations varies based on the host machine and is not constant, like any other application. you can read more about it here.
you can do some profiling to figure out how much it takes on average to perform one tick. Since the sensor data is returned via callback functions, it should be easy to plan your serial transmissions.