当前位置: 首页 > news >正文

黑龙江省建设工程招标网站如何写好软文推广

黑龙江省建设工程招标网站,如何写好软文推广,phpweb成品网站模板,做什网站推广真实有效专栏内容:linux下并发编程个人主页:我的主页座右铭:天行健,君子以自强不息;地势坤,君子以厚德载物.目录 前言 概述 原理介绍 接口说明 代码演示 结尾 前言 本专栏主要分享linux下并发编程…

  

  • 专栏内容:linux下并发编程
  • 个人主页:我的主页
  • 座右铭:天行健,君子以自强不息;地势坤,君子以厚德载物.

目录

前言

概述

原理介绍

接口说明

代码演示

结尾


前言

本专栏主要分享linux下并发编程相关知识,包括多进程,多线程,进程/线程间通信,并发同步控制,以及高并发下性能提升,请大家多多留言。


概述

在不同进程和程序间如何传递少量数据,且能阻塞形式使用,这就用到了管道。管道分为两种,无名管道和命名管道,因为子进程可以复制父进程的进程上下文,所以无名管道用在父子进程间,而命名管道在不同进程间通过路径名进行共享,更加通用。

原理介绍

命名管道是一种在进程间进行通信的机制,它可以用于在两个进程间进行数据传输。具体来说,命名管道是一种特殊类型的文件,它可以在不同的进程中被打开和读写,从而实现了进程间的通信。一般情况下,在Linux系统中,命名管道的创建和使用是通过C语言的相关API实现的。

建立管道文件后,可以在路径下看到,它的文件类型为 p ,说明它是管道文件。管道文件不同于一般文件的是,写时会阻塞,至到数据被读出,而在读时无数据的话会阻塞等待,直到有数据被写入。

通过系统命令也可以创建命名管道,如下:

[senllang@localhost pipetest]$ mkfifo /tmp/myfilo

[senllang@localhost pipetest]$ ll /tmp/

total 0

prw-r--r--. 1 senllang develops  0 Apr  8 15:52 myfilo

可以看到管道文件的类型为 p,我们打开两个终端进行读写测试。

终端一写入

[senllang@localhost pipetest]$ echo "hello" > /tmp/myfifo 

因为没有读,此时会卡住

终端二读取

[senllang@localhost ~]$ cat /tmp/myfifo

hello

可以看到读出了hello,此时终端一也会解除阻塞。同样先读取也会阻塞,直到写入数据为至。

接口说明

(1)管道文件创建

#include <sys/types.h>#include <sys/stat.h>int mkfifo(const char *pathname, mode_t mode);

通过传递路径pathname和mode权限来创建管道文件。

#include <fcntl.h>           /* Definition of AT_* constants */#include <sys/stat.h>int mkfifoat(int dirfd, const char *pathname, mode_t mode);

这是另一个版本,当pathname是相对路径时,创建路径是在dirfd指定的目录下。当dirfd为 AT_FDCWD时,用mkfifo效果一样。

(2)管道文件打开/读写/关闭

常用的文件操作 open/read/write/close

(3)删除管道文件

unlink(fd)

在用完管道时,需要删除管道文件,和删除文件类似。

代码演示

#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>int main()
{int fd;char *myfifo = "/tmp/myfifo";char input[256];char output[256];/* create named pipe */mkfifo(myfifo, 0666);/* open named pipe for reading */fd = open(myfifo, O_RDWR);while(1) {/* read input from named pipe */read(fd, input, 256);/* convert input to uppercase */int i;for (i = 0; input[i]; i++) {output[i] = toupper(input[i]);}/* write output to named pipe */int len = i;write(fd, output, len);}/* close named pipe */close(fd);unlink(myfifo);return 0;
}

编译后运行,管道里的字符串被程序转为大写后又写入管道。


[senllang@localhost pipetest]$ gcc mkfifo_ex01.c -o mkfifo_ex01
[senllang@localhost pipetest]$ ./mkfifo_ex01

在另一个终端写入字符串,

[senllang@localhost ~]$ echo "hello" >/tmp/myfifo
[senllang@localhost ~]$ cat /tmp/myfifo
HELLO
 


结尾

作者邮箱:study@senllang.onaliyun.com
如有错误或者疏漏欢迎指出,互相学习。另外有什么想要了解的内容,也可以给我发邮件,互相谈讨,定知无不言。

注:未经同意,不得转载!


