WapiHandle_process *process_handle;
pid_t pid G_GNUC_UNUSED, ret;
int status;
- gint64 start, now;
+ guint32 start;
+ guint32 now;
struct MonoProcess *mp;
/* FIXME: We can now easily wait on processes that aren't our own children,
#include <sys/time.h>
extern void _wapi_time_t_to_filetime (time_t timeval, WapiFileTime *filetime);
+extern void _wapi_timeval_to_filetime (struct timeval *tv,
+ WapiFileTime *filetime);
extern void _wapi_guint64_to_filetime (guint64 ticks, WapiFileTime *filetime);
#endif /* _WAPI_TIMEFUNCS_PRIVATE_H_ */
filetime->dwHighDateTime = ticks >> 32;
}
+void _wapi_timeval_to_filetime (struct timeval *tv, WapiFileTime *filetime)
+{
+ guint64 ticks;
+
+ ticks = ((guint64)tv->tv_sec * 10000000) +
+ ((guint64)tv->tv_usec * 10) + 116444736000000000ULL;
+ filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
+ filetime->dwHighDateTime = ticks >> 32;
+}
+
void _wapi_guint64_to_filetime (guint64 ticks, WapiFileTime *filetime)
{
filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
filetime->dwHighDateTime = ticks >> 32;
}
+
+gboolean QueryPerformanceCounter(WapiLargeInteger *count G_GNUC_UNUSED)
+{
+ return(FALSE);
+}
+
+gboolean QueryPerformanceFrequency(WapiLargeInteger *freq G_GNUC_UNUSED)
+{
+ return(FALSE);
+}
+
+guint32 GetTickCount (void)
+{
+ return mono_msec_ticks ();
+}
#endif
} WapiFileTime;
+extern gboolean QueryPerformanceCounter(WapiLargeInteger *count);
+extern gboolean QueryPerformanceFrequency(WapiLargeInteger *freq);
+extern guint32 GetTickCount (void);
+
G_END_DECLS
#endif /* _WAPI_TIME_H_ */
#define WSARecv wapi_WSARecv
#define WSASend wapi_WSASend
#define GetSystemInfo wapi_GetSystemInfo
+#define QueryPerformanceCounter wapi_QueryPerformanceCounter
+#define QueryPerformanceFrequency wapi_QueryPerformanceFrequency
+#define GetTickCount wapi_GetTickCount
#define GetFileVersionInfoSize wapi_GetFileVersionInfoSize
#define GetFileVersionInfo wapi_GetFileVersionInfo
#define VerQueryValue wapi_VerQueryValue
finished = TRUE;
if (mono_thread_internal_current () != gc_thread) {
gboolean timed_out = FALSE;
- gint64 start_ticks = mono_msec_ticks ();
- gint64 end_ticks = start_ticks + 2000;
+ guint32 start_ticks = mono_msec_ticks ();
+ guint32 end_ticks = start_ticks + 2000;
mono_gc_finalize_notify ();
/* Finishing the finalizer thread, so wait a little bit... */
/* MS seems to wait for about 2 seconds */
while (!finalizer_thread_exited) {
- gint64 current_ticks = mono_msec_ticks ();
+ guint32 current_ticks = mono_msec_ticks ();
guint32 timeout;
if (current_ticks >= end_ticks)
ICALL(ENV_11, "get_MachineName", ves_icall_System_Environment_get_MachineName)
ICALL(ENV_13, "get_Platform", ves_icall_System_Environment_get_Platform)
ICALL(ENV_14, "get_ProcessorCount", mono_cpu_count)
-ICALL(ENV_15, "get_TickCount", ves_icall_System_Environment_get_TickCount)
+ICALL(ENV_15, "get_TickCount", mono_msec_ticks)
ICALL(ENV_16, "get_UserName", ves_icall_System_Environment_get_UserName)
ICALL(ENV_16m, "internalBroadcastSettingChange", ves_icall_System_Environment_BroadcastSettingChange)
ICALL(ENV_17, "internalGetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable)
#endif
}
-ICALL_EXPORT
-gint32
-ves_icall_System_Environment_get_TickCount (void)
-{
- /* this will overflow after ~24 days */
- return (gint32) (mono_msec_boottime () & 0xffffffff);
-}
-
ICALL_EXPORT gint32
ves_icall_System_Runtime_Versioning_VersioningHelper_GetRuntimeId (void)
{
LockWord lw;
MonoThreadsSync *mon;
HANDLE sem;
- gint64 then = 0, now, delta;
+ guint32 then = 0, now, delta;
guint32 waitms;
guint32 ret;
guint32 new_status, old_status, tmp_status;
if (!mono_thread_test_state (mono_thread_internal_current (), (MonoThreadState)(ThreadState_StopRequested | ThreadState_SuspendRequested | ThreadState_AbortRequested))) {
if (ms != INFINITE) {
now = mono_msec_ticks ();
+ if (now < then) {
+ LOCK_DEBUG (g_message ("%s: wrapped around! now=0x%x then=0x%x", __func__, now, then));
- /* it should not overflow before ~30k years */
- g_assert (now >= then);
+ now += (0xffffffff - then);
+ then = 0;
+
+ LOCK_DEBUG (g_message ("%s: wrap rejig: now=0x%x then=0x%x delta=0x%x", __func__, now, then, now-then));
+ }
delta = now - then;
if (delta >= ms) {
MonoCoopMutex worker_creation_lock;
gint32 heuristic_completions;
- gint64 heuristic_sample_start;
- gint64 heuristic_last_dequeue; // ms
- gint64 heuristic_last_adjustment; // ms
- gint64 heuristic_adjustment_interval; // ms
+ guint32 heuristic_sample_start;
+ guint32 heuristic_last_dequeue; // ms
+ guint32 heuristic_last_adjustment; // ms
+ guint32 heuristic_adjustment_interval; // ms
ThreadPoolHillClimbing heuristic_hill_climbing;
MonoCoopMutex heuristic_lock;
static gboolean
monitor_sufficient_delay_since_last_dequeue (void)
{
- gint64 threshold;
+ guint32 threshold;
g_assert (threadpool);
mono_gc_set_skip_thread (TRUE);
do {
- gint64 ts;
+ guint32 ts;
gboolean alerted = FALSE;
if (mono_runtime_is_shutting_down ())
}
static gint16
-hill_climbing_update (gint16 current_thread_count, guint32 sample_duration, gint32 completions, gint64 *adjustment_interval)
+hill_climbing_update (gint16 current_thread_count, guint32 sample_duration, gint32 completions, guint32 *adjustment_interval)
{
ThreadPoolHillClimbing *hc;
ThreadPoolHeuristicStateTransition transition;
if (mono_coop_mutex_trylock (&threadpool->heuristic_lock) == 0) {
gint32 completions = InterlockedExchange (&threadpool->heuristic_completions, 0);
- gint64 sample_end = mono_msec_ticks ();
- gint64 sample_duration = sample_end - threadpool->heuristic_sample_start;
+ guint32 sample_end = mono_msec_ticks ();
+ guint32 sample_duration = sample_end - threadpool->heuristic_sample_start;
if (sample_duration >= threadpool->heuristic_adjustment_interval / 2) {
ThreadPoolCounter counter;
mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout)
{
gboolean res = TRUE;
- gint64 end;
+ guint32 start;
gpointer sem;
g_assert (domain);
g_assert (mono_domain_is_unloading (domain));
if (timeout != -1)
- end = mono_msec_ticks () + timeout;
+ start = mono_msec_ticks ();
#ifndef DISABLE_SOCKETS
mono_threadpool_ms_io_remove_domain_jobs (domain);
if (timeout != -1) {
- if (mono_msec_ticks () > end)
+ timeout -= mono_msec_ticks () - start;
+ if (timeout < 0)
return FALSE;
}
#endif
mono_memory_write_barrier ();
while (domain->threadpool_jobs) {
- gint64 now;
-
+ MONO_PREPARE_BLOCKING;
+ WaitForSingleObject (sem, timeout);
+ MONO_FINISH_BLOCKING;
if (timeout != -1) {
- now = mono_msec_ticks ();
- if (now > end) {
+ timeout -= mono_msec_ticks () - start;
+ if (timeout <= 0) {
res = FALSE;
break;
}
}
-
- MONO_PREPARE_BLOCKING;
- WaitForSingleObject (sem, timeout != -1 ? end - now : timeout);
- MONO_FINISH_BLOCKING;
}
domain->cleanup_semaphore = NULL;
#endif
abort_appdomain_data user_data;
- gint64 start_time;
+ guint32 start_time;
int orig_timeout = timeout;
int i;
int total = 0;
int fd = conn_fd;
int flags = 0;
- static gint64 last_keepalive;
- gint64 msecs;
+ static gint32 last_keepalive;
+ gint32 msecs;
MONO_PREPARE_BLOCKING;
if (*start_time == 0) {
static guint64 boot_time = 0;
if (!boot_time)
- boot_time = mono_100ns_datetime () - mono_msec_boottime () * 10000;
+ boot_time = mono_100ns_datetime () - ((guint64)mono_msec_ticks ()) * 10000;
*start_time = boot_time + mono_process_get_data (pid, MONO_PROCESS_ELAPSED);
}
#include <utils/mono-time.h>
-#define MTICKS_PER_SEC (10 * 1000 * 1000)
-
-gint64
-mono_msec_ticks (void)
-{
- return mono_100ns_ticks () / 10 / 1000;
-}
+#define MTICKS_PER_SEC 10000000
#ifdef HOST_WIN32
#include <windows.h>
-#ifndef _MSC_VER
-/* we get "error: implicit declaration of function 'GetTickCount64'" */
-ULONGLONG GetTickCount64(void);
-#endif
-
-gint64
-mono_msec_boottime (void)
+guint32
+mono_msec_ticks (void)
{
/* GetTickCount () is reportedly monotonic */
- return GetTickCount64 ();
+ return GetTickCount ();
}
/* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
}
/* Returns the number of milliseconds from boot time: this should be monotonic */
-gint64
-mono_msec_boottime (void)
+guint32
+mono_msec_ticks (void)
{
static gint64 boot_time = 0;
gint64 now;
boot_time = get_boot_time ();
now = mono_100ns_ticks ();
/*printf ("now: %llu (boot: %llu) ticks: %llu\n", (gint64)now, (gint64)boot_time, (gint64)(now - boot_time));*/
- g_assert (now > boot_time);
return (now - boot_time)/10000;
}
#include <sys/time.h>
#endif
-/* Returns the number of milliseconds from boot time: this should be monotonic
- *
- * Prefer to use mono_msec_ticks for elapsed time calculation. */
-gint64 mono_msec_boottime (void);
-
-/* Returns the number of milliseconds ticks from unspecified time: this should be monotonic */
-gint64 mono_msec_ticks (void);
+/* Returns the number of milliseconds from boot time: this should be monotonic */
+guint32 mono_msec_ticks (void);
/* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
-gint64 mono_100ns_ticks (void);
+gint64 mono_100ns_ticks (void);
/* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
-gint64 mono_100ns_datetime (void);
+gint64 mono_100ns_datetime (void);
#ifndef HOST_WIN32
gint64 mono_100ns_datetime_from_timeval (struct timeval tv);