首页 > > 详细

ICSI 400程序讲解、辅导C++设计、program编程语言讲解解析Haskell程序|讲解数据库SQL

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.

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!