본문 바로가기
프로그래밍/Study C

Buffer

by Damon11 2022. 10. 11.

버퍼의 역할

프로그램 지연 방지

Stream Buffering
Buffering is the process of temporarily storing data in main memory that’s passing between a process and a device or file. Buffering improves the throughput of I/O operations, which often have high latencies. Similarly, when a program requests to write to block-oriented devices like disks, the driver can cache the data in memory until it has accumulated enough data for one or more device blocks, at which point it writes the data all at once to the disk, improving throughput. This strategy is called flushing the output buffer.

Like device drivers, streams often maintain their own I/O buffers. Typically, a stream uses one input buffer for each file that the program wants to read from, and one output buffer for each it wants to write to.

 

 

데이터 덩어리로 전달

scanf 와 같이 terminal 에서 입력을 기다리는 경우를 예로 들어본다.

사용자가 enter (\n)을 입력하기 전까지는 계속 대기상태이다. 문자를 입력할 때 마다 바로 데이터를 전송하는 것이 아니라, 입력하면 buffer에 저장되고, enter를 입력할 때 buffer에 저장된 데이터들을 한 번에 전송한다.

'프로그래밍 > Study C' 카테고리의 다른 글

Debugging, Testing and Analysis  (0) 2022.11.07
'Static' in C language  (0) 2022.10.27
Program Structure  (0) 2022.10.19
PreProcessing  (0) 2022.10.17
I/O Stream  (0) 2022.10.11

댓글