Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions testing/ostest/sporadic.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,19 @@ static time_t g_start_time;

static void my_mdelay(unsigned int milliseconds)
{
volatile unsigned int i;
volatile unsigned int j;
struct timespec start;
struct timespec cur;
struct timespec diff;

for (i = 0; i < milliseconds; i++)
clock_gettime(CLOCK_MONOTONIC, &start);

for (; ; )
{
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
clock_gettime(CLOCK_MONOTONIC, &cur);
clock_timespec_subtract(&cur, &start, &diff);
if (diff.tv_sec * 1000 + diff.tv_nsec / 1000000 > milliseconds)
{
break;
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions testing/ostest/sporadic2.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ static int32_t g_ms_cnt2[2] =

static void my_mdelay(unsigned int milliseconds)
{
volatile unsigned int i;
volatile unsigned int j;
struct timespec start;
struct timespec cur;
struct timespec diff;

for (i = 0; i < milliseconds; i++)
clock_gettime(CLOCK_MONOTONIC, &start);

for (; ; )
{
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
clock_gettime(CLOCK_MONOTONIC, &cur);
clock_timespec_subtract(&cur, &start, &diff);
if (diff.tv_sec * 1000 + diff.tv_nsec / 1000000 > milliseconds)
{
break;
}
}
}
Expand Down Expand Up @@ -172,7 +178,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns)

sem_init(&g_sporadic_sem, 0, 0);

/* initilize global worker-thread millisecons-counters */
/* Initialize global worker-thread milliseconds-counters */

g_ms_cnt1[PRIO_HI_NDX] = 0;
g_ms_cnt1[PRIO_LO_NDX] = 0;
Expand Down
15 changes: 11 additions & 4 deletions testing/sched/smp/smp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>
Expand Down Expand Up @@ -87,13 +88,19 @@ static void show_cpu_conditional(FAR const char *caller, int threadno)

static void hog_milliseconds(unsigned int milliseconds)
{
volatile unsigned int i;
volatile unsigned int j;
struct timespec start;
struct timespec cur;
struct timespec diff;

for (i = 0; i < milliseconds; i++)
clock_gettime(CLOCK_MONOTONIC, &start);

for (; ; )
{
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
clock_gettime(CLOCK_MONOTONIC, &cur);
clock_timespec_subtract(&cur, &start, &diff);
if (diff.tv_sec * 1000 + diff.tv_nsec / 1000000 > milliseconds)
{
break;
}
}
}
Expand Down
Loading