summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwycwyhwyq <[email protected]>2025-03-12 18:17:35 +0800
committerRbb666 <[email protected]>2025-04-13 15:25:42 +0800
commitda1c5c788279dab423458dafa79a85c29a9e31f6 (patch)
tree128609b2c10a5b1080923c0c89e9c773be4a01e8 /src
parentf13193ff92e47c39436e0254062927a39450e04a (diff)
add RT_THREAD_CTRL_SET_PRIORITY
Diffstat (limited to 'src')
-rw-r--r--src/thread.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c
index 09cba18131..475ed9d5b2 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -779,6 +779,8 @@ RTM_EXPORT(rt_thread_mdelay);
*
* RT_THREAD_CTRL_BIND_CPU for bind the thread to a CPU.
*
+ * RT_THREAD_CTRL_SET_PRIORITY for set priority level of thread.
+ *
* @param arg is the argument of control command.
*
* @return Return the operation status. If the return value is RT_EOK, the function is successfully executed.
@@ -797,6 +799,16 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
rt_err_t error;
rt_sched_lock_level_t slvl;
rt_sched_lock(&slvl);
+ error = rt_sched_thread_change_priority(thread, *(rt_uint8_t *)arg);
+ rt_sched_unlock(slvl);
+ return error;
+ }
+
+ case RT_THREAD_CTRL_SET_PRIORITY:
+ {
+ rt_err_t error;
+ rt_sched_lock_level_t slvl;
+ rt_sched_lock(&slvl);
error = rt_sched_thread_set_priority(thread, *(rt_uint8_t *)arg);
rt_sched_unlock(slvl);
return error;