xiaoxiang781216 commented on code in PR #3000: URL: https://github.com/apache/nuttx-apps/pull/3000#discussion_r1958106038
########## benchmarks/cyclictest/cyclictest.c: ########## @@ -0,0 +1,1066 @@ +/**************************************************************************** + * apps/benchmarks/cyclictest/cyclictest.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * A NuttX port of the cyclictest rt-tests utility for Linux. + * As of writing this piece of software (Feb 2025), clock_gettime + * and clock_nanosleep are tightly tied to systemtick by default. + * Yes, the time resolution can be achieved by using TICKLESS, but for high + * resolution waiting and measurement we can use other methods. + * + * This piece of software includes configurable waiting methods: + * - clock_nanosleep + * - systemtick hook: it is assumed your BSP supports a board_timerhook + * function where a sem_t g_waitsem is posted. + * - WARNING: only one task (thread) can wait for the semaphore. + * - NuttX Timer API: waiting for the timer to expire. + * - WARNING: only one task (thread) can wait for the timer to expire. + * + * Available time measuring methods: + * - clock_gettime + * - NuttX Timer API + * + * Authors of the NuttX port: Stepan Pressl <pressl.ste...@gmail.com> + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <sched.h> +#include <limits.h> +#include <stdint.h> +#include <stdio.h> +#include <getopt.h> +#include <stdlib.h> +#include <assert.h> +#include <stdbool.h> +#include <string.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <time.h> +#include <unistd.h> +#include <pthread.h> +#include <poll.h> +#include <fcntl.h> + +#include <nuttx/timers/timer.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#ifdef CONFIG_SYSTEMTICK_HOOK +extern sem_t g_waitsem; Review Comment: why not sem_open to share the same sem with kernel side -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org