12 class MyThread
: public Thread
24 SemLock(Semaphore
& sem
) : m_sem(sem
) {
37 * Return time difference between two struct timeval's, in seconds
38 * \param t0 start time
41 double Diff(struct timeval t0
,struct timeval t
)
43 t
.tv_sec
-= t0
.tv_sec
;
44 t
.tv_usec
-= t0
.tv_usec
;
50 return t
.tv_sec
+ (double)t
.tv_usec
/ 1000000;
56 void lock(Mutex
& m
, int i
)
63 void lock(Semaphore
& s
, int i
)
80 Utility::GetTime(&start
);
81 for (int i
= 0; i
< 100000; i
++)
83 Utility::GetTime(&tt
);
85 printf("%.4f sec\n", d
);
87 Utility::GetTime(&start
);
88 for (int i
= 0; i
< 100000; i
++)
90 Utility::GetTime(&tt
);
92 printf("%.4f sec\n", d
);