From 90861a9b3594074ac7d21d8fe8752b2df01587d6 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 11 Aug 2025 05:10:42 -0400 Subject: kernel: sysctl: Add 'proc.count' entry Introduce the 'proc.count' sysctl variable which contains the number of running processes in the system. Signed-off-by: Ian Moffett --- sys/include/sys/sysctl.h | 5 +++++ sys/kern/kern_sysctl.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/include/sys/sysctl.h b/sys/include/sys/sysctl.h index 3b8d3c7..ce7510d 100644 --- a/sys/include/sys/sysctl.h +++ b/sys/include/sys/sysctl.h @@ -55,6 +55,11 @@ #define HW_NCPU 6 #define HW_MACHINE 7 +/* + * List of 'proc.*' identifiers + */ +#define PROC_COUNT 8 + /* * Option types (i.e., int, string, etc) for * sysctl entries. diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index a4c16bb..1f5e578 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -40,6 +40,7 @@ HYRA_VERSION " " \ HYRA_BUILDDATE +extern size_t g_nthreads; static uint32_t pagesize = DEFAULT_PAGESIZE; static char machine[] = HYRA_ARCH; static char hyra[] = "Hyra"; @@ -62,7 +63,10 @@ static struct sysctl_entry common_optab[] = { /* 'hw.*' */ [HW_PAGESIZE] = { HW_PAGESIZE, SYSCTL_OPTYPE_INT_RO, &pagesize }, [HW_NCPU] = { HW_NCPU, SYSCTL_OPTYPE_INT, NULL }, - [HW_MACHINE] = {HW_MACHINE, SYSCTL_OPTYPE_STR_RO, &machine } + [HW_MACHINE] = {HW_MACHINE, SYSCTL_OPTYPE_STR_RO, &machine }, + + /* 'proc.*' */ + [PROC_COUNT] = { PROC_COUNT, SYSCTL_OPTYPE_INT_RO, &g_nthreads } }; static int -- cgit v1.2.3