LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 03-31-2010, 07:56 PM   #1
funjoke
LQ Newbie
 
Registered: Mar 2010
Posts: 6

Rep: Reputation: 0
operating system help


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 ?
 
Old 03-31-2010, 08:18 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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.
 
Old 03-31-2010, 09:33 PM   #3
funjoke
LQ Newbie
 
Registered: Mar 2010
Posts: 6

Original Poster
Rep: Reputation: 0
operation system help

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
 
Old 03-31-2010, 09:38 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Can you answer the previous question about whether or not this is homework / assignment?
 
Old 03-31-2010, 09:50 PM   #5
funjoke
LQ Newbie
 
Registered: Mar 2010
Posts: 6

Original Poster
Rep: Reputation: 0
operation system help

this also can consider as homework and assignmemnt because need pass up to lecturer .and it quite important ,.so pls help out thanks
 
Old 03-31-2010, 09:56 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by funjoke View Post
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.
 
Old 03-31-2010, 09:56 PM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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.
 
Old 04-01-2010, 06:10 AM   #8
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
Quote:
...can i get full source code from this website ?
Sure...

Code:
  #include<stdio.h>

  int main(int argc, char ** argv) {
    printf("Do you own bloody homework and stop repeat-posting\n");
    return 0;
  }
 
1 members found this post helpful.
Old 04-01-2010, 06:17 AM   #9
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Hmm. One doesn't need whitespace just after "#include". I didn't know that. Thanks!
 
Old 04-01-2010, 06:48 AM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by wje_lq View Post
Hmm. One doesn't need whitespace just after "#include". I didn't know that. Thanks!
Because word boundary can be unambiguously detected

Similarly, in Perl it is possible to write

Code:
my$x;
instead of the conventional

Code:
my $x;
- the latter is more readable.
 
Old 04-01-2010, 07:18 AM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracing Intruders connecting to our system in Redhat Linux operating system vkunasani Linux - Software 4 02-15-2010 06:23 AM
'Operating system not found' Any operating system installed wont work. TechniSlave Linux - Newbie 55 02-09-2009 11:02 AM
Total Noob Question (Operating System vs File System) fuzzy1 Linux - Newbie 14 02-06-2009 10:33 AM
My grub is not loading on dual operating system with windows Xp Pro causing my system marlene tack Linux - Newbie 2 03-17-2008 07:54 AM
Why Linux is best Operating System for Learning/Doing System Programming ? ubaid_t General 6 03-21-2004 02:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration