mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
Include "tmacros.h".
Misc. changes related to rtems_intervals.
This commit is contained in:
@@ -29,6 +29,8 @@ rtems_task Init (rtems_task_argument argument);
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "tmacros.h"
|
||||||
|
|
||||||
rtems_interval ticksPerSecond;
|
rtems_interval ticksPerSecond;
|
||||||
rtems_task subtask(rtems_task_argument arg);
|
rtems_task subtask(rtems_task_argument arg);
|
||||||
void startTask(rtems_id arg);
|
void startTask(rtems_id arg);
|
||||||
@@ -83,7 +85,7 @@ rtems_task Init (rtems_task_argument ignored)
|
|||||||
|
|
||||||
ticksPerSecond = rtems_clock_get_ticks_per_second();
|
ticksPerSecond = rtems_clock_get_ticks_per_second();
|
||||||
if (ticksPerSecond <= 0) {
|
if (ticksPerSecond <= 0) {
|
||||||
printf ("Invalid ticks per second: %lu\n", (unsigned long) ticksPerSecond);
|
printf ("Invalid ticks per second: %" PRIdrtems_interval "\n", ticksPerSecond);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
sc = rtems_semaphore_create (rtems_build_name ('S', 'M', 'r', 'c'),
|
sc = rtems_semaphore_create (rtems_build_name ('S', 'M', 'r', 'c'),
|
||||||
@@ -174,16 +176,16 @@ rtems_task Init (rtems_task_argument ignored)
|
|||||||
startTask (semnorec);
|
startTask (semnorec);
|
||||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then);
|
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then);
|
||||||
for (i = 0 ; i < 5 ; i++) {
|
for (i = 0 ; i < 5 ; i++) {
|
||||||
int diff;
|
rtems_interval diff;
|
||||||
|
|
||||||
sc = rtems_semaphore_obtain (semnorec, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
|
sc = rtems_semaphore_obtain (semnorec, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
|
||||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now);
|
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now);
|
||||||
diff = (int) (now - then);
|
diff = (now - then);
|
||||||
then = now;
|
then = now;
|
||||||
if (sc != RTEMS_SUCCESSFUL)
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
printf ("%d: Failed to obtain non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
|
printf ("%d: Failed to obtain non-recursive-lock semaphore: %s\n", __LINE__, rtems_status_text (sc));
|
||||||
else if (diff < (int) (2 * ticksPerSecond))
|
else if (diff < (int) (2 * ticksPerSecond))
|
||||||
printf ("%d: Obtained obtain non-recursive-lock semaphore too quickly -- %d ticks not %d ticks\n", __LINE__, diff, (2 * ticksPerSecond) );
|
printf ("%d: Obtained obtain non-recursive-lock semaphore too quickly -- %" PRIdrtems_interval " ticks not %" PRIdrtems_interval " ticks\n", __LINE__, diff, (2 * ticksPerSecond) );
|
||||||
}
|
}
|
||||||
|
|
||||||
puts( "*** END OF TEST 29 ***" );
|
puts( "*** END OF TEST 29 ***" );
|
||||||
|
|||||||
Reference in New Issue
Block a user