Clock in POSIX API
Joel Sherrill
joel.sherrill at OARcorp.com
Mon Mar 1 15:51:26 UTC 2004
I like easy ones. :)
You set the tv_sec to 10000 which is before the RTEMS epoch.
RTEMS does not allow dates before 1988 even in the POSIX API.
So 10,000 seconds is about 2 hours and 45 minutes after
the POSIX epoch of 1970 (about 0:2:45 January 1 1970).
--joel
Richard M. Barry wrote:
> I want to use the time of day in my (POSIX) application. So I need to set the realtime clock in the beginning of my application. I do this with a call to clock_settime(), but it returns with an error (errno==EINVAL). I can't figure out why, any ideas? I'm guessing it's some #define or #include that I left out, but I have no idea what. Part of the code follows:
>
>
> #define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_MAXIMUM_POSIX_THREADS 5
> #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 20
> #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 20
> #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 20
> #define CONFIGURE_POSIX_INIT_THREAD_TABLE
>
> #define CONFIGURE_MAXIMUM_POSIX_TIMERS 4
>
> #include <time.h>
> #include <sys/features.h>
> #include <errno.h>
> ...
>
> #ifndef _POSIX_TIMERS
> #error "rtems is supposed to have clock_settime"
> #endif
>
> ...
>
> void *POSIX_Init( void *argument )
> {
> struct timespec tim;
> time_t *now;
>
> tim.tv_sec = 10000; // Just a number, can be anything for what I care
> tim.tv_nsec = 0;
>
> status = clock_settime( CLOCK_REALTIME,&tim );
>
> if(status==-1)
> {
> printf("INIT: errno=%d , EINVAL=%d\n",errno,EINVAL);
> }
> assert(!status);
> ...
>
>
>
> Thanks,
> Richard
More information about the users
mailing list