8234397: add OS uptime information to os::print_os_info output
David Holmes
david.holmes at oracle.com
Wed Dec 4 04:31:16 UTC 2019
Hi Matthias,
On 4/12/2019 1:38 am, Baesken, Matthias wrote:
> Hi David, here is a new webrev based on your comments :
>
> http://cr.openjdk.java.net/~mbaesken/webrevs/8234397.4/
Thanks for the updates.
>>
>> Is %llu supported by all compilers (32-bit as well)?
>>
>
> Not sure , I checked and it works with VS2017/32bit. But I don't know about other compilers. So I better use long / %ld.
I think int would be fine - 2^31 seconds is a long time.
>
> Btw I noticed that
>
> os::print_date_and_time
> ...
> // print elapsed time in a human-readable format:
>
> Contains very similar coding to what I do in os::print_dhm --> should this maybe be unified ?
I don't really see a way to unify. You might hoist the constants out to
be static in the file for sharing:
const int secs_per_day = 86400;
const int secs_per_hour = 3600;
const int secs_per_min = 60;
and add others as needed.
Thanks,
David
>
> Best regards, Matthias
>
>
>
>> Hi Matthias,
>>
>> On 29/11/2019 11:58 pm, Baesken, Matthias wrote:
>>> Hi, here is a new webrev, this time with nicer output (see os.cpp) .
>>>
>>> http://cr.openjdk.java.net/~mbaesken/webrevs/8234397.3/
>>
>> src/hotspot/os/bsd/os_bsd.cpp
>>
>> This link may be more general than the Apple "iOS" one.
>>
>> https://man.openbsd.org/sysctl.2
>>
>> + time_t bootsec = boottime.tv_sec, currsec = time(NULL);
>>
>> Please write the two declarations on separate lines.
>>
>> ---
>>
>> src/hotspot/os/posix/os_posix.cpp
>>
>> + // unfortunately it does not work on macOS
>>
>> Still no mention of Linux
>>
>> ---
>>
>> src/hotspot/share/runtime/os.cpp
>>
>> + if (minutes < 10) {
>> + st->print_cr("%s %llu days %llu:0%llu hours", startStr, days,
>> hours, minutes);
>> + } else {
>> + st->print_cr("%s %llu days %llu:%llu hours", startStr, days,
>> hours, minutes);
>> + }
>>
>> You should just use a zero-padded width of 2 to get 01..09 for minutes.
>>
>> Is %llu supported by all compilers (32-bit as well)?
>>
>> ---
>>
>> src/hotspot/os/windows/os_windows.cpp
>>
>> + unsigned long long ticks = GetTickCount64();
>> + os::print_dhm(st, "OS uptime:", ticks);
>>
>> GetTickCount64 returns milliseconds since boot not seconds.
>>
>> ---
>>
>> Thanks,
>> David
>>
>
More information about the hotspot-dev
mailing list