< prev index next >

src/share/vm/runtime/os.cpp

Print this page
rev 10257 : 8149036: Add tracing for thread related events at os level
Reviewed-by:


  43 #include "prims/privilegedStack.hpp"
  44 #include "runtime/arguments.hpp"
  45 #include "runtime/atomic.inline.hpp"
  46 #include "runtime/frame.inline.hpp"
  47 #include "runtime/interfaceSupport.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/javaCalls.hpp"
  50 #include "runtime/mutexLocker.hpp"
  51 #include "runtime/os.inline.hpp"
  52 #include "runtime/stubRoutines.hpp"
  53 #include "runtime/thread.inline.hpp"
  54 #include "runtime/vm_version.hpp"
  55 #include "services/attachListener.hpp"
  56 #include "services/mallocTracker.hpp"
  57 #include "services/memTracker.hpp"
  58 #include "services/nmtCommon.hpp"
  59 #include "services/threadService.hpp"
  60 #include "utilities/defaultStream.hpp"
  61 #include "utilities/events.hpp"
  62 

  63 # include <signal.h>
  64 
  65 OSThread*         os::_starting_thread    = NULL;
  66 address           os::_polling_page       = NULL;
  67 volatile int32_t* os::_mem_serialize_page = NULL;
  68 uintptr_t         os::_serialize_page_mask = 0;
  69 long              os::_rand_seed          = 1;
  70 int               os::_processor_count    = 0;
  71 size_t            os::_page_sizes[os::page_sizes_max];
  72 
  73 #ifndef PRODUCT
  74 julong os::num_mallocs = 0;         // # of calls to malloc/realloc
  75 julong os::alloc_bytes = 0;         // # of bytes allocated
  76 julong os::num_frees = 0;           // # of calls to free
  77 julong os::free_bytes = 0;          // # of bytes freed
  78 #endif
  79 
  80 static juint cur_malloc_words = 0;  // current size for MallocMaxTestWords
  81 
  82 void os_init_globals() {


1736       // Return small page size for values less than a small page.
1737       size_t small_page = small_page_size();
1738       size_t actual = os::page_size_for_region_unaligned(small_page - 17, 1);
1739       assert_eq(small_page, actual);
1740     }
1741   }
1742 
1743  public:
1744   static void run_tests() {
1745     test_page_size_for_region_aligned();
1746     test_page_size_for_region_alignment();
1747     test_page_size_for_region_unaligned();
1748   }
1749 };
1750 
1751 void TestOS_test() {
1752   TestOS::run_tests();
1753 }
1754 
1755 #endif // PRODUCT

































































































































































































































  43 #include "prims/privilegedStack.hpp"
  44 #include "runtime/arguments.hpp"
  45 #include "runtime/atomic.inline.hpp"
  46 #include "runtime/frame.inline.hpp"
  47 #include "runtime/interfaceSupport.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/javaCalls.hpp"
  50 #include "runtime/mutexLocker.hpp"
  51 #include "runtime/os.inline.hpp"
  52 #include "runtime/stubRoutines.hpp"
  53 #include "runtime/thread.inline.hpp"
  54 #include "runtime/vm_version.hpp"
  55 #include "services/attachListener.hpp"
  56 #include "services/mallocTracker.hpp"
  57 #include "services/memTracker.hpp"
  58 #include "services/nmtCommon.hpp"
  59 #include "services/threadService.hpp"
  60 #include "utilities/defaultStream.hpp"
  61 #include "utilities/events.hpp"
  62 
  63 # include <errno.h>
  64 # include <signal.h>
  65 
  66 OSThread*         os::_starting_thread    = NULL;
  67 address           os::_polling_page       = NULL;
  68 volatile int32_t* os::_mem_serialize_page = NULL;
  69 uintptr_t         os::_serialize_page_mask = 0;
  70 long              os::_rand_seed          = 1;
  71 int               os::_processor_count    = 0;
  72 size_t            os::_page_sizes[os::page_sizes_max];
  73 
  74 #ifndef PRODUCT
  75 julong os::num_mallocs = 0;         // # of calls to malloc/realloc
  76 julong os::alloc_bytes = 0;         // # of bytes allocated
  77 julong os::num_frees = 0;           // # of calls to free
  78 julong os::free_bytes = 0;          // # of bytes freed
  79 #endif
  80 
  81 static juint cur_malloc_words = 0;  // current size for MallocMaxTestWords
  82 
  83 void os_init_globals() {


1737       // Return small page size for values less than a small page.
1738       size_t small_page = small_page_size();
1739       size_t actual = os::page_size_for_region_unaligned(small_page - 17, 1);
1740       assert_eq(small_page, actual);
1741     }
1742   }
1743 
1744  public:
1745   static void run_tests() {
1746     test_page_size_for_region_aligned();
1747     test_page_size_for_region_alignment();
1748     test_page_size_for_region_unaligned();
1749   }
1750 };
1751 
1752 void TestOS_test() {
1753   TestOS::run_tests();
1754 }
1755 
1756 #endif // PRODUCT
1757 
1758 
1759 const char* os::errno_name(int err_no) {
1760   switch (err_no) {
1761   case E2BIG: return "E2BIG";
1762   case EACCES: return "EACCES";
1763 #ifdef EADDRINUSE
1764   case EADDRINUSE: return "EADDRINUSE";
1765 #endif
1766 #ifdef EADDRNOTAVAIL
1767   case EADDRNOTAVAIL: return "EADDRNOTAVAIL";
1768 #endif
1769 #ifdef EAFNOSUPPORT
1770   case EAFNOSUPPORT: return "EAFNOSUPPORT";
1771 #endif
1772   case EAGAIN: return "EAGAIN";
1773 #ifdef EALREADY
1774   case EALREADY: return "EALREADY";
1775 #endif
1776   case EBADF: return "EBADF";
1777 #ifdef EBADMSG
1778   case EBADMSG: return "EBADMSG";
1779 #endif
1780   case EBUSY: return "EBUSY";
1781 #ifdef ECANCELED
1782   case ECANCELED: return "ECANCELED";
1783 #endif
1784 #ifdef ECHILD
1785   case ECHILD: return "ECHILD";
1786 #endif
1787 #ifdef ECONNABORTED
1788   case ECONNABORTED: return "ECONNABORTED";
1789 #endif
1790 #ifdef ECONNREFUSED
1791   case ECONNREFUSED: return "ECONNREFUSED";
1792 #endif
1793 #ifdef ECONNRESET
1794   case ECONNRESET: return "ECONNRESET";
1795 #endif
1796 #ifdef EDEADLK
1797   case EDEADLK: return "EDEADLK";
1798 #endif
1799 #ifdef EDESTADDRREQ
1800   case EDESTADDRREQ: return "EDESTADDRREQ";
1801 #endif
1802 #ifdef EDOM
1803   case EDOM: return "EDOM";
1804 #endif
1805 #ifdef EDQUOT
1806   case EDQUOT: return "EDQUOT";
1807 #endif
1808 #ifdef EEXIST
1809   case EEXIST: return "EEXIST";
1810 #endif
1811   case EFAULT: return "EFAULT";
1812 #ifdef EFBIG
1813   case EFBIG: return "EFBIG";
1814 #endif
1815 #ifdef EHOSTUNREACH
1816   case EHOSTUNREACH: return "EHOSTUNREACH";
1817 #endif
1818 #ifdef EIDRM
1819   case EIDRM: return "EIDRM";
1820 #endif
1821 #ifdef EILSEQ
1822   case EILSEQ: return "EILSEQ";
1823 #endif
1824 #ifdef EINPROGRESS
1825   case EINPROGRESS: return "EINPROGRESS";
1826 #endif
1827   case EINTR: return "EINTR";
1828   case EINVAL: return "EINVAL";
1829 #ifdef EIO
1830   case EIO: return "EIO";
1831 #endif
1832 #ifdef EISCONN
1833   case EISCONN: return "EISCONN";
1834 #endif
1835   case EISDIR: return "EISDIR";
1836 #ifdef ELOOP
1837   case ELOOP: return "ELOOP";
1838 #endif
1839 #ifdef EMFILE
1840   case EMFILE: return "EMFILE";
1841 #endif
1842 #ifdef EMLINK
1843   case EMLINK: return "EMLINK";
1844 #endif
1845 #ifdef EMSGSIZE
1846   case EMSGSIZE: return "EMSGSIZE";
1847 #endif
1848 #ifdef EMULTIHOP
1849   case EMULTIHOP: return "EMULTIHOP";
1850 #endif
1851   case ENAMETOOLONG: return "ENAMETOOLONG";
1852 #ifdef ENETDOWN
1853   case ENETDOWN: return "ENETDOWN";
1854 #endif
1855 #ifdef ENETRESET
1856   case ENETRESET: return "ENETRESET";
1857 #endif
1858 #ifdef ENETUNREACH
1859   case ENETUNREACH: return "ENETUNREACH";
1860 #endif
1861 #ifdef ENFILE
1862   case ENFILE: return "ENFILE";
1863 #endif
1864 #ifdef ENOBUFS
1865   case ENOBUFS: return "ENOBUFS";
1866 #endif
1867 #ifdef ENODATA
1868   case ENODATA: return "ENODATA";
1869 #endif
1870 #ifdef ENODEV
1871   case ENODEV: return "ENODEV";
1872 #endif
1873   case ENOENT: return "ENOENT";
1874 #ifdef ENOEXEC
1875   case ENOEXEC: return "ENOEXEC";
1876 #endif
1877 #ifdef ENOLCK
1878   case ENOLCK: return "ENOLCK";
1879 #endif
1880 #ifdef ENOLINK
1881   case ENOLINK: return "ENOLINK";
1882 #endif
1883   case ENOMEM: return "ENOMEM";
1884 #ifdef ENOMSG
1885   case ENOMSG: return "ENOMSG";
1886 #endif
1887 #ifdef ENOPROTOOPT
1888   case ENOPROTOOPT: return "ENOPROTOOPT";
1889 #endif
1890 #ifdef ENOSPC
1891   case ENOSPC: return "ENOSPC";
1892 #endif
1893 #ifdef ENOSR
1894   case ENOSR: return "ENOSR";
1895 #endif
1896 #ifdef ENOSTR
1897   case ENOSTR: return "ENOSTR";
1898 #endif
1899 #ifdef ENOSYS
1900   case ENOSYS: return "ENOSYS";
1901 #endif
1902 #ifdef ENOTCONN
1903   case ENOTCONN: return "ENOTCONN";
1904 #endif
1905 #ifdef ENOTDIR
1906   case ENOTDIR: return "ENOTDIR";
1907 #endif
1908 // AIX: ENOTEMPTY == EEXIST
1909 #if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
1910   case ENOTEMPTY: return "ENOTEMPTY";
1911 #endif
1912 #ifdef ENOTSOCK
1913   case ENOTSOCK: return "ENOTSOCK";
1914 #endif
1915 #ifdef ENOTSUP
1916   case ENOTSUP: return "ENOTSUP";
1917 #endif
1918 #ifdef ENOTTY
1919   case ENOTTY: return "ENOTTY";
1920 #endif
1921 #ifdef ENXIO
1922   case ENXIO: return "ENXIO";
1923 #endif
1924 // on some unices EOPNOTSUPP==ENOTSUPP
1925 #if defined(ENOTSUP) && defined(EOPNOTSUPP) && (EOPNOTSUPP != ENOTSUP)
1926   case EOPNOTSUPP: return "EOPNOTSUPP";
1927 #endif
1928 #ifdef EOVERFLOW
1929   case EOVERFLOW: return "EOVERFLOW";
1930 #endif
1931 #ifdef EPERM
1932   case EPERM: return "EPERM";
1933 #endif
1934 #ifdef EPIPE
1935   case EPIPE: return "EPIPE";
1936 #endif
1937 #ifdef EPROTO
1938   case EPROTO: return "EPROTO";
1939 #endif
1940 #ifdef EPROTONOSUPPORT
1941   case EPROTONOSUPPORT: return "EPROTONOSUPPORT";
1942 #endif
1943 #ifdef EPROTOTYPE
1944   case EPROTOTYPE: return "EPROTOTYPE";
1945 #endif
1946   case ERANGE: return "ERANGE";
1947 #ifdef EROFS
1948   case EROFS: return "EROFS";
1949 #endif
1950 #ifdef ESPIPE
1951   case ESPIPE: return "ESPIPE";
1952 #endif
1953 #ifdef ESRCH
1954   case ESRCH: return "ESRCH";
1955 #endif
1956 #ifdef ESTALE
1957   case ESTALE: return "ESTALE";
1958 #endif
1959 #ifdef ETIME
1960   case ETIME: return "ETIME";
1961 #endif
1962 #ifdef ETIMEDOUT
1963   case ETIMEDOUT: return "ETIMEDOUT";
1964 #endif
1965 #ifdef ETXTBSY
1966   case ETXTBSY: return "ETXTBSY";
1967 #endif
1968 // on some unices EWOULDBLOCK==EAGAIN
1969 #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
1970   case EWOULDBLOCK: return "EWOULDBLOCK";
1971 #endif
1972 #ifdef EXDEV
1973   case EXDEV: return "EXDEV";
1974 #endif
1975   default: return "unknown";
1976   }
1977 }
1978 
1979 
< prev index next >