I found answer in the below given related post, according to it, the writes to fifo are atomic as long as the write messages is less than the page size 4k(page size depends on system configuration).
Are there repercussions to having many processes write to a single reader on a named pipe in posix?
Thank you all for the replies and suggestions.