Resources / Server
Block Name: Server

Code File Location: VisualSim/actor/lib/Smart_Timed_Resource

Block Overview

 o  This is a combination of a queue plus a time delay resource.  This is an Active resource

 o  This is a multi-dimension resource, which means multiple queues + time delay can be defined in a single block.

 o  This block is used when the processing time is known in advance and provided along with the transaction to this block.

 o  If defining a name for the Server block is difficult because of the Class or Hierarchical association, use the TimedQueue. it is the same functionality and there is no Name for the Queue.

 o  It is used to model schedulers, processors and RTOS. There is a SLOT option that models any slot-based archietcture such as multiple virtual RTOS, TDMA etc.

 o  Define multi-core processors, parallel buses, dma channels, wireless channels, wired virtual channels etc.

Smart_Timed_Resource

Description

The following is a block diagram that illustrates the operation of the Server block.

Smart_Timed_Resource


This block defines multiple Active Resources where each operates as an independent queue + Server.  Each queue orders the incoming data structures in the order from highest to the lowest priority. Higher the number signifies higher priority. Queues is reordered based on priority, at the entry of each transaction.  The Queue_Number_Field selects the queue and the Priority_Field provides the priority value. This block queues the incoming data structure in a FIFO or LIFO order. When the data structure/transaction reaches the head of the queue, it is delayed by the amount provided in Time_Field and sent to the output.  The SLOT is a special operation mechanism and the arriving transactions are ordered in a FIFO manner. The SLOT is explained below.

The statistics and current queue length can be accessed using getBlockStatus, Server_Name + "_" + Length(queue_index)) or Resource_Statistics block.  

A special queue type of this block is the "SLOT".  This is best used to model schedulers, RTOS and communication channels that allocated fixed resources to a set of timed segments, virtual channels or virtual machines. In this case, each queue is a slot. The duration of the slot is provided by the Time_Field which must be a double value and not a field name. In addition, one can enter an array of slot times for variable size slot times for each Queue. The array length must match the Number_of_Queues.  Variable slot times allow for control of the bandwidth to specific SLOTs.  

If there are 10 queues, then there are 10 slots.  At the end of the first slot, queue one will output and at the end of the second slot, queue two will output. This will repeat for slots 3 and later. If the Time_Field is set to 1.0, then the transaction will exit from slot one in order at times 1.0, 11.0, 21.0, etc. Slot two will exit at times 2.0, 12,0, 22,0, etc. If there is no transaction in a queue, then no transaction is output for that Slot time.  This slot time will not be allocated to the next queue.

Statistics

The statistics for the Server are generated using the getBlockStatus RegEx function, Resource_Statistics block or the array Server_Name + "_" + Length.  The function and array lookup can be called in either the Script, Smart_Controller and ExpressionList blocks.  

      Result_B = Server_Length(2) where the array index starts at 1 for Queue number 1.  Array Index of 0 is not used.

Statistics_A = getBlockStatus(Server_Name,"Any Value","stats",Queue_Number,1)  -> To get the statistics.  

Reset_Stats_A = getBlockStatus(Server_Name,"Any Value","stats",-(Queue_Number), 1)   -> To reset the statistics.  

If reset or statistics is required for all Queue, then make the Queue_Number = Number of Queues + 1.

There is a pre-created "Generator" block and is used in the Resource_Statistics Example in the BDE.

Copy_A = getBlockStatus(Server_Name,"Any Value","copy",Queue_Number, position)  -> To get copy of the Data Structure at a position in the Queue.

Length_A = getBlockStatus(Server_Name,"Any Value","length",Queue_Number,1)  -> To get the length of the selected Queue.

isAvailable =  getBlockStatus(Server_Name,"Any Value","array",Any Integer, Any Integer)- Returns an array of which Queue is free (true) or busy (false)

To learn about the use of the getBlockstatus, check the library example for getBlockStatus.

Refer Server demo model.

Refer to the Server demo model using Power.

Refer to the Server demo for SLOT usage.

Power

To enable power analysis of the Server resource, add a line to the Power_Manager block with the following information:

STR_ServerName    Active   Standby 0.0   0.0   Standby   Standby   Active  Transition_Time           1000.0     1.0     ;

STR_ServerName       70.0     300.0   0.0   0.0   Standby   Standby   Active     0.0                             1000.0     1.0     ;   

These are the only two states used for the power, and are the same for all the Server resources.  Each Queue of the Server is treated as a separate entity and the power is computed separately.  When a data structure executes a delay in a queue, there is a transition_time delay and the Time Delay of the Data Structure.

Users can modify the current power state to any other state using the RegEx function.  This can be handy to move the resource to a sleep, polling, ready or other states.  For this purpose, any additional columns can be setup in the PowerTable block.

