Fixed the bug "current pid doesn't refer to running process". We should
update pid and pgd each time pgd is written back.