MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / sys_setpriority

Function sys_setpriority

components/lwp/lwp_syscall.c:1621–1649  ·  view source on GitHub ↗

* @brief Sets the priority of a process, process group, or user. * * This system call sets the priority of a process, process group, or user, depending * on the value of the `which` argument. The priority is used by the operating system * for scheduling processes. Lower numerical values represent higher priority in many * systems, and the priority range may be system-specific. * * @param wh

Source from the content-addressed store, hash-verified

1619 * @see getpriority(), getpid(), getppid()
1620 */
1621sysret_t sys_setpriority(int which, id_t who, int prio)
1622{
1623 if (which == PRIO_PROCESS)
1624 {
1625 struct rt_lwp *lwp = RT_NULL;
1626
1627 lwp_pid_lock_take();
1628 lwp = lwp_from_pid_locked(who);
1629
1630 if (lwp && prio >= 0 && prio < RT_THREAD_PRIORITY_MAX)
1631 {
1632 rt_list_t *list;
1633 rt_thread_t thread;
1634 for (list = lwp->t_grp.next; list != &lwp->t_grp; list = list->next)
1635 {
1636 thread = rt_list_entry(list, struct rt_thread, sibling);
1637 rt_thread_control(thread, RT_THREAD_CTRL_RESET_PRIORITY, &prio);
1638 }
1639 lwp_pid_lock_release();
1640 return 0;
1641 }
1642 else
1643 {
1644 lwp_pid_lock_release();
1645 }
1646 }
1647
1648 return -1;
1649}
1650
1651/**
1652 * @brief Creates a semaphore.

Callers

nothing calls this directly

Calls 4

lwp_pid_lock_takeFunction · 0.85
lwp_from_pid_lockedFunction · 0.85
rt_thread_controlFunction · 0.85
lwp_pid_lock_releaseFunction · 0.85

Tested by

no test coverage detected