pussuw commented on code in PR #15563:
URL: https://github.com/apache/nuttx/pull/15563#discussion_r1916606055
##########
arch/risc-v/include/irq.h:
##########
@@ -749,6 +749,34 @@ int up_this_cpu(void);
* Inline Functions
****************************************************************************/
+/****************************************************************************
+ * Schedule acceleration macros
+ ****************************************************************************/
+
+/* When thread local storage is disabled (the usual case), the TP
+ * (Thread Pointer) register is available for use as a general purpose
+ * register. We use it to store the current task's TCB pointer for quick
+ * access.
+ * Note: If you want to use TLS (CONFIG_SCHED_THREAD_LOCAL), your toolchain
+ * must be compiled with --enable-tls option to properly support
+ * thread-local storage.
+ */
+
+#ifndef CONFIG_SCHED_THREAD_LOCAL
+#define up_this_task() \
+ ({ \
+ struct tcb_s* t; \
+ __asm__ __volatile__("mv %0, tp" : "=r"(t)); \
+ t; \
+ })
+
+/* Update the current task pointer stored in TP register */
+#define up_update_task(t) \
Review Comment:
You should call this when a context switch occurs.
--
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]