How to get system available memory and some process memory usage through system call or API

From: Tao, Liu
Date: Thu Jan 28 2016 - 11:18:41 EST


Hi
I want to get system available memory and memory usage of one
precess(known Pid). Now I read /proc/meminfo and /proc/$pid/stat to
get above data.
And my question is:
1 Is there system call or API to get above data?
2 Linux kernel add "MemAvailable" to "/proc/meminfo" in 3.14, but I
use kernel 3.10. Can I calculate "MemAvailable" through data read from
/proc/meminfo in kernel 3.10? How?

--
Best Wishes,

Tao, Liu