gcc time_display.c -o time_display

---------------------------------
./time_display &
Sample Output:

[1] 4512
Current system time: Mon Oct 28 11:37:25 2025
Here, the PID of the process is 4512.

-----------------------------
cat /proc/4512/stat

Example (shortened):

4512 (time_display) R 4498 4512 4498 0 -1 4194560 186 0 0 0 0 1 0 0 20 0 1 0 123456 123456 0 0 0 0 0 0 0 0 0 0 0 0
----------------------------
According to the Linux documentation (man proc), the fields are:

Field	Description
14	utime – Time spent in user mode (in clock ticks)
15	stime – Time spent in kernel mode (in clock ticks)
To extract just these values:

awk '{print "utime (user mode): "$14, "\nstime (kernel mode): "$15}' /proc/4512/stat
Sample Output:

utime (user mode): 2
stime (kernel mode): 1
-----------------------------

Linux measures CPU time in clock ticks, which vary by system.
To find the number of clock ticks per second:

getconf CLK_TCK
Typical output:

100
This means 100 ticks = 1 second.
-----------------------------
verify with
cat /proc/4512/status | grep -E "utime|stime"


