As per my understanding
It looks both do almost same work.
But what are the specific dirty buffer(data) writes into disk? How frequently checkpoint and bgwriter it is calling?
I want to know what are the difference between them.
Thanks in advance
It looks both do almost same work.
Looking at the source code link given by Adrian, you can see these words in the comments for the background writer:
As of Postgres 9.2 the bgwriter no longer handles checkpoints.
...which means in the past, the background writer and checkpointer tasks were handled by one component, which explains the similarity that probably led you to ask this question. The two components were split on 1/Nov/2011 in this commit and you can learn more about the checkpointer here.
From my own understanding, they are doing the same task from different perspectives. The task is making sure we use a limited amount of resources:
...after a checkpoint, log segments preceding the one containing the redo record are no longer needed and can be recycled or removed.It may be helpful to read more about the WAL (Write-Ahead Log) in general.