博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
探索linux管道的容量
阅读量:2723 次
发布时间:2019-05-13

本文共 782 字,大约阅读时间需要 2 分钟。

管道特点:

(1)、单向通信。数据只能由一个进程流向另一个进程(其中一个读管道,一个写管道);如果要进行双工通信,需要建 立两个管道。
(2)、管道只能用于有血缘关系的进程间通信。
(3)、流式服务。发送和接收大小不受特定格式的限制。
(4)、管道的生命周期和进程有关。
(5)、同步与互斥原则。

fcntl()可以改变已打开的文件性质

F_GETFL 取得文件描述符状态旗标,此旗标为open()的参数flags。

F_SETFL 设置文件描述符状态旗标,参数arg为新旗标,但只允许O_APPEND、O_NONBLOCK和O_ASYNC位的改变,其他位的改变将不受影响。

#include
#include
#include
#include
#include
#include
#include
int main(){ int _pipe[2]; if(pipe(_pipe)==-1) { printf("pipe error\n"); return 1; } int ret; int count=0; int flag=fcntl(_pipe[1],F_GETFL); fcntl(_pipe[1],F_SETFL,flag|O_NONBLOCK); while(1) { ret=write(_pipe[1],"A",1); if(ret==-1) { printf("error %s\n",strerror(errno)); break; } count++; } printf("count=%d\n",count); return 0;}

这里写图片描述

所以管道的容量是64kb。

你可能感兴趣的文章
TensorFlow下数据加载——tf.data的使用
查看>>
《CBAM: Convolutional Block Attention Module》论文笔记
查看>>
《A Transductive Approach for Video Object Segmentation》论文笔记
查看>>
《TDNet:Temporally Distributed Networks for Fast Video Semantic Segmentation》论文笔记
查看>>
《HRank:Filter Pruning using High-Rank Feature Map》论文笔记
查看>>
《Siamese FC:Fully-Convolutional Siamese Networks for Object Tracking》论文笔记
查看>>
《FRTM:Learning Fast and Robust Target Models for Video Object Segmentation》论文笔记
查看>>
《STM:Video Object Segmentation using Space-Time Memory Networks》论文笔记
查看>>
《Non-local Neural Networks》论文笔记
查看>>
Pytorch中torch.nn.DataParallel负载均衡问题
查看>>
《FPGM:Filter Pruning via Geometric Median for Deep Convolutional Neural Networks Acceleration》论文笔记
查看>>
《Siamese RPN:High Performance Visual Tracking with Siamese Region Proposal Network》论文笔记
查看>>
《OpenPose:Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields》论文笔记
查看>>
《RETHINKING THE VALUE OF NETWORK PRUNING》论文笔记
查看>>
《Real-time 2D Multi-Person Pose Estimation on CPU:Lightweight OpenPose》论文笔记
查看>>
《Decoders Matter for Semantic Segmentation》论文笔记
查看>>
《HRNet:Deep High-Resolution Representation Learning for Human Pose Estimation》论文笔记
查看>>
《HigherHRNet:Scale-Aware Representation Learning for Bottom-Up Human Pose Estimation》论文笔记
查看>>
《PackNet:3D Packing for Self-Supervised Monocular Depth Estimation》论文笔记
查看>>
《EfficientNetV2:Smaller Models and Faster Training》论文笔记
查看>>