void
mono_process_get_times (gpointer pid, gint64 *start_time, gint64 *user_time, gint64 *kernel_time)
{
    if (user_time)
        *user_time = mono_process_get_data (pid, MONO_PROCESS_USER_TIME);

    if (kernel_time)
        *kernel_time = mono_process_get_data (pid, MONO_PROCESS_SYSTEM_TIME);

    if (start_time) {
        *start_time = 0;

#if USE_SYSCTL && defined(kinfo_starttime_member)
        {
            KINFO_PROC processi;

            if (sysctl_kinfo_proc (pid, &processi))
                *start_time = mono_100ns_datetime_from_timeval (processi.kinfo_starttime_member);
        }
#endif

        if (*start_time == 0) {
            static guint64 boot_time = 0;
            if (!boot_time)
                boot_time = mono_100ns_datetime () - ((guint64)mono_msec_ticks ()) * 10000;

            *start_time = boot_time + mono_process_get_data (pid, MONO_PROCESS_ELAPSED);
        }
    }
}
Ejemplo n.º 2
0
/* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
gint64
mono_100ns_datetime (void)
{
	struct timeval tv;
	if (gettimeofday (&tv, NULL) == 0)
		return mono_100ns_datetime_from_timeval (tv);
	return 0;
}