Statistics Output

Statistic Name 

Value 

Explanation 

Mathematical Equation

 Type 

Number_Entered  

100

Number of transactions entering the queue.

-

int

Number_Exited

25

Number of transactions that left the queue.

-

int

Number_Rejected

10

Number of transactions rejected and output to reject port.

-

int

Queue_Number 

1

Queue Number.  Queue number start at 1.

-

int

Occupancy_Min

4.0

Minimum queue usage during the simulation.

 if (Xn < Xn – 1) Xmin = Xn

double

Occupancy_Mean 

8.0

Mean/Average queue usage during the simulation.

    Xµ  = (1 / n) * (X1 + X2 + … + Xn)

double

Occupancy_StDev

3.0

Standard Deviation from the Mean queue usage during the simulation.

Xσ = Math.sqrt ((1 / n) * ((X1 - Xµ)2 + (X2 - Xµ)2  + … + (Xn - Xµ)2))

STDEV_90_PCT = 1.6448530004790

STDEV_95_PCT = 1.9599610823207

STDEV_99_PCT = 2.5758345145732

double

Occupancy_Max 

25.0

Maximum queue usage consumed during the simulation.

    if (Xn > Xn – 1) Xmax = Xn

double

Total_Delay_Min

1.3

In seconds. Least time through the queue+server among all transactions.

 if (Xn < Xn – 1) Xmin = Xn

double

Total_Delay_Mean 

1.3

In seconds. Mean/Average time through the queue+server among all transactions.

    Xµ  = (1 / n) * (X1 + X2 + … + Xn)

double

Total_Delay_StDev

1.3

In seconds. Standard Deviation from the Mean time through the queue+server among all transactions.

Xσ = Math.sqrt ((1 / n) * ((X1 - Xµ)2 + (X2 - Xµ)2  + … + (Xn - Xµ)2))

STDEV_90_PCT = 1.6448530004790

STDEV_95_PCT = 1.9599610823207

STDEV_99_PCT = 2.5758345145732

double

Total_Delay_Max

1.3

In seconds. Maximum time through the queue+server among all transactions.

    if (Xn > Xn – 1) Xmax = Xn

double

Utilization_Pct_Mean 

10.0

Mean/Average utilization of the server portion only.  Queue utilization not considered. Units are in percentage.

    Xµ  = (1 / n) * (X1 + X2 + … + Xn)

double


Where n is the number of samples and X is occupancy or delay.



Parameter

Explanation

Type

 Example 

Block_Name

Block_Name needs to be unique in modeling space. It is used to identify the block in the Script/ Smart_Controller for determining queue length.

String

"ServerName"

Queue_Number_Field 

Queue_Number_Field selects the Queue number to place the incoming Data Structure.  This is an expression that can contain a fixed value, parameter, variable, data structure  field, RegEx and Expression.  The numbering is one-based, queues selected from 1 to N, 0 will throw an exception. The field needs to be an integer, or will throw an exception.

String

A_Queue_Number

or

1

or

(Que_Length(1)>Que_Length(2))?4:3

Priority_Field

Priority_Field provides the priority number for reordering the queue.  This is an expression that can contain a fixed value, parameter, variable, data structure  field, RegEx and Expression.  The higher number is higher priority.  "None" or the default value is a valid entry.

String

A_Priority" or 2 or None

Time_Field

Time_Field provides the time delay for data structure.  This is an expression that can contain a fixed value, parameter, variable, data structure  field, RegEx and Expression.  "None" or the default value is NOT a valid entry.


For "SLOT" mode the parmeter will be a fixed double value.

String

"A_Time", 1.0 (SLOT or timed operation)

Max_Queue_Length

This is the maximum queue length for each queue and applies to 'Number_of_Queues' parameter, see below.  It is be a single value which will be common to all Queue.

Integer

30

Number_of_Queues

This is number of independent queues in this block.  If "SLOT" mode using variable slot times, then the number of queues parameter must match the Time_Field array length, else an exception will be thrown.

Integer

1

Queue_Type

Queue type attribute can be "FIFO," "LIFO" or "SLOT". The default is "FIFO."  This first two are the ordering of the tokens in the queue, either First-In, First-Out or Last-In, Last-Out.  The SLOT is a scheduling mechanism.  If SLOT is selected, the TIME_FIELD must be a double value and cannot be a field name.

           -

FIFO



Port

Explanation

Input

Input port for data tokens (numerical values) or data structures entering the queue. The queues can support any token type.

Output

Output port sending the head of the queue based on 'pop_input' port integer value, see above. The type is based on the token type in queue. The data token or data structure removed from the queue. 

reject_output

Output port sending the rejected token to this port. The type is based on the input token type.