Question: In this assignment, write a Go program to simulate the producer / consumer processes, as described in section 3 . 5 of the Operating System
In this assignment, write a Go program to simulate the producerconsumer processes, as described in section of the Operating System Concepts book:
simulate a producer and a consumer, each as a goroutine:
the producer produces a given number of random integers in a given range and sends each to the consumer via an unbuffered channel unidirectional or bidirectional
the producer goroutine outputs each number before it sends it
the consumer receives each integer from the producer and consumes it
the consumer goroutine outputs each number after it receives it
modify your program from part so that a buffered channel of a given size is used
Sample Runs
Part the command line argument determines both the number of integers and the range of integers
$ go run main.go
Produced
Consumed
Produced
Produced
Consumed
Consumed
Produced
Produced
Consumed
Consumed
Produced
Produced
Consumed
Consumed
Produced
Produced
Consumed
Consumed
Produced
Part a buffered channel of size is used
$ go run main.go
Produced
Produced
Produced
Produced
Consumed
Consumed
Consumed
Consumed
Produced
Produced
Produced
Produced
Produced
Consumed
Consumed
Consumed
Consumed
Consumed
Produced Write for GOLANG
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
