background writer is a separate server process responsible for writing "dirty" (new or modified) buffers to the on-disk datafiles, to reduce load on regular backends.
Currently following configuration items control the background writer behaviour:
bgwriter_lru_maxpages to zero effectively disables the background writer.
For more details, see the background writer configuration documentation.
The number of buffers written by the background writer itself is recorded in the "buffers_clean" column of the pg_stat_bgwriter view.
The main background writer process code: src/backend/postmaster/bgwriter.c
The actual "heavy lifting" is done in src/backend/storage/buffer/bufmgr.c, particularly function