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-11-07 20:51:39 -03:00
|
|
|
ErrorOr<FlatPtr> Process::sys$times(Userspace<tms*> user_times)
|
2020-07-30 18:38:15 -03:00
|
|
|
{
|
2022-08-17 17:03:04 -03:00
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
2021-12-29 06:11:45 -03:00
|
|
|
TRY(require_promise(Pledge::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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|