It would be nice to share your solution in case someone else comes into the same problem.
Hi,
It was stupid mistake. I forgot to initialize the file descriptor which was passed to mmap and therefore it was throwing "Bad file descriptor" error.i realized it after looking the errors in "man mmap".