From 9508f1e7776f2584a6a92428735bdbf02c15b660 Mon Sep 17 00:00:00 2001 From: R4ken Date: Tue, 12 Aug 2025 10:57:51 +0200 Subject: [PATCH] syscalls: implement getThreadCpuTime syscall Implement syscall based on declared getCpuTime function JIRA: RTOS-1088 --- include/syscalls.h | 5 ++++- proc/threads.c | 6 ++++++ proc/threads.h | 3 +++ syscalls.c | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/syscalls.h b/include/syscalls.h index 5b45b7556..a9909bb0e 100644 --- a/include/syscalls.h +++ b/include/syscalls.h @@ -126,7 +126,10 @@ ID(sys_mprotect) \ \ ID(sys_statvfs) \ - ID(sys_uname) + ID(sys_uname) \ + \ + ID(getThreadCpuTime) + /* parasoft-end-suppress MISRAC2012-RULE_20_7-a */ /* clang-format on */ diff --git a/proc/threads.c b/proc/threads.c index 20ee8df5d..c609d088a 100644 --- a/proc/threads.c +++ b/proc/threads.c @@ -2222,6 +2222,12 @@ int proc_threadsOther(thread_t *t) } +time_t threads_getCpuTime(thread_t *t) +{ + return t->cpuTime; +} + + int _threads_init(vm_map_t *kmap, vm_object_t *kernel) { unsigned int i; diff --git a/proc/threads.h b/proc/threads.h index 60e89e077..e18e85567 100644 --- a/proc/threads.h +++ b/proc/threads.h @@ -177,6 +177,9 @@ time_t proc_uptime(void); void proc_gettime(time_t *raw, time_t *offs); +extern time_t threads_getCpuTime(thread_t *t); + + int proc_settime(time_t offs); diff --git a/syscalls.c b/syscalls.c index 9516efc2d..ed9c53e58 100644 --- a/syscalls.c +++ b/syscalls.c @@ -372,6 +372,12 @@ int syscalls_priority(u8 *ustack) } +time_t syscalls_getThreadCpuTime(void *ustack) +{ + return threads_getCpuTime(proc_current()); +} + + /* * System state info */