联系方式

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

您当前位置:首页 >> Java编程Java编程

日期:2021-11-12 10:17

Lab 4 - Conways Problem

Conway’s Problem

In this lab you will write a program to solve Conway’s problem.

Description

You will again use the IPC implementation under UNIX and the ezipc.h library to solve the problem. If

ezipc is not used, points will be taken off. You may use SHOW() and SET() only for debugging purposes.

Purpose

Conway's Problem: Write a program to read 80-column cards and write them as 125-character lines with

the following changes. After every card image the string <EOL> is inserted. Every adjacent pair of

asterisks ** is replaced by a #.

Of course Conway's problem can be solved by a single sequential program. However, it is difficult to be

sure that you have taken care of all special cases such as pairs of asterisks at the end of a card and so

on.

The problem has an elegant solution with three concurrent processes. One process producer reads

cards and inserts the string <EOLN> when necessary and passes characters through a one-character

buffer to a process squash. squash, which knows nothing about 80-column cards, simply looks for

double asterisks and passes a stream of modified characters to a process print. print takes the

characters and prints them as 125-character lines.

Program Guidlines

Write a program to solve Conway's problem with three separate processes for the producer, squasher

and printer as described above using three concurrent processes with the following modifications:

- Your program should read in the card text from a file called “conway.txt”

- Each card is 20 characters long (not 80 column cards).

- To simulate card input read from a file where each line has 20 characters.

- Printer process: prints 25-character lines to the screen (not 125 character lines).

*Note that each shared memory is a 1 character buffer.

.

producer squash print

shared

memory

shared

memory

input

file output

Here is an example, given the text file provided, program would be expected the shown to output

Input file

1234*6**9*ABCDEFGHI*

*bcdefghij**bcdefghi

*****XXXXXabcdefghij

********************

********************

ABCDEFGHIJKLMNOPQRST

** Z

Output

1234*6#9*ABCDEFGHI*<EOL>*

bcdefghij#bcdefghi<EOL>##

*XXXXXabcdefghij<EOL>####

######<EOL>##########<EOL

>ABCDEFGHIJKLMNOPQRST<EOL

># Z<EOL>


相关文章

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

python代写
微信客服:codinghelp