princeton-sns / firecracker-tools

5 stars 5 forks source link

When a guest has two vcpus, busy loop implementation of waiting for a specified duration always read the same clock value. #19

Open tan-yue opened 5 years ago

tan-yue commented 5 years ago

Due to #18 , I tried this alternative approach with commit shown below:

start = int(time.clock() * 1000)
while int(time.clock() * 1000) - start < 500:
    pass

My test is based on firecracker@23b4387 on console branch and firerunner@bca73a7 on integrate branch.

This workaround works when the guest has one vcpu. But the loop effectively becomes an infinite loop if a guest has two vcpus because time.clock() always return the same value. Under the hood, for python2, time.clock() calls clock_gettime with clock id CLOCK_PROCESS_CPUTIME_ID