kmsloop: Synchronize thread execution using condition variables

Change-Id: I75ca23c39b43bde5f81ec1e00e2726d7e1337610