add lock to pid operations