
This functionality is required for BSD top(1), as exposed through the CTL_KERN KERN_CP_TIME sysctl(2) call. The idea is that the overall time spent in the system is divided into five categories. While NetBSD uses a separate category for the kernel ("system") and interrupts, we redefine "system" to mean userspace system services and "interrupts" to mean time spent in the kernel, thereby providing the same categories as MINIX3's own top(1), while adding the "nice" category which, like on NetBSD, is used for time spent by processes with a priority lowered by the system administrator. Change-Id: I2114148d1e07d9635055ceca7b163f337c53c43a
31 lines
878 B
C
31 lines
878 B
C
#include "kernel/system.h"
|
|
#include <minix/endpoint.h>
|
|
#include "kernel/clock.h"
|
|
|
|
/*===========================================================================*
|
|
* do_schedule *
|
|
*===========================================================================*/
|
|
int do_schedule(struct proc * caller, message * m_ptr)
|
|
{
|
|
struct proc *p;
|
|
int proc_nr;
|
|
int priority, quantum, cpu, niced;
|
|
|
|
if (!isokendpt(m_ptr->m_lsys_krn_schedule.endpoint, &proc_nr))
|
|
return EINVAL;
|
|
|
|
p = proc_addr(proc_nr);
|
|
|
|
/* Only this process' scheduler can schedule it */
|
|
if (caller != p->p_scheduler)
|
|
return(EPERM);
|
|
|
|
/* Try to schedule the process. */
|
|
priority = m_ptr->m_lsys_krn_schedule.priority;
|
|
quantum = m_ptr->m_lsys_krn_schedule.quantum;
|
|
cpu = m_ptr->m_lsys_krn_schedule.cpu;
|
|
niced = !!(m_ptr->m_lsys_krn_schedule.niced);
|
|
|
|
return sched_proc(p, priority, quantum, cpu, niced);
|
|
}
|