From 55fd7dfff7de7d4f49c78a31ddeace38def3b47c Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Mon, 30 Jan 2023 10:51:32 -0700
Subject: [PATCH] Add centiseconds to context time

---
 src/scheme/sys/context.rs | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/scheme/sys/context.rs b/src/scheme/sys/context.rs
index ec4fcfee..0f27aad5 100644
--- a/src/scheme/sys/context.rs
+++ b/src/scheme/sys/context.rs
@@ -5,7 +5,7 @@ use crate::context;
 use crate::syscall::error::Result;
 
 pub fn resource() -> Result<Vec<u8>> {
-    let mut string = format!("{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<8}{:<8}{}\n",
+    let mut string = format!("{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<12}{:<8}{}\n",
                              "PID",
                              "PGID",
                              "PPID",
@@ -17,7 +17,7 @@ pub fn resource() -> Result<Vec<u8>> {
                              "ENS",
                              "STAT",
                              "CPU",
-                             "TICKS",
+                             "TIME",
                              "MEM",
                              "NAME");
     {
@@ -63,12 +63,14 @@ pub fn resource() -> Result<Vec<u8>> {
                 format!("?")
             };
 
-            let cpu_time = context.cpu_time / crate::time::NANOS_PER_SEC;
+            let cpu_time_s = context.cpu_time / crate::time::NANOS_PER_SEC;
+            let cpu_time_ns = context.cpu_time % crate::time::NANOS_PER_SEC;
             let cpu_time_string = format!(
-                "{:02}:{:02}:{:02}",
-                cpu_time / 3600,
-                (cpu_time / 60) % 60,
-                cpu_time % 60
+                "{:02}:{:02}:{:02}.{:02}",
+                cpu_time_s / 3600,
+                (cpu_time_s / 60) % 60,
+                cpu_time_s % 60,
+                cpu_time_ns / 10_000_000
             );
 
             let mut memory = context.kfx.len();
@@ -93,7 +95,7 @@ pub fn resource() -> Result<Vec<u8>> {
                 format!("{} B", memory)
             };
 
-            string.push_str(&format!("{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<9}{:<8}{}\n",
+            string.push_str(&format!("{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<6}{:<12}{:<8}{}\n",
                                context.id.into(),
                                context.pgid.into(),
                                context.ppid.into(),
-- 
GitLab