哪里STDOUT缓冲区? [英] Where is the STDOUT buffer?

查看:176
本文介绍了哪里STDOUT缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我们所知,stdout是在Linux中缓冲。我的问题是:1)它是由所有进程共享的全局缓冲区?或每个进程的一个缓冲器? 2)其中,缓冲区是什么?堆栈或堆或静态区域? 3)谁创造的呢?

As we know, STDOUT is buffered in Linux. My question is: 1) is it a global buffer shared by all processes? or one buffer for each process? 2) where the buffer is? on stack, or heap or static area? 3) who creates it?

推荐答案

标准输出是C 文件指针创建标准库,因此相关code加载为你的C库的一部分。在Linux中,这将在Posix的文件描述符的角度来实现。

stdout is a C FILE pointer created by the standard library, so the relevant code is loaded as part of your C library. On Linux, it will be implemented in terms of Posix file descriptors.

您的两个C库和内核可以使用缓冲;你必须检查各单证。我建议通过查看C库的源$ C ​​$ C的相关部分开始(即部分实现< stdio.h中> ),这应该是非常有教育意义。

Both your C library and the kernel may use buffering; you'll have to check the individual documentations. I recommend to start by looking at the relevant part of the source code of the C library (i.e. the part that implements <stdio.h>), which should be very educational.

这篇关于哪里STDOUT缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