5142b1f388
Old realtime was used for both timers (where an accurate count of all ticks is needed) and the system time. In order to implement adjtime(2), these duties must be separated as changing the time of day by a small amount shouldn't affect timers in any way nor should it change the boot time. Following the naming of the clocks used by clock_gettime(2). The clock named 'realtime' will represent the best guess at the current wall clock time, and the clock named 'monotonic' will represent the absolute time the system has been running. Use monotonic for timers in kernel and in drivers. Use realtime for determining time of day, dates, etc. This commit simply renames realtime to monotonic and adds a new tick counter named realtime. There are no functional changes in this commit. It just lays the foundation for future work.
44 lines
1.3 KiB
C
44 lines
1.3 KiB
C
/* The kernel call implemented in this file:
|
|
* m_type: SYS_TIMES
|
|
*
|
|
* The parameters for this kernel call are:
|
|
* m4_l1: T_ENDPT (get info for this process)
|
|
* m4_l1: T_USER_TIME (return values ...)
|
|
* m4_l2: T_SYSTEM_TIME
|
|
* m4_l3: T_BOOTTIME
|
|
* m4_l5: T_BOOT_TICKS
|
|
*/
|
|
|
|
#include "kernel/system.h"
|
|
|
|
#include <minix/endpoint.h>
|
|
|
|
#if USE_TIMES
|
|
|
|
/*===========================================================================*
|
|
* do_times *
|
|
*===========================================================================*/
|
|
int do_times(struct proc * caller, message * m_ptr)
|
|
{
|
|
/* Handle sys_times(). Retrieve the accounting information. */
|
|
register const struct proc *rp;
|
|
int proc_nr;
|
|
endpoint_t e_proc_nr;
|
|
|
|
/* Insert the times needed by the SYS_TIMES kernel call in the message.
|
|
* The clock's interrupt handler may run to update the user or system time
|
|
* while in this code, but that cannot do any harm.
|
|
*/
|
|
e_proc_nr = (m_ptr->T_ENDPT == SELF) ? caller->p_endpoint : m_ptr->T_ENDPT;
|
|
if(e_proc_nr != NONE && isokendpt(e_proc_nr, &proc_nr)) {
|
|
rp = proc_addr(proc_nr);
|
|
m_ptr->T_USER_TIME = rp->p_user_time;
|
|
m_ptr->T_SYSTEM_TIME = rp->p_sys_time;
|
|
}
|
|
m_ptr->T_BOOT_TICKS = get_monotonic();
|
|
m_ptr->T_BOOTTIME = boottime;
|
|
return(OK);
|
|
}
|
|
|
|
#endif /* USE_TIMES */
|
|
|