1 /* This file takes care of those system calls that deal with time.
3 * The entry points into this file are
4 * do_time: perform the TIME system call
5 * do_stime: perform the STIME system call
6 * do_times: perform the TIMES system call
10 #include <minix/callnr.h>
11 #include <minix/com.h>
16 /*===========================================================================*
18 *===========================================================================*/
21 /* Perform the time(tp) system call. This returns the time in seconds since
22 * 1.1.1970. MINIX is an astrophysically naive system that assumes the earth
23 * rotates at a constant rate and that such things as leap seconds do not
26 clock_t uptime
, boottime
;
29 if ( (s
=getuptime2(&uptime
, &boottime
)) != OK
)
30 panic("do_time couldn't get uptime: %d", s
);
32 mp
->mp_reply
.reply_time
= (time_t) (boottime
+ (uptime
/system_hz
));
33 mp
->mp_reply
.reply_utime
= (uptime
%system_hz
)*1000000/system_hz
;
37 /*===========================================================================*
39 *===========================================================================*/
42 /* Perform the stime(tp) system call. Retrieve the system's uptime (ticks
43 * since boot) and pass the new time in seconds at system boot to the kernel.
45 clock_t uptime
, boottime
;
48 if (mp
->mp_effuid
!= SUPER_USER
) {
51 if ( (s
=getuptime(&uptime
)) != OK
)
52 panic("do_stime couldn't get uptime: %d", s
);
53 boottime
= (long) m_in
.stime
- (uptime
/system_hz
);
55 s
= sys_stime(boottime
); /* Tell kernel about boottime */
57 panic("pm: sys_stime failed: %d", s
);
62 /*===========================================================================*
64 *===========================================================================*/
67 /* Perform the times(buffer) system call. */
68 register struct mproc
*rmp
= mp
;
69 clock_t user_time
, sys_time
, uptime
;
72 if (OK
!= (s
=sys_times(who_e
, &user_time
, &sys_time
, &uptime
, NULL
)))
73 panic("do_times couldn't get times: %d", s
);
74 rmp
->mp_reply
.reply_t1
= user_time
; /* user time */
75 rmp
->mp_reply
.reply_t2
= sys_time
; /* system time */
76 rmp
->mp_reply
.reply_t3
= rmp
->mp_child_utime
; /* child user time */
77 rmp
->mp_reply
.reply_t4
= rmp
->mp_child_stime
; /* child system time */
78 rmp
->mp_reply
.reply_t5
= uptime
; /* uptime since boot */