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

Function sys_getpriority

components/lwp/lwp_syscall.c:1568–1589  ·  view source on GitHub ↗

* @brief Retrieves the priority of a process or process group. * * This system call returns the priority of a process or a process group, depending on * the value of the `which` argument. * * @param which The entity for which the priority is being requested. Possible values include: * - `PRIO_PROCESS`: Retrieves the priority of the process specified by `who`. * - `

Source from the content-addressed store, hash-verified

1566 * @see setpriority(), getpid(), getppid()
1567 */
1568sysret_t sys_getpriority(int which, id_t who)
1569{
1570 long prio = 0xff;
1571
1572 if (which == PRIO_PROCESS)
1573 {
1574 struct rt_lwp *lwp = RT_NULL;
1575
1576 lwp_pid_lock_take();
1577 lwp = lwp_from_pid_locked(who);
1578
1579 if (lwp)
1580 {
1581 rt_thread_t thread = rt_list_entry(lwp->t_grp.prev, struct rt_thread, sibling);
1582 prio = RT_SCHED_PRIV(thread).current_priority;
1583 }
1584
1585 lwp_pid_lock_release();
1586 }
1587
1588 return prio;
1589}
1590
1591/**
1592 * @brief Sets the priority of a process, process group, or user.

Callers

nothing calls this directly

Calls 3

lwp_pid_lock_takeFunction · 0.85
lwp_from_pid_lockedFunction · 0.85
lwp_pid_lock_releaseFunction · 0.85

Tested by

no test coverage detected