1729 1730 #ifndef SOLARIS 1731 int status; 1732 if (_pthread_condattr_setclock != NULL && _clock_gettime != NULL) { 1733 if ((status = _pthread_condattr_setclock(_condAttr, CLOCK_MONOTONIC)) != 0) { 1734 if (status == EINVAL) { 1735 _use_clock_monotonic_condattr = false; 1736 warning("Unable to use monotonic clock with relative timed-waits" \ 1737 " - changes to the time-of-day clock may have adverse affects"); 1738 } else { 1739 fatal("pthread_condattr_setclock: %s", os::strerror(status)); 1740 } 1741 } else { 1742 _use_clock_monotonic_condattr = true; 1743 } 1744 } 1745 #endif // !SOLARIS 1746 1747 } 1748 1749 void os::Posix::init_2(void) { 1750 #ifndef SOLARIS 1751 log_info(os)("Use of CLOCK_MONOTONIC is%s supported", 1752 (_clock_gettime != NULL ? "" : " not")); 1753 log_info(os)("Use of pthread_condattr_setclock is%s supported", 1754 (_pthread_condattr_setclock != NULL ? "" : " not")); 1755 log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with %s", 1756 _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock"); 1757 #endif // !SOLARIS 1758 } 1759 1760 #else // !SUPPORTS_CLOCK_MONOTONIC 1761 1762 void os::Posix::init(void) { 1763 pthread_init_common(); 1764 } 1765 1766 void os::Posix::init_2(void) { 1767 #ifndef SOLARIS 1768 log_info(os)("Use of CLOCK_MONOTONIC is not supported"); 1769 log_info(os)("Use of pthread_condattr_setclock is not supported"); 1770 log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with the default clock"); 1771 #endif // !SOLARIS 1772 } 1773 1774 #endif // SUPPORTS_CLOCK_MONOTONIC 1775 1776 // Utility to convert the given timeout to an absolute timespec | 1729 1730 #ifndef SOLARIS 1731 int status; 1732 if (_pthread_condattr_setclock != NULL && _clock_gettime != NULL) { 1733 if ((status = _pthread_condattr_setclock(_condAttr, CLOCK_MONOTONIC)) != 0) { 1734 if (status == EINVAL) { 1735 _use_clock_monotonic_condattr = false; 1736 warning("Unable to use monotonic clock with relative timed-waits" \ 1737 " - changes to the time-of-day clock may have adverse affects"); 1738 } else { 1739 fatal("pthread_condattr_setclock: %s", os::strerror(status)); 1740 } 1741 } else { 1742 _use_clock_monotonic_condattr = true; 1743 } 1744 } 1745 #endif // !SOLARIS 1746 1747 } 1748 1749 #ifndef SOLARIS 1750 sigset_t sigs; 1751 struct sigaction sigact[NSIG]; 1752 1753 struct sigaction* os::Posix::get_preinstalled_handler(int sig) { 1754 if (sigismember(&sigs, sig)) { 1755 return &sigact[sig]; 1756 } 1757 return NULL; 1758 } 1759 1760 void os::Posix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { 1761 assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); 1762 sigact[sig] = oldAct; 1763 sigaddset(&sigs, sig); 1764 } 1765 #else 1766 static int *sigs = NULL; 1767 static struct sigaction *sigact = NULL; 1768 static int Maxsignum = 0; 1769 1770 struct sigaction* os::Posix::get_preinstalled_handler(int sig) { 1771 assert((sigact != (struct sigaction *)NULL) && 1772 (sigs != (int *)NULL), "signals not yet initialized"); 1773 if (sigs[sig] != 0) { 1774 return &sigact[sig]; 1775 } 1776 return NULL; 1777 } 1778 1779 void os::Posix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { 1780 assert(sig > 0 && sig <= Maxsignum, "vm signal out of expected range"); 1781 assert((sigact != (struct sigaction *)NULL) && 1782 (sigs != (int *)NULL), "signals not yet initialized"); 1783 sigact[sig] = oldAct; 1784 sigs[sig] = 1; 1785 } 1786 #endif 1787 1788 void os::Posix::init_2(void) { 1789 #ifndef SOLARIS 1790 log_info(os)("Use of CLOCK_MONOTONIC is%s supported", 1791 (_clock_gettime != NULL ? "" : " not")); 1792 log_info(os)("Use of pthread_condattr_setclock is%s supported", 1793 (_pthread_condattr_setclock != NULL ? "" : " not")); 1794 log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with %s", 1795 _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock"); 1796 sigemptyset(&sigs); 1797 #else 1798 Maxsignum = SIGRTMAX; 1799 if (UseSignalChaining) { 1800 sigact = (struct sigaction *)malloc(sizeof(struct sigaction) 1801 * (Maxsignum + 1), mtInternal); 1802 memset(sigact, 0, (sizeof(struct sigaction) * (Maxsignum + 1))); 1803 sigs = (int *)os::malloc(sizeof(int) * (Maxsignum + 1), mtInternal); 1804 memset(sigs, 0, (sizeof(int) * (Maxsignum + 1))); 1805 } 1806 #endif // !SOLARIS 1807 } 1808 1809 #else // !SUPPORTS_CLOCK_MONOTONIC 1810 1811 void os::Posix::init(void) { 1812 pthread_init_common(); 1813 } 1814 1815 void os::Posix::init_2(void) { 1816 #ifndef SOLARIS 1817 log_info(os)("Use of CLOCK_MONOTONIC is not supported"); 1818 log_info(os)("Use of pthread_condattr_setclock is not supported"); 1819 log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with the default clock"); 1820 #endif // !SOLARIS 1821 } 1822 1823 #endif // SUPPORTS_CLOCK_MONOTONIC 1824 1825 // Utility to convert the given timeout to an absolute timespec |