Esempio n. 1
0
void
call_omrthread_init(void)
{
	omrthread_library_t lib = GLOBAL_DATA(default_library);

#if defined(LINUX) || !defined(J9_PRIORITY_MAP) || defined(J9OS_I5) || defined(OSX)
	if (initialize_priority_map()) {
		goto thread_init_error;
	}
#endif /* defined(LINUX) || !defined(J9_PRIORITY_MAP) || defined(J9OS_I5) || defined(OSX) */

#ifdef J9ZOS390
	zos_init_yielding();
#endif

#if J9THREAD_USE_MONOTONIC_COND_CLOCK
	initCondAttr(); /* ignore the result */
#endif

	omrthread_init(lib);
	return;

thread_init_error:
	lib->initStatus = -1;
}
Esempio n. 2
0
/**
 * Perform OS-specific initializations for the threading library.
 *
 * @return 0 on success or non-zero value on failure.
 */
intptr_t
init_thread_library(void)
{
	omrthread_library_t lib = GLOBAL_DATA(default_library);
	if (lib->initStatus == 0) {
		HANDLE mutex = CreateMutex(NULL, TRUE, "omrthread_init_mutex");
		if (mutex == NULL) {
			return -1;
		}
		if (lib->initStatus == 0) {
			omrthread_init(lib);
			if (lib->initStatus == 1) {
				atexit(omrthread_shutdown_library);
			}
		}
		ReleaseMutex(mutex);
		CloseHandle(mutex);
	}
	return lib->initStatus != 1;
}