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
29 if ( (s
=getuptime(&uptime
)) != OK
)
30 panic(__FILE__
,"do_time couldn't get uptime", s
);
32 mp
->mp_reply
.reply_time
= (time_t) (boottime
+ (uptime
/HZ
));
33 mp
->mp_reply
.reply_utime
= (uptime
%HZ
)*1000000/HZ
;
37 /*===========================================================================*
39 *===========================================================================*/
42 /* Perform the stime(tp) system call. Retrieve the system's uptime (ticks
43 * since boot) and store the time in seconds at system boot in the global
44 * variable 'boottime'.
49 if (mp
->mp_effuid
!= SUPER_USER
) {
52 if ( (s
=getuptime(&uptime
)) != OK
)
53 panic(__FILE__
,"do_stime couldn't get uptime", s
);
54 boottime
= (long) m_in
.stime
- (uptime
/HZ
);
56 if (mp
->mp_fs_call
!= PM_IDLE
)
57 panic("pm", "do_stime: not idle", mp
->mp_fs_call
);
58 mp
->mp_fs_call
= PM_STIME
;
59 s
= notify(FS_PROC_NR
);
60 if (s
!= OK
) panic("pm", "do_stime: unable to notify FS", s
);
62 /* Do not reply until FS is ready to process the stime request */
66 /*===========================================================================*
68 *===========================================================================*/
71 /* Perform the times(buffer) system call. */
72 register struct mproc
*rmp
= mp
;
76 if (OK
!= (s
=sys_times(who_e
, t
)))
77 panic(__FILE__
,"do_times couldn't get times", s
);
78 rmp
->mp_reply
.reply_t1
= t
[0]; /* user time */
79 rmp
->mp_reply
.reply_t2
= t
[1]; /* system time */
80 rmp
->mp_reply
.reply_t3
= rmp
->mp_child_utime
; /* child user time */
81 rmp
->mp_reply
.reply_t4
= rmp
->mp_child_stime
; /* child system time */
82 rmp
->mp_reply
.reply_t5
= t
[4]; /* uptime since boot */