What does it mean by buffer?

后端 未结 8 1165
自闭症患者
自闭症患者 2020-12-04 05:04

I see the word \"BUFFER\" everywhere, but I am unable to grasp what it exactly is.

  1. Would anybody please explain what is buffer in laym
相关标签:
8条回答
  • 2020-12-04 05:29

    Buffer is temporary placeholder (variables in many programming languages) in memory (ram/disk) on which data can be dumped and then processing can be done.

    There are many advantages of Buffering like it allows things to happen in parallel, improve IO performance, etc.

    It also has many downside if not used correctly like buffer overflow, buffer underflow, etc.

    C Example of Character buffer.

    char *buffer1 = calloc(5, sizeof(char));
    
    char *buffer2 = calloc(15, sizeof(char));
    
    0 讨论(0)
  • 2020-12-04 05:29

    Buffer is temporary placeholder (variables in many programming languages) in memory (ram/disk) on which data can be dumped and then processing can be done.

    The term "buffer" is a very generic term, and is not specific to IT or CS. It's a place to store something temporarily, in order to mitigate differences between input speed and output speed. While the producer is being faster than the consumer, the producer can continue to store output in the buffer. When the consumer speeds up, it can read from the buffer. The buffer is there in the middle to bridge the gap.

    0 讨论(0)
提交回复
热议问题