moving to clock_gettime and add correction of time spent in freezed state.