M/M/C queue with C++

Discussion in 'C++' started by martial, Jan 16, 2007.

Thread Status:
Not open for further replies.
  1. martial

    martial New Member

    Joined:
    Jan 9, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone:

    The following program simulates a M/M/1 queue system. i have some difficulties in changing the program to simulate a M/M/C queue with 3 servers. Can anyone help me to solve this problem?

    Thanks in advance for your help

    Code:
    #include <stdio.h>      
    #include "smpl.h"       
    
    void main(void)
    {
      real Ta = 200;        // Mean interarrival time (seconds)
      real Ts = 100;        // Mean service time
      real te = 1.0e6;      // Total simulation time
      int customer = 1;     // Customer id (always '1' for this simulation)
      int event;            // Event (1 = arrival, 2 = request, 3 = completion)
      int server;           // Handle for server facility
    
      // Initialize SMPL subsystem
      smpl(0, "M/M/1 Queue");
    
    // Initialize server facility (single server)
      server=facility("server", 3);
    
      // Schedule arrival event at time 0 to kick-off simulation
      schedule(1, 0.0, customer);
    
      // Loop while simulation time is less than te
      while (time() < te)
      {
        // "Cause" the next event on the event list
        cause(&event,&customer);
    
        // Process the event
        switch(event)
        {
          case 1:  // *** Arrival
            schedule(2, 0.0, customer);
            schedule(1, expntl(Ta), customer);
            break;
    
          case 2:  // *** Request Server
            if (request(server, customer, 0) == 0)
              schedule(3, expntl(Ts), customer);
         break;
    
          case 3:  // *** Release server
            release(server, customer);
            break;
        }
      }
    
      // Output standard SMPL report
      report();
    }
     
    Last edited by a moderator: Jan 17, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Duplicate of [thread=2500]How to implement a M/M/1 queue in C++[/thread]. Thread closed.
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice