• No se han encontrado resultados

Diferencias y aspectos comunes entre la empresa social y la

CAPÍTULO 1 EL EMPRENDIMIENTO SOCIAL

1.5. Las Empresas Sociales

1.5.3. Diferencias y aspectos comunes entre la empresa social y la

I. For each arriving packet, the ranking specified on its header is obtained. Queues are tracked bottom-up (from less priority to higher priority), observing which is the ranking level contained in the last enqueued packet from each queue. If the last packet ranking is minor or equal than current packet’s one, the packet is enqueued. Otherwise, the next queue is analyzed in the same manner and the procedure is repeated until reaching the last queue (highest priority). Packets reaching last queue will be enqueued whether their ranking is higher or lower than the one defining the queue.

24 Our Algorithm

Figure 3.5: Strict Priority PIFO (SP-PIFO).

a) Ranking of new packet is obtained: 3.

b) Ranking of last packet in third queue is obtained: 9. c) Is 9 <= than 3?

No: Jump to next queue.

d) Ranking of last packet in second queue is obtained: 7. e) Is 7 <= than 3?

No: Jump to next queue.

As next queue is the first one, packet will be enqueued in the first queue. In this case 2 is smaller than 3, so there is no blocking. But even if there was blocking, packet would still be enqueued in that queue.

II. After having understood the basic procedure now let’s move to the adaptive part, which is detecting blocking and acting to prevent repetition. For this, we need to define the concept of queue level. In the basic procedure of the algorithm, the queue level is the ranking of the packet which was enqueued last. In Figure3.5, the highest priority queue has a level of 2 when the new packet arrives, mid-priority queue has a level of 7 and low-priority queue has a level of 9. When the new packet is enqueued, high priority queue updates its level to 3, following the rank of the newly enqueued packet. This queue level is the fundamental concept when trying to control blockings in the network and react accordingly.

The key point here is to understand why blocking is happening in our algorithm and what does it mean. Then, what can we do to react and prevent it from possibly happening in future events. When starting to run the algorithm, all queues are empty, and initialized with a level of zero. Then the basic procedure takes place, with packets filling the queues and moving to the top as packets with different ranking levels come. When the queue filling reaches the first queue, there is no more space to keep expanding, and therefore ranking granularity has reached its possible end. It is in this moment when blocking can start occurring in the highest-priority queue. Blocking can be easily detected by comparing the rank of the new packet with the level of the queue. If the rank is lower than the level, blocking is going to take place. The fact of blocking happening informs us about the need for higher level of granularity in the top queue. It occurs when high rank packets are sharing the same queue as low rank packets, which would like to enjoy their assigned priority. Blocking therefore shows a problem of queue space granularity for the different rankings. And while not always happens, some times is possible to reach the desired level of granularity by re-designing the distribution of packets throughout the other queues, trying to squeeze the maximum efficiency in the distribution of rankings among available resources. To move some packet assignments to the lower queues,

queue levels of smaller priority queues need to be decreased. This way, as packets start the procedure by checking the queues below, if they experience lower levels, there will be a higher probability that they will finish enqueued in those layers. And, as it is not only important to detect if there is blocking to react, but also to know if the blocking is big (wide difference from new rank to level), we will use the weighted inversion index to measure the blocking and react accordingly. To verify the proper performance of the designed algorithm, we have also developed a Java version to compare the obtained distributions with the theoretical ones, and see how close we are from the ideal results. As can be seen in the snippet below, the only required state to be saved in the switch is a variable queue level for each of the available priority queues. This state will be compared with the packet rank to determine the right allocation position, and after enqueuing the packet, in case blocking occurred, all the below queues will have their levels decreased an amount equivalent to the weighted inversion number of the blocking, to re-distribute weights among the queues and prevent possible blockings in future allocation decisions.

Algorithm 4 Scheduling of each packet in the corresponding queue

1: for (int i=0; i<packets.size(); i++) do

2: for (int q=queueList.size()-1; q>=0; q- -) do

3: if ((queueList.get(q).getLevel()<= packets.get(i). getRank()) || (q==0)) then

4: int WIN = queueList.get(q). addPacket_and_getWIN(packets.get(i));

5: if (WIN > 0) then

6: for (int w=queueList.size()-1; w>=q; w- -) do

7: queueList.get(w).setLevel(queueList.get(w). getLevel()-WIN); 8: end for 9: end if 10: break; 11: end if 12: end for 13: end for

Example of execution 3.5.1. For a scenario with 70 packets, 5 queues and maximum

rank set to 9:

Random sequence of packets generated is:

<- - - - {2}{2}{3}{6}{5}{1}{1}{5}{2}{3}{7}{7}{7}{3}{6}{5}{8}{2}{3}{8} - - - - Packets in queue 0: {1}{1}{2}{3}{3}{5}{2}

Packets in queue 1: {5}{5}{6}{3}

Packets in queue 2: {2}{2}{3}{6}{7}{7}{7}{8}{8}

Output sequence when draining is performed after all allocations: {1}{1}{2}{3}{3}{5}{2}{5}{5}{6}{3}{2}{2}{3}{6}{7}{7}{7}{8}{8}

Inversion number: 25

Weighted inversion number: 55