Fix-Point commented on code in PR #15044:
URL: https://github.com/apache/nuttx/pull/15044#discussion_r1877657421
##########
drivers/timers/arch_alarm.c:
##########
@@ -46,6 +46,7 @@ static FAR struct oneshot_lowerhalf_s *g_oneshot_lower;
#ifndef CONFIG_SCHED_TICKLESS
static clock_t g_current_tick;
+static clock_t g_base_tick;
Review Comment:
#include <nuttx/config.h>
#include <stdio.h>
#include <pthread.h>
#include <time.h>
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void *test_thread(void *arg)
{
struct timespec time;
clock_gettime(CLOCK_REALTIME, &time);
printf("[%ld.%ld] trying to get timedlock, curr_tick %ld\n", time.tv_sec,
time.tv_nsec,
clock_systime_ticks());
time.tv_sec += 2;
pthread_mutex_timedlock(&mutex, &time);
clock_gettime(CLOCK_REALTIME, &time);
printf("[%ld.%ld] failed to get timedlock, curr_tick %ld\n", time.tv_sec,
time.tv_nsec, clock_systime_ticks());
return NULL;
}
int main(int argc, FAR char *argv[])
{
pthread_t pthread;
pthread_mutex_lock(&mutex);
pthread_create(&pthread, NULL, (pthread_startroutine_t)test_thread, NULL);
pthread_join(pthread, NULL);
pthread_mutex_unlock(&mutex);
return 0;
}
##########
drivers/timers/arch_alarm.c:
##########
@@ -46,6 +46,7 @@ static FAR struct oneshot_lowerhalf_s *g_oneshot_lower;
#ifndef CONFIG_SCHED_TICKLESS
static clock_t g_current_tick;
+static clock_t g_base_tick;
Review Comment:
Can you provide the NuttX configuration? I am trying to reproduce the issue
with the test case showed below:
```c
#include <nuttx/config.h>
#include <stdio.h>
#include <pthread.h>
#include <time.h>
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void *test_thread(void *arg)
{
struct timespec time;
clock_gettime(CLOCK_REALTIME, &time);
printf("[%ld.%ld] trying to get timedlock, curr_tick %ld\n", time.tv_sec,
time.tv_nsec,
clock_systime_ticks());
time.tv_sec += 2;
pthread_mutex_timedlock(&mutex, &time);
clock_gettime(CLOCK_REALTIME, &time);
printf("[%ld.%ld] failed to get timedlock, curr_tick %ld\n", time.tv_sec,
time.tv_nsec, clock_systime_ticks());
return NULL;
}
int main(int argc, FAR char *argv[])
{
pthread_t pthread;
pthread_mutex_lock(&mutex);
pthread_create(&pthread, NULL, (pthread_startroutine_t)test_thread, NULL);
pthread_join(pthread, NULL);
pthread_mutex_unlock(&mutex);
return 0;
}
```
It seems OK on QEMU/x86_64 with `CONFIG_SCHED_TICKLESS` enabled.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]