ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Write a C program that accepts 3 parameters. Each parameter indicates the quantity of product to be
produced. Each product will be produced in different production line. Ready products will be placed
in a buffer area located at the end of each production line. Packaging workers will pack the products
into boxes. Information of each production line as follow:
Production line A: product ready in 1-2 minutes, buffer capacity: 12 units
Production line B: product ready in 2-3 minutes, buffer capacity: 6 units
Production line C: product ready in 1-2 minutes, buffer capacity: 24 units
There are currently 2 packaging workers available. Each worker needs 2 minutes to pack 6 units of
product into a box. The production line will be temporary suspended if the buffer area is full of
product. The operation will continue when the worker has taken 1 unit of product from the buffer
area.
Simulate the operation of production line and the packaging workers by using threads and
appropriate semaphores. There are at least 5 threads, but you may use additional thread if it is
necessary. You have to decide how the workers select the product to pack. Assume that 1 second in
your program is equivalent to 1 minute.
Sample output:
...
Buffer A: 11
Buffer C: 4
Worker X packing B: 3
Buffer B: 8
Worker Y packing C: 2
Buffer A: 12
Production line A suspended.
...
#anybody know how to do this question ? i really no idea on how to do it ,anybody can help me on this coding.i even dun know how to start it and dun know what the question one .i very poor on this ,can anybody help ?
That looks like a homework problem. If it's not, please establish a context.
If it is a homework problem, please describe the class and text you're using. Then show anything you've done re an answer and indicate where you're "stuck."
Again, assuming this is a homework problem, the point of actually doing your homework is that it helps you understand the information presented in the class. You don't learn much by plagiarizing someone other person's work.
but i really dunno how to start and no idea on the coding ...can i get full source code from this website ?i saw from tutorial there .they have provided answer
this also can consider as homework and assignmemnt because need pass up to lecturer .and it quite important ,.so pls help out thanks
There are many C and programming tutorials on the web. If this is homework, we will be glad to HELP when you get stuck, but we're not going to write it for you. Do your own research and work.
Right, so as it is homework / assignment then you are learning something and have attended classes about semaphores and threads.
I believe if you read your books on these topics they will show examples of how they work.
Once you have followed the examples and then altered them to conform to the specification outlined above, let us know where you
get stuck and I am sure someone will help you.
Also, googling for semaphore and thread in C (I assume this is the language being used, if not, change to appropriate one), will
yield a slew of examples and information.
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
funjoke;
Please look at my reply in your other recent thread---If you post again, you need to follow those guidelines
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.