MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_sched_setparam

Function sys_sched_setparam

components/lwp/lwp_syscall.c:8765–8800  ·  view source on GitHub ↗

* @brief Set scheduling parameters for a specific thread. * * This function allows setting the scheduling parameters for a thread identified by its thread ID (`tid`). * The parameters are provided via the `param` argument, which should be a structure compatible with the * system's scheduling policies. * * @param[in] tid The thread ID of the target thread for which the scheduling parameters a

Source from the content-addressed store, hash-verified

8763 * The exact structure and fields of `param` depend on the system's implementation and scheduling policies.
8764 */
8765sysret_t sys_sched_setparam(pid_t tid, void *param)
8766{
8767 struct sched_param *sched_param = RT_NULL;
8768 rt_thread_t thread;
8769 int ret = -1;
8770
8771 if (!lwp_user_accessable(param, sizeof(struct sched_param)))
8772 {
8773 return -EFAULT;
8774 }
8775
8776 sched_param = kmem_get(sizeof(struct sched_param));
8777 if (sched_param == RT_NULL)
8778 {
8779 return -ENOMEM;
8780 }
8781
8782 if (lwp_get_from_user(sched_param, param, sizeof(struct sched_param)) != sizeof(struct sched_param))
8783 {
8784 kmem_put(sched_param);
8785 return -EINVAL;
8786 }
8787
8788 thread = lwp_tid_get_thread_and_inc_ref(tid);
8789
8790 if (thread)
8791 {
8792 ret = rt_thread_control(thread, RT_THREAD_CTRL_RESET_PRIORITY, (void *)&sched_param->sched_priority);
8793 }
8794
8795 lwp_tid_dec_ref(thread);
8796
8797 kmem_put(sched_param);
8798
8799 return ret;
8800}
8801
8802/**
8803 * @brief Relinquish the processor voluntarily.

Callers

nothing calls this directly

Calls 7

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
rt_thread_controlFunction · 0.85
lwp_tid_dec_refFunction · 0.85

Tested by

no test coverage detected