// Global variable struct timespec tp; void * t_function(void * ctx) { while (1) { clock_gettime(CLOCK_MONOTONIC, &tp); } return NULL; } pthread_t t_thread; pthread_create(&t_thread, NULL, t_function, NULL); // `int messages' represents the number of messages to be sent for (int i = 0; i < messages; i++) { /** * Prepare WR with sge that points to tp.tv_nsec. It will * continue to change since the thread continues to run in the * background. */ // No need to invoke clock_gettime() here ibv_post_send(); // Post prepared WR }