In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail the differences between jdk1.8u131 and jdk1.8u222 cpu acquisition methods. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
How to get the cpu of JDK1.8u222
Int OSContainer::active_processor_count () {
Int quota_count = 0, share_count = 0
Int cpu_count, limit_count
Int result
Cpu_count = limit_count = os::Linux::active_processor_count ()
Int quota = cpu_quota ()
Int period = cpu_period ()
Int share = cpu_shares ()
If (quota >-1 & & period > 0) {
Quota_count = ceilf ((float) quota / (float) period)
If (PrintContainerInfo) {
Tty- > print_cr ("CPU Quota count based on quota/period:% d", quota_count)
}
}
If (share >-1) {
Share_count = ceilf ((float) share / (float) PER_CPU_SHARES)
If (PrintContainerInfo) {
Tty- > print_cr ("CPU Share count based on shares:% d", share_count)
}
}
/ / If both shares and quotas are setup results depend
/ / on flag PreferContainerQuotaForCPUCount.
/ / If true, limit CPU count to quota
/ / If false, use minimum of shares and quotas
If (quota_count! = 0 & & share_count! = 0) {
If (PreferContainerQuotaForCPUCount) {
Limit_count = quota_count
} else {
Limit_count = MIN2 (quota_count, share_count)
}
} else if (quota_count! = 0) {
Limit_count = quota_count
} else if (share_count! = 0) {
Limit_count = share_count
}
Result = MIN2 (cpu_count, limit_count)
If (PrintContainerInfo) {
Tty- > print_cr ("OSContainer::active_processor_count:% d", result)
}
Return result
}
How to get the cpu of JDK1.8u131
Int os::active_processor_count () {
/ / Linux doesn't yet have a (official) notion of processor sets
/ / so just return the number of online processors.
Int online_cpus =:: sysconf (_ SC_NPROCESSORS_ONLN)
Assert (online_cpus > 0 & & online_cpus
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.