os.hpp revision 242
1008N/A * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 1008N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1008N/A * This code is free software; you can redistribute it and/or modify it 1008N/A * under the terms of the GNU General Public License version 2 only, as 1008N/A * published by the Free Software Foundation. 1008N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1008N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1008N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1008N/A * version 2 for more details (a copy is included in the LICENSE file that 1008N/A * You should have received a copy of the GNU General Public License version 1008N/A * 2 along with this work; if not, write to the Free Software Foundation, 1008N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1008N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1008N/A * CA 95054 USA or visit www.sun.com if you need additional information or 1008N/A// os defines the interface to operating system; this includes traditional 1008N/A// OS services (time, I/O) as well as other functionality with system- 1008N/A// Platform-independent error return values from OS functions 1008N/A // ensures that VMThread doesn't starve profiler 1008N/A// Typedef for structured exception handling support 1008N/A static void init(
void);
// Called before command line parsing 1008N/A // File names are case-insensitive on windows only 2345N/A // Returns the elapsed time in seconds since the vm started. 1548N/A // Returns real time in seconds since an arbitrary point 1565N/A // Interface to the performance counter 1565N/A // Return current local time in a string (YYYY-MM-DD HH:MM:SS). 1565N/A // It is MT safe, but not async-safe, as reading time zone 1548N/A // information may require a lock on some platforms. 1548N/A // Fill in buffer with current local time as an ISO-8601 string. 1548N/A // E.g., YYYY-MM-DDThh:mm:ss.mmm+zzzz. 1008N/A // Returns buffer, or NULL if it failed. 1008N/A // Interface for detecting multiprocessor system 1008N/A // Returns the number of CPUs this process is currently allowed to run on. 1008N/A // Note that on some OSes this can change dynamically. 1008N/A // Bind processes to processors. 1008N/A // This is a two step procedure: 1008N/A // first you generate a distribution of processes to processors, 1008N/A // then you bind processes according to that distribution. 1008N/A // Compute a distribution for number of processes to processors. 1008N/A // Stores the processor id's into the distribution array argument. 1008N/A // Returns true if it worked, false if it didn't. 1008N/A // Binds the current process to a processor. 1008N/A // Returns true if it worked, false if it didn't. 1008N/A // Interface for stack banging (predetect possible stack overflow for 1008N/A // exception processing) There are guard pages, and above that shadow 1008N/A // pages for stack overflow checking. 2872N/A // OS interface to Virtual Memory 2872N/A // Return the default page size. 2872N/A // Return the page size to use for a region of memory. The min_pages argument 2872N/A // is a hint intended to limit fragmentation; it says the returned page size 2872N/A // should be <= region_max_size / min_pages. Because min_pages is a hint, 2872N/A // this routine may return a size larger than region_max_size / min_pages. 2872N/A // The current implementation ignores min_pages if a larger page size is an 2872N/A // exact multiple of both region_min_size and region_max_size. This allows 2872N/A // larger pages to be used when doing so would not cause fragmentation; in 2872N/A // particular, a single page can be used when region_min_size == 2872N/A // region_max_size == a supported page size. 2872N/A // Method for tracing page sizes returned by the above method; enabled by 1548N/A // TracePageSizes. The region_{min,max}_size parameters should be the values 1548N/A // passed to page_size_for_region() and page_size should be the result of that 1548N/A // call. The (optional) base and size parameters should come from the 1548N/A // ReservedSpace base() and size() methods. 1008N/A // reserve, commit and pin the entire memory region 1008N/A // OS interface to polling page 1008N/A // Routines used to serialize the thread state without using membars 1008N/A // Since we write to the serialize page from every thread, we 1008N/A // want stores to be on unique cache lines whenever possible 1008N/A // in order to minimize CPU cross talk. We pre-compute the 1008N/A // amount to shift the thread* to make this offset unique to 1008N/A // Calculate thread specific address 1008N/A // TODO-FIXME: some platforms mask off faulting addresses to the base pagesize. 1008N/A // Instead of using a test for equality we should probably use something 1008N/A // return ((_mem_serialize_page ^ addr) & -pagesize) == 0 1008N/A // thread id on Linux/64bit is 64bit, on Windows and Solaris, it's 32bit 1008N/A // hpi::read for calls from non native state 1008N/A // For performance, hpi::read is only callable from _thread_in_native 1142N/A static void yield();
// Yields to all threads with same priority 1008N/A // platform-specific yield return immediately 1008N/A // YIELD_SWITCHED and YIELD_NONREADY imply the platform supports a "strong" 1008N/A // yield that can be used in lieu of blocking. 1008N/A // run cmd in a separate process and return its exit code; or -1 on failures 1008N/A // Set file to send error reports. 1008N/A // os::exit() is merged with vm_exit() 1008N/A // static void exit(int num); 1008N/A // Terminate the VM, but don't exit the process 1008N/A // Terminate with an error. Default is to generate a core file on platforms 1008N/A // that support such things. This calls shutdown() and then aborts. 1008N/A // Die immediately, no exit hook, no abort hook, no cleanup. 1008N/A // Dynamic library extension 1008N/A // Builds a platform-specific full library path given a ld path and lib name 1008N/A // Symbol lookup, find nearest function name; basically it implements 1008N/A // dladdr() for all platforms. Name of the nearest function is copied 1008N/A // to buf. Distance from its base address is returned as offset. 1008N/A // If function name is not found, buf[0] is set to '\0' and offset is 1008N/A // Locate DLL/DSO. On success, full path of the library is copied to 1008N/A // buf, and offset is set to be the distance between addr and the 1008N/A // library's base address. On failure, buf[0] is set to '\0' and 1008N/A // in case of error it checks if .dll/.so was built for the 1008N/A // same architecture as Hotspot is running on 1008N/A // lookup symbol in a shared library 1008N/A // Print out system information; they are called by fatal error handler. 1008N/A // Output format may be different on different platforms. 1008N/A // The following two functions are used by fatal error handler to trace 1008N/A // We don't attempt to become a debugger, so we only follow frames if that 1008N/A // does not require a lookup in the unwind table, which is part of the binary 1008N/A // file but may be unsafe to read after a fatal error. So on x86, we can 1008N/A // only walk stack if %ebp is used as frame pointer; on ia64, it's not 1008N/A // possible to walk C stack without having the unwind table. 1008N/A // return current frame. pc() and sp() are set to NULL on failure. 1008N/A // Returns native Java library, loads if necessary 1008N/A // Init os specific system properties values 1008N/A // IO operations, non-JVM_ version. 1008N/A // IO operations on binary files 1008N/A // General allocation (must be MT-safe) 2517N/A // Printing 64 bit integers 2517N/A // Support for signals (see JVM_RaiseSignal, JVM_RegisterSignal) 2517N/A // random number generation 2517N/A static long random();
// return 32bit pseudorandom number 2517N/A // Structured OS Exception support 2517N/A // JVMTI & JVM monitoring and management support 2517N/A // The thread_cpu_time() and current_thread_cpu_time() are only 2517N/A // supported if is_thread_cpu_time_supported() returns true. 2517N/A // They are not supported on Solaris T1. 2517N/A // Thread CPU Time - return the fast estimate on a platform 2517N/A // On Solaris - call gethrvtime (fast) - user time only 2517N/A // On Linux - fast clock_gettime where available - user+sys 2517N/A // - otherwise: very slow /proc fs - user+sys 2517N/A // On Windows - GetThreadTimes - user+sys 2517N/A // Thread CPU Time with user_sys_cpu_time parameter. 2517N/A // If user_sys_cpu_time is true, user+sys time is returned. 1008N/A // Otherwise, only user time is returned 1008N/A // Return a bunch of info about the timers. 1008N/A // Note that the returned info for these two functions may be different 2517N/A // System loadavg support. Returns -1 if load average cannot be obtained. 2517N/A // Hook for os specific jvm options that we don't want to abort on seeing 2517N/A // Platform dependent stuff 2517N/A // Thread priority helpers (implemented in OS-specific part) 2517N/A // Hint to the underlying OS that a task switch would not be good. 1008N/A // Void return because it's a hint and can fail. 1008N/A // Used at creation if requested by the diagnostic flag PauseAtStartup. 1008N/A // Causes the VM to wait until an external stimulus has been applied 1008N/A // (for Unix, that stimulus is a signal, for Windows, an external 1008N/A// Note that "PAUSE" is almost always used with synchronization 1008N/A// so arguably we should provide Atomic::SpinPause() instead 1008N/A// of the global SpinPause() with C linkage. 1008N/A// It'd also be eligible for inlining on many platforms.