This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Adding a new thread model to GCC

A glance over gthr.h reminds me __gthread_time_t. There seem few requirements documented in gthr.h.
I discussed this with Adrien Nader on mingw-w64's mailing list a few days ago.

Specifically, here are the two questions:
0) Should __gthread_time_t be a struct or a plain integral type?
The 'struct timespec' used by pthread is a struct introduced in POSIX.
However my implementation uses a plain uint64_t.
1) How to obtain a __gthread_time_t representing the current time?
According to Linux man pages, the timeout parameter of pthread_cond_timedwait() is the same as gettimeofday() - that is, it uses the wall clock.
My implementation uses GetTickCount64() - that is, my implementation uses a monotonic clock.

Quoting from ISO/IEC WG21 Draft N4582 (C++1z):
[quote] Class timed_mutex [thread.timedmutex.class]
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
the std::timed_mutex::try_lock_for() function template shall accept any clock type, hence we have to do timestamp translation. It is also important to know how libstdc++ handles this.

Best regards,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]