Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the differences between jdk1.8u131 and jdk1.8u222 cpu acquisition methods?

Shulou Source: shulou.com Published: 2022-05-31 18:28:26 09月21日 Update

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

Tags: Way article difference more good practical consistent content scene container situation article machine version knowledge thread reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info macOS Linux Microsoft