Eliminated deadlock BUG.
Avoid use mmap() directly.
Used a better locking method.