After searching the web, the solution I found is to disable this Linux kernel messages coming to the UART port and also the serial console login facility. Here's how I did that.
To disable kernel messages coming to the UART port, open the following file by issuing the command,
sudo nano /boot/cmdline.txt
Edit the content of the file by removing all the parameters which involve ttyAMA0 device. So, the resulting content would look like the following.
dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Now save and exit from the nano editor.
To disable the serial console through the UART port, open the following file by issuing the command,
sudo nano /etc/innitab
Find the following line in that file.
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Now add a '#' character in front of that like to comment that out so that it looks as follows.
# T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Now save and exit from the nano editor. After editing these two files we are done. When the next time you reboot the Raspberry Pi, you will be able to use the UART port without any disturbance from system level.