add mutex API, add thread safety to memmgr

Signed-off-by: Wilfried Chauveau <ithinuel@gmail.com>