Question
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
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 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started