It might occur to you that it would be easier, simpler, and clearer just to include this feature's single procedural line: Launch_producer (a_producer: separate PRODUCER) Notice that the root class uses a feature launch_producer (and a corresponding feature launch_consumer) for instructing the producers and consumers on how many products to handle. It requests the producers to create a number of products, and the consumers, in the aggregate, to consume that same number of products. The root class of the example creates the bounded product buffer and a number of producers and consumers, all given separate types. e., not empty for consumers and not full for producers). To avoid concurrency related problems, producers and consumers can access the buffer only at times when no other producer or consumer is accessing it, and only when it is in the proper state for the particular type requesting access (i. Or the buffer could be full, which would mean that no producer could produce a new product until a consumer had first consumed a product, making space in the buffer. So at any time, the buffer could be empty, precluding any consumer from withdrawing a product. The shared buffer is "bounded", that is, it has a maximum capacity. All producers and consumers must share access to a "buffer" into which producers insert the products they produce, and from which consumers take the products they consume. The problem features one or more "producers" and one or more "consumers". The producer-consumer problem is a classic software concurrency problem.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |