|
Loading
|
||||
Queues and stacksIt is often nice to be able to simulate a queue or stack discipline for places, e.g. for communication over a TCP channel. Alas, CPN Tools does not currently support this, but this is easy done by the modeler. ExampleThis is a very simple model of a sender and a receiver. The sender, sends packages onto a network. The receiver receives packages from the network. StackWe want the network to have a LIFO (last in, first out), or stack behavior. (Yes, this is not realistic, but then I only need to introduce one example). We change the type of the place from “T” to “list T”, and make all ingoing arcs preprend to the list, and all outgoing arcs should then remove the head from the list. When I do this to the above example, I get: Changes to declarations
Changes to the network place
Changes to (ingoing and outgoing) arcs
QueuesWe want the network to have a FIFO (first in, first out), or queue behavior. This is like the behavior of TCP streams. We change the type of the place from “T” to “list T”, and make all ingoing arcs append to the list, and all outgoing arcs should then remove the head from the list. The only difference from stacks is that instead of prepending to the list, we append to it. When I do this to the example, I obtain: Changes to declarations
Changes to the network place
Changes to outgoing arcs
Changes to incoming arcs
Priority queuesWe want the network to have a priority-queue behavior, i.e. the priority of a packet determines the order in which it is handled. This is similar to IP quality-of-service options which allow datagrams to be identified (and possibly handled) with eight levels of precedence. We change the type of the place from “T” to “list T”, and make all ingoing arcs insert elements into the list according to precedence/priority, and all outgoing arcs should then remove the head from the list. The difference from FIFO queues is that instead of appending to the list, elements are added according to their priority. When I do this to the example, I obtain: Changes to declarations
Changes to the network place
Changes to outgoing arcs
Changes to ingoing arcs
ExamplesThe examples described in this document can be downloaded |
||||