Skip to contentSkip to conversation

Add xn_sys_current_info

PATCH In review Jan Kiszka 1 participant 1 message Feb 25, 2009

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/2 Add xn_sys_current_info

Provide a new nucleus syscall for retrieving low-level information about the current thread in a skin-agnostic way. This is useful for building diagnosis services like the assert_context the following patch will introduce.

---

 include/asm-generic/syscall.h |   21 +++++++++++----------
 include/nucleus/thread.h      |   27 ++++++++++++++++++++++++++
 ksrc/nucleus/shadow.c         |   42 +++++++++++++++++++++++++++++++++++++----
 3 files changed, 76 insertions(+), 14 deletions(-)
include/asm-generic/syscall.h +11 -10
index c378ea9..cf3ea9d 100644
@@ -21,17 +21,18 @@
 #define _XENO_ASM_GENERIC_SYSCALL_H
 
 /* Xenomai multiplexer syscall. */
-#define __xn_sys_mux        555	/* Must fit within 15bit */
+#define __xn_sys_mux		555	/* Must fit within 15bit */
 /* Xenomai nucleus syscalls. */
-#define __xn_sys_bind       0	/* muxid = bind_to_interface(magic,featdep,abirev) */
-#define __xn_sys_completion 1	/* xnshadow_completion(&completion) */
-#define __xn_sys_migrate    2	/* switched = xnshadow_relax/harden() */
-#define __xn_sys_barrier    3	/* started = xnshadow_wait_barrier(&entry,&cookie) */
-#define __xn_sys_info       4	/* xnshadow_get_info(muxid,&info) */
-#define __xn_sys_arch       5	/* r = xnarch_local_syscall(args) */
-#define __xn_sys_trace      6	/* r = xntrace_xxx(...) */
-#define __xn_sys_sem_heap   7
-#define __xn_sys_current    8
+#define __xn_sys_bind		0	/* muxid = bind_to_interface(magic,featdep,abirev) */
+#define __xn_sys_completion	1	/* xnshadow_completion(&completion) */
+#define __xn_sys_migrate	2	/* switched = xnshadow_relax/harden() */
+#define __xn_sys_barrier	3	/* started = xnshadow_wait_barrier(&entry,&cookie) */
+#define __xn_sys_info		4	/* xnshadow_get_info(muxid,&info) */
+#define __xn_sys_arch		5	/* r = xnarch_local_syscall(args) */
+#define __xn_sys_trace		6	/* r = xntrace_xxx(...) */
+#define __xn_sys_sem_heap	7
+#define __xn_sys_current	8	/* threadh = xnthread_handle(cur) */
+#define __xn_sys_current_info	9	/* r = xnshadow_current_info(&info) */
 
 #define XENOMAI_LINUX_DOMAIN  0
 #define XENOMAI_XENO_DOMAIN   1
include/nucleus/thread.h +27 -0
index 27765ca..4e17000 100644
@@ -22,6 +22,8 @@
 #ifndef _XENO_NUCLEUS_THREAD_H
 #define _XENO_NUCLEUS_THREAD_H
 
+#include <nucleus/types.h>
+
 /*! @ingroup nucleus 
   @defgroup nucleus_state_flags Thread state flags.
   @brief Bits reporting permanent or transient states of thread.
@@ -121,6 +123,31 @@
 
 /*! @} */ /* Ends doxygen comment group: nucleus_info_flags */
 
+/*!
+  @brief Structure containing thread information.
+*/
+typedef struct xnthread_info {
+
+	unsigned long state; /**< Thread state, @see nucleus_state_flags */
+
+	int bprio;  /**< Base priority. */
+	int cprio; /**< Current priority. May change through Priority Inheritance.*/
+
+	int cpu; /**< CPU the thread currently runs on. */
+	unsigned long affinity; /**< Thread's CPU affinity. */
+
+	unsigned long long relpoint; /**< Time of next release.*/
+
+	unsigned long long exectime; /**< Execution time in primary mode in nanoseconds. */
+
+	unsigned long modeswitches; /**< Number of primary->secondary mode switches. */
+	unsigned long ctxswitches; /**< Number of context switches. */
+	unsigned long pagefaults; /**< Number of triggered page faults. */
+
+	char name[XNOBJECT_NAME_LEN];  /**< Symbolic name assigned at creation. */
+
+} xnthread_info_t;
+
 #if defined(__KERNEL__) || defined(__XENO_SIM__)
 
 #include <nucleus/stat.h>
ksrc/nucleus/shadow.c +38 -4

64 lines not on this page · raw message