联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2020-10-19 11:02

Operating Systems

Chongqing University of Posts and Telecommunications

Computer Science, International College

ICSI 400

Lab4

Assigned Date: Wednesday, October 14th, 2020

Due Date: Wednesday, October 28st, 2020 by 7:00 PM


Student Name:

OBJECTIVES

To develop a C program that uses both fork() and pipe()  process system calls to implement interprocess communication by means of file sharing.


PROBLEM

You are to use the Ubuntu operating system to create two C programs.

A program consumer.c to (1) read from a file containing integers and to (2) write to the display the even numbers and (3) the sum of the odd numbers found in the input file.

A program producer.c to (1) create a file with 20 integers and to (2) share this file with the consumer.

Both programs, the consumer and the producer, will communicate through a pipe.  Your solution must include a child process which will execute your consumer program. Your shared file should be named numbers.txt and should be the only means of sharing information between your producer and consumer programs. You may use the fork(), pipe(), dup(), dup2(), read(), write(), creat(), as well as any of the exec() family of system calls.

WHAT TO SUBMIT

You are to follow the instructions provided by your co-instructor for the submission of your work. The following are to be submitted:

Your source code for both the producer and the consumer, as well as any output produced by your solution that clearly shows the following:

1)The contents of the file numbers.txt, and

2)Information about pids of both parent and child, the file descriptor fd of your numbers.txt file, and a screenshot of the output of your consumer program.  You are to use the following format to structure your output:

a)File numbers.txt fd is:  fd-of-numbers.txt.

b)Contents of file numbers.txt: a listing of the 20 integers.

c)A screenshot of your terminal showing both (1) the even numbers returned by your consumer program as well as (2) the sum of the odd numbers.

d)Parent Process: My pid = pid-of-parent. I created child pid = pid-of-child.

e)Child Process: My pid = pid-of-child. My parent pid = pid-of-parent.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp