Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this session you will deal with named pipes and multiple file/pipe descriptors. We will consider a very simple bank application with two ATMs through

image text in transcribed

In this session you will deal with named pipes and multiple file/pipe descriptors.

We will consider a very simple bank application with two ATMs through which customers deposit money to an account. Mainly you will implement two programs called bank.c andcustomer.c whose operations are desceribed below.

Log on to your Linux Account.

Create a directory called RecD under cs3733 and do all your work under RecD.

Implement bank.c

Declare and initialize TOTAL to 0.

Check the existance of two named pipes (say ATM1, ATM2). If needed, create them using mkfifo).

Open both pipes to read

In an infinite loop,

Using select, wait for either pipe to be ready (one which has data).

Read an integer (deposit) from the ready pipe and add it to TOTAL

Print TOTAL

Implement customer.c

Get the name of the named pipe from the command line

Open named pipe (argv[1]) to write

In an infinite loop,

Prompt user to enter an integer to deposit

Read an integer from standard input

If user enters an integer less than zero, break loop

Otherwise, write the given integer into the pipe

Close pipes and quit

Using makefile, compile both bank.c and cusomer.c

Open three new terminals and goto RecD in each terminal

In terminal 1, run bank

In terminal 2, run customer ATM1

In terminal 3, run customer ATM2

Randomly go into terminal 2 or 3, and enter integers and see what is printed on terminal 1.

In this session you will deal with named pipes and multiple file/pipe descriptors We will consider a very simple bank application with two ATMs through which customers deposit money to an account. Mainly you will implement two programs called bank.c and customer.c whose operations are desceribed below Log on to your Linux Account. Create a directory called RecD under cs3733 and do all your work under RecD Implement bank.c o Declare and initialize TOTAL to 0 o Check the existance of two named pipes (say ATMI, ATM2). If needed, create them using mkfifo) o Open both pipes to read o In an infinite loop, -Using select, wait for either pipe to be ready (one which has data) - Read an integer (deposit) from the ready pipe and add it to TOTAL Print TOTAL . Implement customer.c o Get the name of the named pipe from the command line o Open named pipe (argv[1]) to write o In an infinite loop, Prompt user to enter an integer to deposit Read an integer from standard input If user enters an integer less than zero, break loop Otherwise, write the given integer into the pipe o Close pipes and quit Using makefile, compile both bank.c and cusomer.c Open three new terminals and goto RecD in each terminal In terminal 1, run bank In terminal 2, run customer ATM1 .In terminal 3, run customer ATM2 Randomly go into terminal 2 or 3, and enter integers and see what is printed on terminal 1 In this session you will deal with named pipes and multiple file/pipe descriptors We will consider a very simple bank application with two ATMs through which customers deposit money to an account. Mainly you will implement two programs called bank.c and customer.c whose operations are desceribed below Log on to your Linux Account. Create a directory called RecD under cs3733 and do all your work under RecD Implement bank.c o Declare and initialize TOTAL to 0 o Check the existance of two named pipes (say ATMI, ATM2). If needed, create them using mkfifo) o Open both pipes to read o In an infinite loop, -Using select, wait for either pipe to be ready (one which has data) - Read an integer (deposit) from the ready pipe and add it to TOTAL Print TOTAL . Implement customer.c o Get the name of the named pipe from the command line o Open named pipe (argv[1]) to write o In an infinite loop, Prompt user to enter an integer to deposit Read an integer from standard input If user enters an integer less than zero, break loop Otherwise, write the given integer into the pipe o Close pipes and quit Using makefile, compile both bank.c and cusomer.c Open three new terminals and goto RecD in each terminal In terminal 1, run bank In terminal 2, run customer ATM1 .In terminal 3, run customer ATM2 Randomly go into terminal 2 or 3, and enter integers and see what is printed on terminal 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago