Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello please I need help with the following question coding I need you to use Erlang only, here is the part asking to create some

Hello please I need help with the following question coding I need you to use Erlang only,

here is the part asking to create some function in Erlang coding. i a screenshot for it.

In Erlang only thanks

image text in transcribed

8. Create a function producer(Pid, N) that takes consumer's pid and an integer N as arguments. The function is to repeat N times. While the function is running, it generates random numbers and prints them along with its process id to the shell (as in process producing 5, process producing 1, ...):, and then sends these numbers as messages to the consumer process using consumer's pid. (Note: the producer function is set up to send messages but NOT to receive). When you spawn this function in go(), decide on the value of N you will want to pick some small N for testing purposes (e.g. 7) 9. Create a function consum umer() that consumes the numbers sent by the producer via the receive statement, and prints them with along with its process id to the shell (as in process consuming 5, process consuming 1, ...). (Note: the consumer function is set up to receive messages but NOT to send) After verifying everything works, extend the consumer() function by putting the process to sleep for 10 units and only then beginning to receive, timer:sleep (10). Finally, end the consumer process when no new message arrives for about 40 units of time (hint: use after primitive to do so) . 8. Create a function producer(Pid, N) that takes consumer's pid and an integer N as arguments. The function is to repeat N times. While the function is running, it generates random numbers and prints them along with its process id to the shell (as in process producing 5, process producing 1, ...):, and then sends these numbers as messages to the consumer process using consumer's pid. (Note: the producer function is set up to send messages but NOT to receive). When you spawn this function in go(), decide on the value of N you will want to pick some small N for testing purposes (e.g. 7) 9. Create a function consum umer() that consumes the numbers sent by the producer via the receive statement, and prints them with along with its process id to the shell (as in process consuming 5, process consuming 1, ...). (Note: the consumer function is set up to receive messages but NOT to send) After verifying everything works, extend the consumer() function by putting the process to sleep for 10 units and only then beginning to receive, timer:sleep (10). Finally, end the consumer process when no new message arrives for about 40 units of time (hint: use after primitive to do so)

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

Step: 3

blur-text-image

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions