Identical behavior with xilinx-zynq-a9 (little - endian?). What frustrates me much more is the missing wait and the return value of pthread_cond_timedwait(&cond, &mutex, &timeout) and that also the join in main will never be reached.
qemu-system-arm -M xilinx-zynq-a9 -m 256M -no-reboot -serial null -serial mon:stdio -nographic -rtc base=localtime,clock=host -kernel build/arm-rtems6-xilinx_zynq_a9_qemu/posix_api/psx_example_2/psx_example_2.exe <main>: Wait for child thread... timeval : seconds : 8068 micro seconds : 567993600 timespec seconds : 8068000 nano seconds : 567993610 <child>: Hello World coming to wait! Error on pthread_cond_timedwait: Success With the format instructions you suggested, the output at least is ok: time tv_sec = 567993600, tv_usec = 4470 timeout tv_sec = 567993610, tv_nsec = 4470000 Danke, Heinz > On 13. Apr 2021, at 18:23, Gedare Bloom <[email protected]> wrote: > > Hi Heinz, > > On Tue, Apr 13, 2021 at 7:02 AM Heinz Junkes <[email protected]> wrote: >> >> Unfortunately I still do not understand it. Under Unix it runs perfectly and >> also the >> values are displayed correctly. >> > > #include <inttypes.h> > > [...] > printf("now tv_sec = %" PRIuLEAST64 ", tv_nsec = %d\n", now.tv_sec, > now.tv_nsec); > [...] > printf("timeout tv_sec = %" PRIuLEAST64 ", tv_nsec = %d\n", > timeout.tv_sec, timeout.tv_nsec); > > What you observe is an artifact of 32-/64-bit integer conversions in a > 32-bit big-endian architecture, I suspect. > >> In the debugger, the contents of the structure timespec are displayed >> correctly. >> >> Another point that probably makes the program hang: >> >> the function pthread_cond_timedwait(&cond, &mutex, &timeout) returns "1" and >> does not wait for the timeout. >> This return value should not exist at all? >> >> Under Unix, as expected, "110" is returned. ETIMOUT. >> >> Heinz >> >> >>> On 12. Apr 2021, at 20:38, Gedare Bloom <[email protected]> wrote: >>> >>> On Fri, Apr 9, 2021 at 11:45 AM Heinz Junkes <[email protected]> >>> wrote: >>>> >>>> Jiri, Joel, thanks for your answers. >>>> >>>> @Joel: I was wondering that rtems-examples in psx_example_3 does not wait >>>> 3 seconds. >>>> >>>> I made a curious observation: >>>> >>>> in the original code: >>>> >>>> clock_gettime( CLOCK_REALTIME, &timeout ); >>>> timeout.tv_sec += 3; >>>> timeout.tv_nsec = 0; >>>> printf("The task is coming to enter in a timed wait\n"); >>>> pthread_cond_timedwait(&cond, &mutex, &timeout); >>>> >>>> >>>> I then inserted some printfs and found that the "3" is added to the nsec’s. >>>> >>>> Then I added the rtems-timespec-helpers routines, but get the same >>>> behavior: >>>> >>>> >>>> void * print_hello(void * arg) >>>> { >>>> struct timespec now, timeout; >>>> rtems_timespec_set(&timeout, 3, 0); >>>> >>>> printf("<child>: Hello World! task with max priority \n"); >>>> clock_gettime( CLOCK_REALTIME, &now ); >>>> printf("now tv_sec = %d, tv_nsec = %d\n", now.tv_sec, now.tv_nsec); >>>> rtems_timespec_add_to(&timeout, &now); >>>> printf("timeout tv_sec = %d, tv_nsec = %d\n", timeout.tv_sec, >>>> timeout.tv_nsec); >>> >>> Please try with the appropriate type sizes and report back what you find. >>> >>> tv_sec is of type time_t >>> tv_nsec is of type long >>> >>> %d will only take 32b of those values, so you get some kind of garbage >>> (that can depend on endianness) >>> >>>> printf("The task is coming to enter in a timed wait\n"); >>>> pthread_cond_timedwait(&cond, &mutex, &timeout); >>>> printf("The task is coming out from the timed wait \n"); >>>> return NULL; >>>> } >>>> >>>> program output: >>>> >>>> <main> Enter in the main >>>> Creating first task >>>> <child>: Hello World! task with max priority >>>> now tv_sec = 4766459, tv_nsec = 567993600 >>>> timeout tv_sec = 4766459, tv_nsec = 567993603 >>>> The task is coming to enter in a timed wait >>>> The task is coming out from the timed wait >>>> First Task created >>>> Creating second task >>>> <child>: Hello World! Task with lowest priority Second task created >>>> <main> Out of the main >>>> >>>> If I now swap the arguments in the set-function , i.e. instead of >>>> rtems_timespec_set(&timeout, 3, 0); >>>> >>>> rtems_timespec_set(&timeout, 0, 3); >>>> >>>> it looks as it should >>>> >>>> <child>: Hello World! task with max priority >>>> now tv_sec = 10766729, tv_nsec = 567993600 >>>> timeout tv_sec = 10766732, tv_nsec = 567993600 >>>> The task is coming to enter in a timed wait >>>> The task is coming out from the timed wait >>>> First Task created >>>> Creating second task >>>> <child>: Hello World! Task with lowest priority Second task created >>>> <main> Out of the main >>>> >>>> But still no timed wait recognizable :-( >>>> >>>> Heinz >>>> >>>> >>>> >>>> _______________________________________________ >>>> users mailing list >>>> [email protected] >>>> http://lists.rtems.org/mailman/listinfo/users >>
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ users mailing list [email protected] http://lists.rtems.org/mailman/listinfo/users
