Esempio n. 1
0
File: ossim.py Progetto: gaber/simx
        
        bp = self.os.create_process(BarProcess)
        # waits for Bar process to finish before resuming
        self.waitfor(bp)

        print "Foo process ",id(self)," on node",self.os.get_entity_id(), \
            "returned from waitfor. Acquired resource ",self.resource, \
            " at time ", simx.get_now()



#initialize
simx.init("ossim")
simx.set_end_time(1000)
simx.set_min_delay(1)
simx.set_log_level("debug3")
simx.init_env()

num_nodes = 1

#create nodes
for i in xrange(num_nodes):
    simx.create_entity(('n',i), os.Node,ent_data=({'num_cores':1}))

num_processes = 1
#on each node create foo processes
for i in xrange(num_nodes):
    node = simx.get_entity(('n',i))
    # the node might not live in this memory space
    # in a distributed memory simulation
Esempio n. 2
0
File: hello.py Progetto: thulas/simx
from Person import *
from HelloHandler import *


####### Initialize MPI and configuration framework#######
simx.init("HelloWorld")

end_time = 2**10

##### set simulation configuration values ########
simx.set_min_delay(10)
simx.set_end_time(end_time)

# These are optional
simx.set_output_file("helloworld.out")
simx.set_log_level("info")
simx.set_log_file("helloworld.log")

####### Initialize environment (logging, output etc) ###########
simx.init_env()


##### Add services to be used in the simulation ########
# the second argument is a profile (should be dictionary (can be empty) or None)
hh = simx.add_service('HelloHandlerPerson',None,[]) 

##### Create Entities ##########

# create an entity profile (optional)
ep = { 'SERVICES':{eAddr_HelloHandlerPerson:hh}}
Esempio n. 3
0
File: cd.py Progetto: nmtrmail/simx
    """
    Just another process
    """
    def __init__(self, id_):
        self.id_ = id_

    def run(self):
        print "foo process: ", self.id_, " Time: ", simx.get_now()
        #if id == 0:
        #    self.spawn(fooprocess(id+1))
        self.sleep(2)
        print "foo process: ", self.id_, " wake up at time:", simx.get_now()

    def end(self):
        print "foo process: ", self.id_, " ends here"


simx.init("cd")

simx.set_min_delay(1)
simx.set_end_time(100)
simx.set_log_level("debug3")

simx.init_env()

for i in range(1):
    cd = CountDown(i, 10)
    simx.schedule_process(cd)

simx.run()
Esempio n. 4
0
import simx
import random

endTime = 500
count = 100000
maxSleep = 100

#Initialize
simx.init("GREEN")
simx.set_end_time(endTime)
simx.set_min_delay(1)
simx.set_log_level("warn")
simx.init_env()


#Create a message generation process
class processApp(simx.Process):
    """
    Schedule the compute nodes to run their applications (Booting Up)
    """
    def run(self):
        while True:
            x = int(maxSleep * random.random())
            #print "Sleeping for", x
            self.sleep(x)
            #print "Woke"


for i in xrange(count):
    #print "Adding process", i
    mg = processApp()
Esempio n. 5
0
from Person import *
from HelloHandler import *

####### Initialize MPI and configuration framework#######
simx.init("HelloWorld")

end_time = 2**10

##### set simulation configuration values ########
simx.set_min_delay(10)
simx.set_end_time(end_time)

# These are optional
simx.set_output_file("helloworld.out")
simx.set_log_level("info")
simx.set_log_file("helloworld.log")

####### Initialize environment (logging, output etc) ###########
simx.init_env()

##### Add services to be used in the simulation ########
# the second argument is a profile (should be dictionary (can be empty) or None)
hh = simx.add_service('HelloHandlerPerson', None, [])

##### Create Entities ##########

# create an entity profile (optional)
ep = {'SERVICES': {eAddr_HelloHandlerPerson: hh}}

num_entities = 2**5
Esempio n. 6
0
import simx
import random

endTime = 500
count = 100000
maxSleep = 100

#Initialize
simx.init("GREEN")
simx.set_end_time(endTime)
simx.set_min_delay(1)
simx.set_log_level("warn")
simx.init_env()

#Create a message generation process
class processApp(simx.Process):
    """
    Schedule the compute nodes to run their applications (Booting Up)
    """
    def run(self):
        while True:
            x = int(maxSleep*random.random())
            #print "Sleeping for", x
            self.sleep(x)
            #print "Woke"

for i in xrange(count):
    #print "Adding process", i
    mg = processApp()
    simx.schedule_process(mg)