An M/M/c queue is a basic queue with $c$ identical servers, exponentially distributed interarrival times, and exponentially distributed service times for each server. The arrival rate is defined as $\lambda$ such that the interarrival time distribution has mean $1/\lambda$. Similarly, the service rate is defined as $\mu$ such that the service time distribution has mean $1/\mu$ (for each server). The overall traffic intensity of the queue is $\rho = \lambda / (c \mu)$. If the traffic intensity exceeds one, the queue is unstable and the queue length will grow indefinitely.
In [ ]:
    
Pkg.add("Distributions")
Pkg.add("SimJulia")
    
In [2]:
    
using Distributions
using SimJulia, ResumableFunctions
    
    
In [3]:
    
srand(8710) # set random number seed for reproducibility
num_customers = 10 # total number of customers generated
num_servers = 2 # number of servers
mu = 1.0 / 2 # service rate
lam = 0.9 # arrival rate
arrival_dist = Exponential(1 / lam) # interarrival time distriubtion
service_dist = Exponential(1 / mu); # service time distribution
    
In [4]:
    
@resumable function customer(env::Environment, server::Resource, id::Integer, time_arr::Float64, dist_serve::Distribution)
    @yield timeout(env, time_arr) # customer arrives
    println("Customer $id arrived: ", now(env))
    @yield request(server) # customer starts service
    println("Customer $id entered service: ", now(env))
    @yield timeout(env, rand(dist_serve)) # server is busy
    @yield release(server) # customer exits service
    println("Customer $id exited service: ", now(env))
end
    
    Out[4]:
In [5]:
    
sim = Simulation() # initialize simulation environment
server = Resource(sim, num_servers) # initialize servers
arrival_time = 0.0
for i = 1:num_customers # initialize customers
    arrival_time += rand(arrival_dist)
    @process customer(sim, server, i, arrival_time, service_dist)
end
run(sim) # run simulation