xref: /minix/minix/kernel/system/do_times.c (revision 83133719)
1 /* The kernel call implemented in this file:
2  *   m_type:	SYS_TIMES
3  *
4  * The parameters for this kernel call are:
5  *   m_lsys_krn_sys_times.endpt		(get info for this process)
6  *   m_krn_lsys_sys_times.user_time	(return values ...)
7  *   m_krn_lsys_sys_times.system_time
8  *   m_krn_lsys_sys_times.boot_time
9  *   m_krn_lsys_sys_times.boot_ticks
10  *   m_krn_lsys_sys_times.real_ticks
11  */
12 
13 #include "kernel/system.h"
14 
15 #include <minix/endpoint.h>
16 
17 #if USE_TIMES
18 
19 /*===========================================================================*
20  *				do_times				     *
21  *===========================================================================*/
22 int do_times(struct proc * caller, message * m_ptr)
23 {
24 /* Handle sys_times().  Retrieve the accounting information. */
25   register const struct proc *rp;
26   int proc_nr;
27   endpoint_t e_proc_nr;
28 
29   /* Insert the times needed by the SYS_TIMES kernel call in the message.
30    * The clock's interrupt handler may run to update the user or system time
31    * while in this code, but that cannot do any harm.
32    */
33   e_proc_nr = (m_ptr->m_lsys_krn_sys_times.endpt == SELF) ?
34       caller->p_endpoint : m_ptr->m_lsys_krn_sys_times.endpt;
35   if(e_proc_nr != NONE && isokendpt(e_proc_nr, &proc_nr)) {
36       rp = proc_addr(proc_nr);
37       m_ptr->m_krn_lsys_sys_times.user_time   = rp->p_user_time;
38       m_ptr->m_krn_lsys_sys_times.system_time = rp->p_sys_time;
39   }
40   m_ptr->m_krn_lsys_sys_times.boot_ticks = get_monotonic();
41   m_ptr->m_krn_lsys_sys_times.real_ticks = get_realtime();
42   m_ptr->m_krn_lsys_sys_times.boot_time = boottime;
43   return(OK);
44 }
45 
46 #endif /* USE_TIMES */
47