< prev index next >

src/os/solaris/vm/os_solaris.cpp

Print this page




1800     st->print_cr("Error: Cannot print dynamic libraries.");
1801     return;
1802   }
1803   dlinfo(handle, RTLD_DI_LINKMAP, &map);
1804   if (map == NULL) {
1805     st->print_cr("Error: Cannot print dynamic libraries.");
1806     return;
1807   }
1808 
1809   while (map->l_prev != NULL)
1810     map = map->l_prev;
1811 
1812   while (map != NULL) {
1813     st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name);
1814     map = map->l_next;
1815   }
1816 
1817   dlclose(handle);
1818 }
1819 





































1820   // Loads .dll/.so and
1821   // in case of error it checks if .dll/.so was built for the
1822   // same architecture as Hotspot is running on
1823 
1824 void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
1825 {
1826   void * result= ::dlopen(filename, RTLD_LAZY);
1827   if (result != NULL) {
1828     // Successful loading
1829     return result;
1830   }
1831 
1832   Elf32_Ehdr elf_head;
1833 
1834   // Read system error message into ebuf
1835   // It may or may not be overwritten below
1836   ::strncpy(ebuf, ::dlerror(), ebuflen-1);
1837   ebuf[ebuflen-1]='\0';
1838   int diag_msg_max_length=ebuflen-strlen(ebuf);
1839   char* diag_msg_buf=ebuf+strlen(ebuf);


3240     if( ( res == 0 ) || ((res == OS_ERR) && (errno == EINTR))) {
3241       newtime = getTimeMillis();
3242       assert(newtime >= prevtime, "time moving backwards");
3243     /* Doing prevtime and newtime in microseconds doesn't help precision,
3244        and trying to round up to avoid lost milliseconds can result in a
3245        too-short delay. */
3246       millis -= newtime - prevtime;
3247       if(millis <= 0)
3248         return OS_OK;
3249       prevtime = newtime;
3250     } else
3251       return res;
3252   }
3253 
3254   return OS_OK;
3255 }
3256 
3257 // Read calls from inside the vm need to perform state transitions
3258 size_t os::read(int fd, void *buf, unsigned int nBytes) {
3259   INTERRUPTIBLE_RETURN_INT_VM(::read(fd, buf, nBytes), os::Solaris::clear_interrupted);









3260 }
3261 
3262 size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
3263   INTERRUPTIBLE_RETURN_INT(::read(fd, buf, nBytes), os::Solaris::clear_interrupted);
3264 }
3265 
3266 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
3267   assert(thread == Thread::current(),  "thread consistency check");
3268 
3269   // TODO-FIXME: this should be removed.
3270   // On Solaris machines (especially 2.5.1) we found that sometimes the VM gets into a live lock
3271   // situation with a JavaThread being starved out of a lwp. The kernel doesn't seem to generate
3272   // a SIGWAITING signal which would enable the threads library to create a new lwp for the starving
3273   // thread. We suspect that because the Watcher thread keeps waking up at periodic intervals the kernel
3274   // is fooled into believing that the system is making progress. In the code below we block the
3275   // the watcher thread while safepoint is in progress so that it would not appear as though the
3276   // system is making progress.
3277   if (!Solaris::T2_libthread() &&
3278       thread->is_Watcher_thread() && SafepointSynchronize::is_synchronizing() && !Arguments::has_profile()) {
3279     // We now try to acquire the threads lock. Since this lock is held by the VM thread during




1800     st->print_cr("Error: Cannot print dynamic libraries.");
1801     return;
1802   }
1803   dlinfo(handle, RTLD_DI_LINKMAP, &map);
1804   if (map == NULL) {
1805     st->print_cr("Error: Cannot print dynamic libraries.");
1806     return;
1807   }
1808 
1809   while (map->l_prev != NULL)
1810     map = map->l_prev;
1811 
1812   while (map != NULL) {
1813     st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name);
1814     map = map->l_next;
1815   }
1816 
1817   dlclose(handle);
1818 }
1819 
1820 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
1821   Dl_info dli;
1822   // Sanity check?
1823   if (dladdr(CAST_FROM_FN_PTR(void *, os::get_loaded_modules_info), &dli) == 0 ||
1824       dli.dli_fname == NULL) {
1825     return 1;
1826   }
1827 
1828   void * handle = dlopen(dli.dli_fname, RTLD_LAZY);
1829   if (handle == NULL) {
1830     return 1;
1831   }
1832 
1833   Link_map *map;
1834   dlinfo(handle, RTLD_DI_LINKMAP, &map);
1835   if (map == NULL) {
1836     dlclose(handle);
1837     return 1;
1838   }
1839 
1840   while (map->l_prev != NULL) {
1841     map = map->l_prev;
1842   }
1843 
1844   while (map != NULL) {
1845     // Iterate through all map entries and call callback with fields of interest
1846     if(callback(map->l_name, (address)map->l_addr, (address)0, param)) {
1847       dlclose(handle);
1848       return 1;
1849     }
1850     map = map->l_next;
1851   }
1852 
1853   dlclose(handle);
1854   return 0;
1855 }
1856 
1857   // Loads .dll/.so and
1858   // in case of error it checks if .dll/.so was built for the
1859   // same architecture as Hotspot is running on
1860 
1861 void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
1862 {
1863   void * result= ::dlopen(filename, RTLD_LAZY);
1864   if (result != NULL) {
1865     // Successful loading
1866     return result;
1867   }
1868 
1869   Elf32_Ehdr elf_head;
1870 
1871   // Read system error message into ebuf
1872   // It may or may not be overwritten below
1873   ::strncpy(ebuf, ::dlerror(), ebuflen-1);
1874   ebuf[ebuflen-1]='\0';
1875   int diag_msg_max_length=ebuflen-strlen(ebuf);
1876   char* diag_msg_buf=ebuf+strlen(ebuf);


3277     if( ( res == 0 ) || ((res == OS_ERR) && (errno == EINTR))) {
3278       newtime = getTimeMillis();
3279       assert(newtime >= prevtime, "time moving backwards");
3280     /* Doing prevtime and newtime in microseconds doesn't help precision,
3281        and trying to round up to avoid lost milliseconds can result in a
3282        too-short delay. */
3283       millis -= newtime - prevtime;
3284       if(millis <= 0)
3285         return OS_OK;
3286       prevtime = newtime;
3287     } else
3288       return res;
3289   }
3290 
3291   return OS_OK;
3292 }
3293 
3294 // Read calls from inside the vm need to perform state transitions
3295 size_t os::read(int fd, void *buf, unsigned int nBytes) {
3296   INTERRUPTIBLE_RETURN_INT_VM(::read(fd, buf, nBytes), os::Solaris::clear_interrupted);
3297 }
3298 
3299 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
3300   size_t res;
3301   JavaThread* thread = (JavaThread*)Thread::current();
3302   assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
3303   ThreadBlockInVM tbiv(thread);
3304   RESTARTABLE(::pread(fd, buf, (size_t) nBytes, offset), res);
3305   return res;
3306 }
3307 
3308 size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
3309   INTERRUPTIBLE_RETURN_INT(::read(fd, buf, nBytes), os::Solaris::clear_interrupted);
3310 }
3311 
3312 int os::sleep(Thread* thread, jlong millis, bool interruptible) {
3313   assert(thread == Thread::current(),  "thread consistency check");
3314 
3315   // TODO-FIXME: this should be removed.
3316   // On Solaris machines (especially 2.5.1) we found that sometimes the VM gets into a live lock
3317   // situation with a JavaThread being starved out of a lwp. The kernel doesn't seem to generate
3318   // a SIGWAITING signal which would enable the threads library to create a new lwp for the starving
3319   // thread. We suspect that because the Watcher thread keeps waking up at periodic intervals the kernel
3320   // is fooled into believing that the system is making progress. In the code below we block the
3321   // the watcher thread while safepoint is in progress so that it would not appear as though the
3322   // system is making progress.
3323   if (!Solaris::T2_libthread() &&
3324       thread->is_Watcher_thread() && SafepointSynchronize::is_synchronizing() && !Arguments::has_profile()) {
3325     // We now try to acquire the threads lock. Since this lock is held by the VM thread during


< prev index next >