文件名称:File-Operations

  • 所属分类:
  • Linux/Unix编程
  • 资源属性:
  • [C/C++] [源码]
  • 上传时间:
  • 2015-10-30
  • 文件大小:
  • 4kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • 忆*
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

在 Linux 中 FIFO 是一种进程之间的管道通信机制。Linux 支持完整的 FIFO通信 机制。 本实验内容,通过使用文件操作,仿真 FIFO(先进先出)结构以及生产者-消费者运行模型。

本实验中需要打开两个虚拟终端,分别运行生产者程序(producer)和消费者程序(customer)。此时两个进程同时对同一个文件进行读写操作。因为这个文件是临界资源,所以可以使用文件锁机制来保证两个进程对文件的访问都是原子操作。

先启动生产者进程,它负责创建仿真 FIFO 结构的文件(其实是一个普通文件)并投入生产,就是按照给定的时间间隔,向 FIFO 文件写入自动生成的字符(在程序中用宏定义选择使用数字还是使用英文字符),生产周期以及要生产的资源数通过参数传递给进程(默认生产周期为 1s,要生产的资源数为 10 个字符)。

后启动的消费者进程按照给定的数目进行消费,首先从文件中读取相应数目的字符并在屏幕上显示,然后从文件中删除刚才消费过的数据。为了仿真 FIFO 结构,此时需要使用两次复制来实现文件内容的偏移。每次消费的资源数通过参数传递给进程,默认值为10 个字符。 -Linux is in FIFO pipe communication mechanism between processes. Linux supports a full FIFO communication mechanism. The experiment content, through the use of file operations, simulation FIFO (First In First Out) structure as well as producer- consumer model is run.

In this study we need to open two virtual terminals, each running program producers (producer) and consumer programs (customer). At this point two processes simultaneously on the same file for read and write operations. Because this document is the critical resource, so you can use the file locking mechanism to ensure access to the file two processes are atomic.

Producers first start process, it is responsible for creating the simulation FIFO file structure (actually a common file) and put into production, is in accordance with a given time interval, automatically generated characters written into the FIFO file (using macros define the selection the use of digital still use English characters), the production cycle and t
(系统自动生成,下载前可以参看下载内容)

下载文件列表





sy4\customer.c

...\mylock.h

...\producer.c

...\sy4.c

sy4

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org