From ed1a47268c0b22dd7ccb886521fcb18120f77cd4 Mon Sep 17 00:00:00 2001 From: chendi Date: Tue, 23 Jul 2024 14:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5=EF=BC=8Cru?= =?UTF-8?q?nningTid=E4=B8=8A=E7=A7=BB=E8=87=B3CoTask?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chendi Change-Id: Ib973736e507b13680f5c286b8f02c246f9a70e15 --- interfaces/inner_api/c/executor_task.h | 9 ++++++++- src/core/task.cpp | 6 +++--- src/tm/cpu_task.h | 2 -- src/tm/task_base.h | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/interfaces/inner_api/c/executor_task.h b/interfaces/inner_api/c/executor_task.h index db98da1..67e19b9 100644 --- a/interfaces/inner_api/c/executor_task.h +++ b/interfaces/inner_api/c/executor_task.h @@ -105,5 +105,12 @@ FFRT_C_API void ffrt_task_attr_set_local(ffrt_task_attr_t* attr, bool task_local */ FFRT_C_API bool ffrt_task_attr_get_local(ffrt_task_attr_t* attr); -FFRT_C_API pthread_t ffrt_task_get_tid(void* taskHandle); +/** + * @brief Obtains the thread id of the input task handle. + * + * @param task_handle The task pointer. + * @return The thread id of the input task handle. + * @version 1.0 + */ +FFRT_C_API pthread_t ffrt_task_get_tid(void* task_handle); #endif \ No newline at end of file diff --git a/src/core/task.cpp b/src/core/task.cpp index 62d7686..c3d4e77 100644 --- a/src/core/task.cpp +++ b/src/core/task.cpp @@ -601,14 +601,14 @@ bool ffrt_task_attr_get_local(ffrt_task_attr_t* attr) } API_ATTRIBUTE((visibility("default"))) -pthread_t ffrt_task_get_tid(void* taskHandle) +pthread_t ffrt_task_get_tid(void* task_handle) { - if (taskHandle == nullptr) { + if (task_handle == nullptr) { FFRT_LOGE("invalid task handle"); return 0; } - auto task = reinterpret_cast(taskHandle); + auto task = reinterpret_cast(task_handle); return task->runningTid.load(); } #ifdef __cplusplus diff --git a/src/tm/cpu_task.h b/src/tm/cpu_task.h index e798ff6..2cb05c2 100644 --- a/src/tm/cpu_task.h +++ b/src/tm/cpu_task.h @@ -80,8 +80,6 @@ public: void SetQos(QoS& newQos); uint64_t reserved[8]; - std::atomic runningTid = 0; - void FreeMem() override; void Execute() override; diff --git a/src/tm/task_base.h b/src/tm/task_base.h index eae0407..f2b2e24 100644 --- a/src/tm/task_base.h +++ b/src/tm/task_base.h @@ -51,6 +51,7 @@ public: // |**********coroutine*********| CoRoutine* coRoutine = nullptr; uint64_t stack_size = STACK_SIZE; + std::atomic runningTid = 0; }; } #endif \ No newline at end of file