New course! Every coder should learn Generative AI!
Try a free lesson+ 3
Operating systems usually came with some form of process information utility. Windows has Task Manager and Linux *IIRC* has table of process.
These utilities has extended information about resource usage of each running process. You can utilise them to watch for a certain process' resource usage.
Implementing such thing in our own program is not easy task, it's part of system information.
However some high level languages may support it through a framework or library.