Linux下高精度時間


Linux下高精度時間

time.h提供了精確到秒級的時間

		#include <time.h>
		time_t time(time_t *tloc);

為了獲取更高精度,我了解了一下timespec結構體

一、struct timespec定義

		struct timespec {
				time_t tv_sec; // seconds 
				long tv_nsec; // and nanoseconds 
		};
		
		#include<time.h>
		
		 int nanosleep(const struct timespec *req, struct timespec *rem);

nanosleep() suspends the execution of the calling thread until either at least the time specified in *req has elapsed, or the delivery of a signal that triggers the invocation of a handler in the calling thread or that terminates the process.

nanosleep()函數掛起呼叫線程知道req指定的時間消逝,或者一個觸發句柄請求信號的傳送,在呼叫線程或者終止進程。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM