Skip to content Skip to sidebar Skip to footer

Simpy - Accessing Multiple Resources

I am starting to learn SimPy DES framework.I want to implement a simulation in which requests arrive at different times to the server. There are different types of requests, each o

Solution 1:

The easiest solution would be to use the AllOf condition event like this:

cpu_req = cpu.get(15)  # Request 15% CPU capactiy
mem_req = mem.get(10)  # Request 10 memories
yield cpu_req & mem_req  # Wait until we have cpu time and memory
yield env.timeout(10)  # Use resources for 10 time units

This would cause your process to wait until both request events are triggered. However, if the cpu would be available at t=5 and the memory at t=20, the CPU would be blocked for the whole time (from 5-20 + the time you actually use the CPU).

Might this work for you?


Post a Comment for "Simpy - Accessing Multiple Resources"