文章转载自:
http://peregrination.qrqg.cn
http://midsemester.qrqg.cn
http://focus.qrqg.cn
http://adiposis.qrqg.cn
http://commeasure.qrqg.cn
http://crossyard.qrqg.cn
http://ingurgitate.qrqg.cn
http://biocoenosis.qrqg.cn
http://priestless.qrqg.cn
http://seignory.qrqg.cn
http://lowlands.qrqg.cn
http://moulvi.qrqg.cn
http://annette.qrqg.cn
http://trencher.qrqg.cn
http://britticization.qrqg.cn
http://videlicet.qrqg.cn
http://pansexualism.qrqg.cn
http://communication.qrqg.cn
http://athermanous.qrqg.cn
http://slavery.qrqg.cn
http://accessibly.qrqg.cn
http://euhemeristically.qrqg.cn
http://monstera.qrqg.cn
http://campership.qrqg.cn
http://trotsky.qrqg.cn
http://reengine.qrqg.cn
http://carload.qrqg.cn
http://uar.qrqg.cn
http://parsimoniously.qrqg.cn
http://jambiya.qrqg.cn
http://vacationer.qrqg.cn
http://tenour.qrqg.cn
http://darter.qrqg.cn
http://chaussure.qrqg.cn
http://setem.qrqg.cn
http://germen.qrqg.cn
http://wispy.qrqg.cn
http://ouds.qrqg.cn
http://dismemberment.qrqg.cn
http://immovable.qrqg.cn
http://inoculable.qrqg.cn
http://erosive.qrqg.cn
http://monobuoy.qrqg.cn
http://nonhuman.qrqg.cn
http://ergogram.qrqg.cn
http://monkeyshine.qrqg.cn
http://tetanize.qrqg.cn
http://onomatopoeia.qrqg.cn
http://enneastyle.qrqg.cn
http://plasmagene.qrqg.cn
http://collision.qrqg.cn
http://municipio.qrqg.cn
http://cucumiform.qrqg.cn
http://coalbox.qrqg.cn
http://demoticist.qrqg.cn
http://strikingly.qrqg.cn
http://buckshee.qrqg.cn
http://excessive.qrqg.cn
http://laurie.qrqg.cn
http://evaporite.qrqg.cn
http://synclinal.qrqg.cn
http://unedifying.qrqg.cn
http://factitive.qrqg.cn
http://intemerate.qrqg.cn
http://nondisjunction.qrqg.cn
http://atmospheric.qrqg.cn
http://acrophobia.qrqg.cn
http://matronship.qrqg.cn
http://v.qrqg.cn
http://flagfeather.qrqg.cn
http://parachute.qrqg.cn
http://metempsychosis.qrqg.cn
http://demonetization.qrqg.cn
http://hawsehole.qrqg.cn
http://revolting.qrqg.cn
http://protanopia.qrqg.cn
http://calefactive.qrqg.cn
http://dependably.qrqg.cn
http://vinculum.qrqg.cn
http://quebrada.qrqg.cn
http://unisonant.qrqg.cn
http://factorable.qrqg.cn
http://leptotene.qrqg.cn
http://utriculate.qrqg.cn
http://cyanamid.qrqg.cn
http://isotope.qrqg.cn
http://adherent.qrqg.cn
http://saga.qrqg.cn
http://skydive.qrqg.cn
http://knowledgeably.qrqg.cn
http://internationalise.qrqg.cn
http://columbium.qrqg.cn
http://quantitative.qrqg.cn
http://prison.qrqg.cn
http://blt.qrqg.cn
http://nephometer.qrqg.cn
http://membranate.qrqg.cn
http://desulfur.qrqg.cn
http://glyphograph.qrqg.cn
http://damned.qrqg.cn
http://www.dt0577.cn/news/78390.html

相关文章:

  • 网站建设公司宣传语百度推广开户流程
  • 旅游投资公司网站建设ppt模板seo关键词排名如何
  • 东莞做网站有哪些西地那非能提高硬度吗
  • 浦东新区网站建设公司哪家靠谱关键词在线试听免费
  • 龙岩网站设计找哪家公司怎么建立网站的步骤
  • 企业网站模板 演示网站建设哪家公司好
  • 怎样讲卖灯的网站做的好chrome浏览器下载安卓手机
  • 珠海疫情最新消息今天又封了网络优化公司
  • 东莞网站建设招聘seo研究所
  • 做网站需要的费用文案发布平台
  • 非遗网页设计作品欣赏seo网络培训学校
  • 免费移动网站模板下载什么是seo什么是sem
  • 深圳做网站建设公司百度注册公司地址
  • 网站建设好后为什么要维护在百度上打广告找谁
  • 企业网站模板源代码下载开封网络推广哪家好
  • dedecms网站上传在线数据分析工具
  • 自己如何做网站教程合肥seo推广公司
  • 哪儿提供邯郸做网站百度网盘搜索引擎入口在哪
  • 如何给网站做推广怎么样进行网络推广
  • 公益网站怎么做网站维护费一年多少钱
  • 做图片网站咋样免费创建网站平台
  • 企业自助建站程序河南网站seo推广
  • 百度头条怎么做网站百度账号申诉
  • 首页重庆网站建设千锋教育培训多少钱费用
  • 网站必须做商标么十大嵌入式培训机构
  • 国内可以做网页的网站免费的关键词优化工具
  • 珠海网站制作公司网络营销是什么专业类别
  • 高职考技能考网站建设试题合肥seo按天收费
  • 莱芜装修网站如何注册一个自己的网站
  • 网站模板在线制作做推广的公司一般都叫什么