[rtems commit] libtest: Add T_get_thread_timer_state()

Sebastian Huber sebh at rtems.org
Mon Feb 8 07:55:29 UTC 2021


Module:    rtems
Branch:    master
Commit:    788fa865fbfa3340d07f72e407fdbe7a5c79ce93
Changeset: http://git.rtems.org/rtems/commit/?id=788fa865fbfa3340d07f72e407fdbe7a5c79ce93

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Feb  5 16:05:20 2021 +0100

libtest: Add T_get_thread_timer_state()

---

 cpukit/include/rtems/test.h        | 11 ++++++++++-
 cpukit/libtest/t-test-rtems-objs.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index f96a5a6..b42bf5f 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -1,7 +1,7 @@
 /*
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (C) 2017, 2020 embedded brains GmbH
+ * Copyright (C) 2017, 2021 embedded brains GmbH
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -2503,6 +2503,15 @@ void T_check_posix_shms(T_event, const char *);
 void T_check_posix_threads(T_event, const char *);
 
 void T_check_posix_timers(T_event, const char *);
+
+typedef enum {
+	T_THREAD_TIMER_NO_THREAD,
+	T_THREAD_TIMER_SCHEDULED,
+	T_THREAD_TIMER_PENDING,
+	T_THREAD_TIMER_INACTIVE
+} T_thread_timer_state;
+
+T_thread_timer_state T_get_thread_timer_state(uint32_t);
 #endif /* __rtems__ */
 
 /**
diff --git a/cpukit/libtest/t-test-rtems-objs.c b/cpukit/libtest/t-test-rtems-objs.c
index ed7222e..ad8d153 100644
--- a/cpukit/libtest/t-test-rtems-objs.c
+++ b/cpukit/libtest/t-test-rtems-objs.c
@@ -43,6 +43,35 @@
 
 #include <rtems/score/threadimpl.h>
 
+T_thread_timer_state
+T_get_thread_timer_state(uint32_t id)
+{
+	Thread_Control *the_thread;
+	ISR_lock_Context lock_context;
+	T_thread_timer_state state;
+
+	the_thread = _Thread_Get(id, &lock_context);
+	if (the_thread == NULL) {
+		return T_THREAD_TIMER_NO_THREAD;
+	}
+
+	switch (_Watchdog_Get_state(&the_thread->Timer.Watchdog)) {
+		case WATCHDOG_SCHEDULED_BLACK:
+		case WATCHDOG_SCHEDULED_RED:
+			state = T_THREAD_TIMER_SCHEDULED;
+			break;
+		case WATCHDOG_PENDING:
+			state = T_THREAD_TIMER_PENDING;
+			break;
+		default:
+			state = T_THREAD_TIMER_INACTIVE;
+			break;
+	}
+
+	_ISR_lock_ISR_enable(&lock_context);
+	return state;
+}
+
 Objects_Maximum
 T_objects_count(Objects_APIs api, uint16_t cls)
 {



More information about the vc mailing list