2020-07-30 18:38:15 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 18:38:15 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-06-28 15:59:35 -03:00
|
|
|
KResultOr<FlatPtr> Process::sys$times(Userspace<tms*> user_times)
|
2020-07-30 18:38:15 -03:00
|
|
|
{
|
2021-07-18 15:20:12 -03:00
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
2020-07-30 18:38:15 -03:00
|
|
|
REQUIRE_PROMISE(stdio);
|
2020-08-09 16:26:56 -03:00
|
|
|
tms times = {};
|
|
|
|
|
times.tms_utime = m_ticks_in_user;
|
|
|
|
|
times.tms_stime = m_ticks_in_kernel;
|
|
|
|
|
times.tms_cutime = m_ticks_in_user_for_dead_children;
|
|
|
|
|
times.tms_cstime = m_ticks_in_kernel_for_dead_children;
|
|
|
|
|
|
2021-09-05 12:38:37 -03:00
|
|
|
TRY(copy_to_user(user_times, ×));
|
2020-11-15 15:58:19 -03:00
|
|
|
return TimeManagement::the().uptime_ms() & 0x7fffffff;
|
2020-07-30 18:38:15 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|