Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
時間
|
399
EFAULT
ts
是一個無效的指標。
EINVAL
clock_id
在此系統上是一個無效的時間來源。
下面的範例程式碼可以從四種標準的時間來源取得當前時間:
clockid_t clocks[] = {
CLOCK_REALTIME,
CLOCK_MONOTONIC,
CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID,
CLOCK_MONOTONIC_RAW,
(clockid_t)
1 };
int i;
for (i = 0; clocks[i] != (clockid_t)
1; i++) {
struct timespec ts;
int ret;
ret = clock_gettime (clocks[i], &ts);
if (ret)
perror ("clock_gettime");
else
printf ("clock=%d sec=%ld nsec=%ld\n",
clocks[i], ts.tv_sec, ts.tv_nsec);
}
取得行程時間
times()
系統呼叫可用於取得正在運行之行程與它的子行程的行程時間,以時鐘週期
clock tick)計:
#include <sys/times.h>
struct tms {
clock_t tms_utime; /* user time consumed */
clock_t tms_stime; /* system time consumed */
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769812