Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-15-2004, 12:03 AM   #1
Registered: Oct 2002
Location: Ohio, USA
Distribution: OS X 10.4.8, Ubuntu 6.10
Posts: 146

Rep: Reputation: 15
Question Simulation progam

Ok, I am writing a program in C++ that simulates a M/D/1 multiplexor. Basically, I have the command line params like N (# of lines to wait in), R (Rate bps), alpha (busy time), M (output capacity), closeTime. What the program needs to do is generate random customers to wait in N. The R is the speed at which things are to be done. I'm not to sue what alpha is to be used for.. (sorry...) and M is the maximum output avaliable for the machine.

For those of you who are still with me, thanks for continuing to read. I need to write this to have three modules. One to generate the customers. This generates them with an exponential interarrival time distribution with mean 1/lambda. If the server is busy, the customer is to go into FIFO line. Wake up and generate the next customer after the 1AT. This continues until closing time.

The second module is to serve the customer. It is to pick up the next customer from the line and serve them, if there aren't any, sleep.

The third is the Stats. Compute the mean arrival time, mean service rate, mean time customers spends in system, mean wait time, etc.. and write to an output file.

Ok, now this was given to me as a program from my work and I am new to this. I understand the third module and how to do that just fine. It's the first two that I'm not clear on. A co-worker told me that I am to use GSL to generate the random customers and I believe I can do that, ex:



T = gsl_rng_default;
r = gsl_rng_alloc;

Now from what I understand that will install the GSL enviroment and being to generate random customers with the help of:

customer = gsl_ran_exponential(r, 1/mu);
I'm just not to sure how the heck to get it to go into a FIFO if there are two many customers... Same with sleep if there aren't too many.

On the second module, I'm not sure what my boss wants me to do to serve the customer but since he didn't specify it could probably something simple like have it do a calculation of some sort. Now how could I keep track of the time spent here?

I know this is a huge problem and if anyone has any insight it will more than likely help me keep my job. Thanks for any insight!!

Old 03-15-2004, 10:39 AM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180 looks like one of my tasks during programming course (long ago). Don't take me wrong, I'm not saying it's your homework, you probably understand what I think...

So how would I do it...Probably by three threads. One generating customers (in fact, it's telling us 'there's a customer!') and setting the arrival time in the special field in customer structure. Then it passes it to a FIFO (without checking if FIFO's empty or not; you may need a test if FIFO's full or not). Second end of the FIFO is in the second thread. It wakes when something's in the FIFO (if it was idle). It sets time for 'start of work' (also in the client structure) and does something with the client. When finishing, it sets another timestamp. Then it passes the client to the third (stats) thread and checks if there's something in the FIFO. If not, it sleeps.
Old 03-15-2004, 07:26 PM   #3
Registered: Oct 2002
Location: Ohio, USA
Distribution: OS X 10.4.8, Ubuntu 6.10
Posts: 146

Original Poster
Rep: Reputation: 15
Thanks a lot. I'll try and do something similar to that when I go back into work tomorrow. Thanks!



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Desktop links to progam .. needs konsole!! Astrologer Linux - Software 4 09-24-2005 09:24 AM
socket progam crashing nasarlinux Programming 5 08-27-2005 03:41 AM
ID3 tag progam Bomb187 Linux - Software 3 03-18-2004 04:57 PM
Bookkeeping progam Delorian Linux - Software 2 05-08-2003 11:27 AM
Need Help Installing Freeamp progam Manimal Linux - Software 0 03-25-2002 12:28 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:12 PM.

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