Skip to content
Merged
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
15 changes: 13 additions & 2 deletions benchmarks/cyclictest/cyclictest.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static long arg_decimal(char *arg)
{
long ret;
char *endptr;

ret = strtol(arg, &endptr, 10);
if (endptr == arg)
{
Expand All @@ -220,6 +221,7 @@ static bool parse_args(int argc, char * const argv[])
int longindex;
int opt;
long decimal;

while ((opt = getopt_long(argc, argv, "c:d:D:h:Hi:l:m:n:p:qt:T:",
optargs, &longindex)) != -1)
{
Expand All @@ -231,9 +233,13 @@ static bool parse_args(int argc, char * const argv[])
{
return false;
}
else if (decimal == CLOCK_MONOTONIC || decimal == CLOCK_REALTIME)
else if (decimal == 0)
{
config.clock = decimal;
config.clock = CLOCK_REALTIME;
}
else if (decimal == 1)
{
config.clock = CLOCK_MONOTONIC;
}
break;
case 'd':
Expand Down Expand Up @@ -443,6 +449,7 @@ static inline void tsnorm(struct timespec *ts)
static inline int64_t timediff_us(struct timespec t1, struct timespec t2)
{
int64_t ret;

ret = 1000000 * (t1.tv_sec - t2.tv_sec);
ret += (t1.tv_nsec - t2.tv_nsec) / 1000;
return ret;
Expand All @@ -454,6 +461,7 @@ static inline int64_t timediff_us_timer(struct timer_status_s after,
int64_t ret = 0;
uint32_t t1;
uint32_t t2;

t1 = before.timeleft;
t2 = after.timeleft;
if (t2 < t1)
Expand Down Expand Up @@ -732,6 +740,7 @@ static void print_hist(struct thread_param_s *par[], int nthreads)
for (j = 0; j < nthreads; j++)
{
unsigned long curr_latency = par[j]->stats->hist_array[i];

printf("%06lu", curr_latency);
if (j < nthreads - 1)
{
Expand Down Expand Up @@ -824,6 +833,7 @@ static void print_stat(struct thread_param_s *par, int index)
{
struct thread_stats_s *stat = par->stats;
char *fmt;

fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu "
"Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n";
printf(fmt, index, stat->tid, par->prio, par->interval, stat->cycles,
Expand Down Expand Up @@ -1038,6 +1048,7 @@ int main(int argc, char *argv[])

usleep(100 * 1000);
int ended = 0;

for (i = 0; i < config.threads; ++i)
{
if (!config.quiet)
Expand Down
48 changes: 31 additions & 17 deletions testing/ostest/cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ static FAR void *sem_waiter(FAR void *parameter)
status = pthread_mutex_lock(&mutex);
if (status != 0)
{
printf("sem_waiter: ERROR pthread_mutex_lock failed, status=%d\n",
status);
ASSERT(false);
printf("sem_waiter: ERROR pthread_mutex_lock failed, status=%d\n",
status);
ASSERT(false);
}

sem_post(&sem_thread_started);
Expand All @@ -95,10 +95,10 @@ static FAR void *sem_waiter(FAR void *parameter)
status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if (status != 0)
{
printf("sem_waiter: "
"ERROR pthread_setcancelstate failed, status=%d\n",
status);
ASSERT(false);
printf("sem_waiter: "
"ERROR pthread_setcancelstate failed, status=%d\n",
status);
ASSERT(false);
}
}

Expand Down Expand Up @@ -269,10 +269,10 @@ static FAR void *asynch_waiter(FAR void *parameter)
status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if (status != 0)
{
printf("asynch_waiter: "
"ERROR pthread_setcancelstate failed, status=%d\n",
status);
ASSERT(false);
printf("asynch_waiter: "
"ERROR pthread_setcancelstate failed, status=%d\n",
status);
ASSERT(false);
}

/* Set the asynchronous cancellation type */
Expand All @@ -281,14 +281,14 @@ static FAR void *asynch_waiter(FAR void *parameter)
status = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
if (status != 0)
{
printf("asynch_waiter: "
"ERROR pthread_setcanceltype failed, status=%d\n",
status);
ASSERT(false);
printf("asynch_waiter: "
"ERROR pthread_setcanceltype failed, status=%d\n",
status);
ASSERT(false);
}

/* Then wait a bit. We should be canceled aynchronously while waiting, but
* the cancellation should pend because we are non-cancellable.
/* Then wait a bit. We should be canceled asynchronously while waiting,
* but the cancellation should pend because we are non-cancellable.
*/

usleep(250 * 1000);
Expand Down Expand Up @@ -388,6 +388,20 @@ static void restart_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter,
{
int status;

/* Broadcast the condition variable before destruction.
* This ensures that no threads are waiting on the condition variable
* before attempting to destroy it.
*/

printf("restart_thread: Broadcasting cond to clear waiters\n");
status = pthread_cond_broadcast(&cond);
if (status != 0)
{
printf("restart_thread: "
"ERROR pthread_cond_broadcast failed, status=%d\n", status);
ASSERT(false);
}

/* Destroy the condition variable */

printf("restart_thread: Destroying cond\n");
Expand Down
Loading