Exemple #1
0
def read_next_job_and_register_timer_event ():

    global g_flag_sim_entity_term
    job = pop_job_from_Workloads()
    if job is not None:
        timer = job.pop(1)
        evt_data = job

        # ------------------------
        # EVENT MESSAGE
        # ------------------------
        # EVENT_ID   = EVENT UNIQUE ID
        # EVENT_TIME = EVENT_SIM_CLOCK or EVENT_TIME_OUT CLOCK
        # EVENT_SRC  = Event Message Sender
        # EVENT_DST  = Event Message Receiver
        # EVENT_CODE = Event Type
        # EVENT_SUB_CODE = Event Sub Type
        # EVENT_DATA = Event DaTa
        # ------------------------

        # register timer event
        q_evt = clib.make_queue_event (timer, g_my_block_id, simgval.gBLOCK_SIM_EVENT_HANDLER, simgval.gEVT_SET_TIMER, simgval.gEVT_SUB_SEND_JOB, evt_data)

        gQ_OUT.put (q_evt)
    else:

        g_flag_sim_entity_term = True

        # Timer Event for Workload Gen Termination
        q_evt = clib.make_queue_event (1, g_my_block_id, simgval.gBLOCK_SIM_EVENT_HANDLER, simgval.gEVT_SET_TIMER, simgval.gEVT_SUB_WORKGEN_TERMINATE, None)
        gQ_OUT.put (q_evt)
Exemple #2
0
def sim_clock_evt_set_clock_ack_processing(q_msg):

    evt_clock = q_msg[1]
    evt_code = q_msg[4]
    evt_sub_code = q_msg[5]
    evt_data = q_msg[6]

    if evt_code != simgval.gEVT_SET_CLOCK_ACK:
        g_log_handler.error(
            "[SimClock] %s sim_clock_evt_sim_ack_processing EVT_CODE (%s) Error! => %s"
            % (str(Global_Wall_Clock), simgval.get_sim_code_str(evt_code),
               q_msg))
        clib.sim_exit()

    if Global_Wall_Clock == (evt_clock):

        #time.sleep(1)
        print "[SimClock] Simulation Clock OK: SIM_TIMER:%ds, SIM_EVENT_HANDLER:%ds" % (
            Global_Wall_Clock, evt_clock)

        # increase wall clock
        tick = evt_sub_code
        increase_Wall_Clock(tick)

        q_evt = clib.make_queue_event(Global_Wall_Clock, g_my_block_id,
                                      simgval.gBLOCK_SIM_EVENT_HANDLER,
                                      simgval.gEVT_SET_CLOCK, tick, None)
        gQ_OUT.put(q_evt)

    else:

        g_log_handler.error("[SimClock] Simulation Clock Mismatch: SIM_TIMER:%ds, SIM_EVENT_HANDLER:%ds" \
              % (Global_Wall_Clock, evt_clock))
        clib.sim_exit()
Exemple #3
0
def workgen_send_evt_ack (evt_id, evt_org_code):

    ack_evt = clib.make_queue_event (0, g_my_block_id, simgval.gBLOCK_SIM_EVENT_HANDLER, simgval.gEVT_ACK, evt_org_code, None)
    ack_evt[0] = evt_id
    gQ_OUT.put (ack_evt)

    return
Exemple #4
0
def workgen_evt_sub_send_job_processing (q_msg):

    # Send Job to Broker
    evt_id          = q_msg[0]  # EVT_ID
    evt_code        = q_msg[4]  # EVT_CODE
    evt_sub_code    = q_msg[5]  # EVT_SUB_CODE
    evt_data        = q_msg[6]  # EVT_DATA

    if evt_sub_code != simgval.gEVT_SUB_SEND_JOB:
        g_log_handler.error("[Work_Gen] %s workgen_evt_sub_send_job_processing EVT_CODE (EC:%s, ESC:%s) Error! => %s" %(str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_sub_code), q_msg))
        clib.sim_exit()

    qe_data =  [simgval.gEVT_WORK_GEN]
    qe_data.extend (evt_data)

    q_evt = clib.make_queue_event (0, g_my_block_id, simgval.gBLOCK_SIM_EVENT_HANDLER, simgval.gEVT_BYPASS, simgval.gBLOCK_BROKER, qe_data)
    gQ_OUT.put (q_evt)

    g_joblog_handler.info ('%s\t%s\t%d\t%d\t%s\t%d\t%s\t%d\t\t%s'
                           % (str(Global_Curr_Sim_Clock), evt_data[0], evt_data[1], evt_data[2], simgval.get_sim_code_str(evt_data[3]), evt_data[4], simgval.get_sim_code_str(evt_data[5]), evt_data[6], evt_data[7]))

    # read the next job
    read_next_job_and_register_timer_event ()

    # send event ack
    workgen_send_evt_ack (evt_id, evt_code)
Exemple #5
0
def wakeup_sim_clock(flag_send_ack, jump_clock):
    if flag_send_ack is not True:
        return

    # send ack packet to clock - active clock thread
    q_evt_clock = clib.make_queue_event(Global_Curr_Sim_Clock, g_my_block_id,
                                        simgval.gBLOCK_SIM_CLOCK,
                                        simgval.gEVT_SET_CLOCK_ACK, jump_clock,
                                        None)
    gQ_CLOCK.put(q_evt_clock)
Exemple #6
0
def SEH_send_evt_ack(evt_id):

    dst_block_id = simgval.gBLOCK_SIM_EVENT_HANDLER
    evt_code = simgval.gEVT_ACK

    ack_evt = clib.make_queue_event(0, g_my_block_id, dst_block_id, evt_code,
                                    None, None)
    ack_evt[0] = evt_id
    send_EVT_to_Block(evt_code, dst_block_id, ack_evt)

    return
Exemple #7
0
def terminate_sim_entity_workloadgen (q_msg):

    evt_id          = q_msg[0]  # EVT_ID
    evt_code        = q_msg[4]  # EVT_CODE
    evt_sub_code    = q_msg[5]  # EVT_SUB_CODE

    if evt_code != simgval.gEVT_EXP_TIMER or evt_sub_code != simgval.gEVT_SUB_WORKGEN_TERMINATE:
        g_log_handler.error("[Work_Gen] %s EVT_CODE (%s)/EVT_SUB_CODE (%s) Error! => %s" \
              %(str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_sub_code), q_msg))
        clib.sim_exit()

    # [a] ack send first
    workgen_send_evt_ack (evt_id, evt_code)

    # [b] send gEVT_NOTI_SIMENTIY_TERMINATED (common event code) to event handler
    term_evt = clib.make_queue_event (Global_Curr_Sim_Clock, g_my_block_id, simgval.gBLOCK_SIM_EVENT_HANDLER, simgval.gEVT_NOTI_SIMENTIY_TERMINATED, None, None)
    gQ_OUT.put (term_evt)
Exemple #8
0
def sim_clock_evt_sim_start_processing(q_msg):

    evt_code = q_msg[4]
    if evt_code != simgval.gEVT_SIM_START:
        g_log_handler.error(
            "[SimClock] %s sim_clock_evt_sim_start_processing EVT_CODE (%s) Error! => %s"
            % (str(Global_Wall_Clock), simgval.get_sim_code_str(evt_code),
               q_msg))
        clib.sim_exit()

    g_log_handler.info("[SimClock] %s Simulation Start..." %
                       (Global_Wall_Clock))

    # send msg to sim_evt_handler ==> Wake up event for simulation event handler
    q_evt = clib.make_queue_event(Global_Wall_Clock, g_my_block_id,
                                  simgval.gBLOCK_SIM_EVENT_HANDLER,
                                  simgval.gEVT_SET_CLOCK, None, None)
    gQ_OUT.put(q_evt)
Exemple #9
0
def sim_clock_evt_sim_end_processing(q_msg):

    evt_code = q_msg[4]

    if evt_code != simgval.gEVT_SIM_END:
        g_log_handler.error(
            "[SimClock] %s sim_clock_evt_sim_end_processing EVT_CODE (%s) Error! => %s"
            % (str(Global_Wall_Clock), simgval.get_sim_code_str(evt_code),
               q_msg))
        clib.sim_exit()

    g_log_handler.info(
        "[SimClock] %s EVT_RECV: %s" %
        (str(Global_Wall_Clock), simgval.get_sim_code_str(evt_code)))

    # simulation complete event
    sim_end_evt = clib.make_queue_event(Global_Wall_Clock, g_my_block_id,
                                        simgval.gBLOCK_SIM_EVENT_HANDLER,
                                        simgval.gEVT_SIM_END, None, None)
    gQ_OUT.put(sim_end_evt)
Exemple #10
0
def SEH_evt_noti_simentity_terminated(q_msg):

    evt_src = q_msg[2]  # EVT_SRC
    evt_code = q_msg[4]  # EVT_CODE

    if evt_code != simgval.gEVT_NOTI_SIMENTIY_TERMINATED:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! => %s" %
                            (str(Global_Curr_Sim_Clock),
                             simgval.get_sim_code_str(evt_code), q_msg))
        clib.sim_exit()

    remaining_events_exist = find_Timer_Event_by_block(evt_src)
    if remaining_events_exist is True:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Processing Error! => Timer Events for %s Exist!" \
              % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_src)))
        clib.sim_exit()

    set_sim_entity_running_state(evt_src, False)
    print "[SimEvent] %s EVT_CODE (%s) Processing => %s" \
          % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), str(g_Sim_Entity_Running_States[simgval.gBLOCK_SIM_ENTITY_START+1:]))

    # [condition 1] if all sim entities are false (stopped), send termination noti event to sim_clock
    all_entities_terminated = all(
        state is False for state in
        g_Sim_Entity_Running_States[simgval.gBLOCK_SIM_ENTITY_START + 1:])

    # [condition 2] no timer events
    no_of_tmr_evts = get_number_of_imp_Timer_Events()

    if all_entities_terminated is True and no_of_tmr_evts < 1:

        # Set Termination Flag
        set_SEH_sim_entity_term_flag(True)

        # simulation complete event
        sim_end_evt = clib.make_queue_event(Global_Curr_Sim_Clock,
                                            g_my_block_id,
                                            simgval.gBLOCK_SIM_CLOCK,
                                            simgval.gEVT_SIM_END, None, None)
        gQ_CLOCK.put(sim_end_evt)
Exemple #11
0
def SEH_evt_bypass_processing(q_msg):

    evt_src = q_msg[2]  # EVT_SRC
    evt_code = q_msg[4]  # EVT_CODE
    evt_sub_code = q_msg[5]  # EVT_SUB_CODE
    evt_data = q_msg[6]  # EVT_DATA

    if evt_code != simgval.gEVT_BYPASS:
        g_log_handler.error(
            "[SimEvent] %s SEH_evt_bypass_processing EVT_CODE (%s) Error! => %s"
            % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code),
               q_msg))
        clib.sim_exit()

    print "[SimEvent] %s IN  Sentout_Timer_Event_IDs=>" % str(
        Global_Curr_Sim_Clock), Sentout_Timer_Event_IDs

    so_evt_dst_block = evt_sub_code
    so_evt_code = evt_data.pop(0)  # EVT_DATA[0] -- Actual Event Code.
    so_evt_sub_code = evt_src
    so_evt_data = evt_data

    q_evt_so = clib.make_queue_event(Global_Curr_Sim_Clock, g_my_block_id,
                                     so_evt_dst_block, so_evt_code,
                                     so_evt_sub_code, so_evt_data)
    r = send_EVT_to_Block(evt_code, so_evt_dst_block, q_evt_so)
    if r is False:
        g_log_handler.error(
            "[SimEvent] %s EVT_BYPASS DST BLOCK (%s) ERROR!!!" %
            (str(Global_Curr_Sim_Clock),
             simgval.get_sim_code_str(so_evt_dst_block)))
        clib.sim_exit()

    print "[SimEvent] %s 1 BYPASS_EVT:%s sent out" % (
        str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(so_evt_code))
    print "[SimEvent] %s Out Sentout_Timer_Event_IDs=>" % str(
        Global_Curr_Sim_Clock), Sentout_Timer_Event_IDs
Exemple #12
0
def run_simulation():

    # create config obj.
    sim_conf = simobj.Config(1)
    load_sim_config(sim_conf)

    # check workload data
    check_workload_data(sim_conf)

    # load VM types
    load_vm_types(sim_conf)

    # initialize_logs
    initialize_logs(sim_conf)

    clib.display_conf_obj(0, sim_conf)

    #create queues
    Q_SimClock = Queue.Queue()
    Q_SimEventHandler = Queue.Queue()
    Q_WorkloadGenerator = Queue.Queue()
    Q_Broker = Queue.Queue()
    Q_IaaS = Queue.Queue()

    threads = []

    log_dir = sim_conf.log_path

    thread = thread_sim_clock(simgval.gBLOCK_SIM_CLOCK, sim_conf, Q_SimClock,
                              Q_SimEventHandler)
    thread.start()
    threads.append(thread)
    print "* Create Thread - Sim Clock"

    thread = thread_sim_event(simgval.gBLOCK_SIM_EVENT_HANDLER, sim_conf,
                              Q_SimEventHandler, Q_SimClock,
                              Q_WorkloadGenerator, Q_Broker, Q_IaaS)
    thread.start()
    threads.append(thread)
    print "* Create Thread - Sim Event Handler"

    thread = thread_sim_entity_workload_generator(simgval.gBLOCK_WORKLOAD_GEN,
                                                  sim_conf,
                                                  Q_WorkloadGenerator,
                                                  Q_SimEventHandler)
    thread.start()
    threads.append(thread)
    print "* Create Thread - Sim Workload Generator"

    thread = thread_sim_entity_broker(simgval.gBLOCK_BROKER, sim_conf,
                                      Q_Broker, Q_SimEventHandler)
    thread.start()
    threads.append(thread)
    print "* Create Thread - Sim Broker"

    thread = thread_sim_entity_IaaS(simgval.gBLOCK_IAAS, sim_conf, Q_IaaS,
                                    Q_SimEventHandler)
    thread.start()
    threads.append(thread)
    print "* Create Thread - Sim IaaS"

    # Simulation Start...
    print("* Start Simulation in 5 sec")
    for x in xrange(0, 5):
        sys.stdout.write('.')
        time.sleep(1)
    sys.stdout.write('\n')

    # ------------------------
    # EVENT MESSAGE
    # ------------------------
    # EVENT_ID   = EVENT UNIQUE ID
    # EVENT_TIME = EVENT_SIM_CLOCK or EVENT_TIME_OUT CLOCK
    # EVENT_SRC  = Event Message Sender
    # EVENT_DST  = Event Message Receiver
    # EVENT_TYPE = Event Type
    # EVENT_SUB_TYPE = Event_Sub_Type
    # EVENT_DATA = Event DaTa
    # ------------------------
    q_evt = clib.make_queue_event(0, simgval.gBLOCK_MAIN,
                                  simgval.gBLOCK_SIM_CLOCK,
                                  simgval.gEVT_SIM_START, None, None)
    Q_SimClock.put(q_evt)

    for t in threads:
        t.join()
    print "* Exiting Run_Simulation"
Exemple #13
0
def SEH_evt_clear_sd_tmr_event(q_msg):

    evt_id = q_msg[0]  # EVT_ID
    evt_src = q_msg[2]  # EVT_SRC
    evt_code = q_msg[4]  # EVT_CODE
    evt_real_src = q_msg[5]  # EVT_SUB_CODE
    evt_data = q_msg[6]  # EVT_DATA

    if evt_code != simgval.gEVT_REQ_CLEAR_SD_TMR_EVENT:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! => %s" %
                            (str(Global_Curr_Sim_Clock),
                             simgval.get_sim_code_str(evt_code), q_msg))
        clib.sim_exit()

    if evt_real_src != simgval.gBLOCK_BROKER:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! - Invalid REAL SRC Block (%s) => %s" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_real_src), q_msg))
        clib.sim_exit()

    vm_obj = evt_data[0]
    exception_flag = evt_data[1]

    if vm_obj.sd_policy_activated != True:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! - Invalid Access to Lib:SEH_evt_clear_sd_tmr_event => %s" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), q_msg))
        clib.logwrite_vm_obj(g_log_handler,
                             "[SimEvent] " + str(Global_Curr_Sim_Clock),
                             vm_obj)
        clib.sim_exit()

    index, te = get_index_Timer_Event_by_Infos(simgval.gBLOCK_BROKER,
                                               simgval.gEVT_SUB_VM_SCALE_DOWN,
                                               vm_obj.id)
    if index < 0 or te is None:

        # this case hardly happens but it exists -- no just warning instead of terminating simulator - 10/27/2014
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! - Proper Timer Event for VM (ID:%d) Scale Down not found!!!" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), vm_obj.id))

    else:

        # proper event exists

        te_blk = te[1][0]
        te_ec = te[1][1]
        te_data = te[1][2]

        if  te_blk      != simgval.gBLOCK_BROKER or \
            te_ec       != simgval.gEVT_SUB_VM_SCALE_DOWN or \
            te_data[0]  != vm_obj.id or \
            index       <  0:

            g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! - Timer Event (IDX:%d, EC:%s) for VM(ID:%d) Scale Down Mismatch!" \
                     % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code),
                        index, simgval.get_sim_code_str(te_ec),vm_obj.id))
            clib.sim_exit()

        remove_Timer_Event_by_Index(index)
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) - Remove Timer Event (IDX:%d, EC:%s) for VM(ID:%d) Scale Down" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), index, simgval.get_sim_code_str(te_ec),vm_obj.id))

        # send by pass to notify "request to clear sd event completed"
        seh_dst_block_id = simgval.gBLOCK_BROKER
        seh_evt_code = simgval.gEVT_SUCCESS_CLEAR_SD_TMR_EVENT
        seh_evt_id_data = [vm_obj, exception_flag]

        seh_evt = clib.make_queue_event(Global_Curr_Sim_Clock, g_my_block_id,
                                        seh_dst_block_id, seh_evt_code, None,
                                        seh_evt_id_data)
        ret = send_EVT_to_Block(seh_evt_code, seh_dst_block_id, seh_evt)

    # send ack
    SEH_send_evt_ack(evt_id)
Exemple #14
0
def SEH_evt_ask_simentity_termination(q_msg):

    evt_src = q_msg[2]  # EVT_SRC
    evt_code = q_msg[4]  # EVT_CODE
    baseline_block_id = simgval.gBLOCK_WORKLOAD_GEN

    if evt_code != simgval.gEVT_ASK_SIMENTITY_TERMINATION:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! => %s" %
                            (str(Global_Curr_Sim_Clock),
                             simgval.get_sim_code_str(evt_code), q_msg))
        clib.sim_exit()

    if evt_src == baseline_block_id:
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Error! - Invalid SRC Block (%s) => %s" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_src), q_msg))
        clib.sim_exit()

    print "[SimEvent] %s IN  Sentout_Timer_Event_IDs => %s" % (
        str(Global_Curr_Sim_Clock), str(Sentout_Timer_Event_IDs))

    term_cfm_evt_code = None
    # Workload Gen Sim Entity is Running
    if g_Sim_Entity_Running_States[baseline_block_id] is True:

        # cannot be terminated
        g_log_handler.error("[SimEvent] %s EVT_CODE (%s) Processing - %s CANNOT be terminated! - %s [%s] is running!" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_src), simgval.get_sim_code_str(baseline_block_id), str(g_Sim_Entity_Running_States[baseline_block_id])))

        # Send EVT_REJECT_SIMENTITY_TERMINATION to SRC BLOCK
        term_cfm_evt_code = simgval.gEVT_REJECT_SIMENTITY_TERMINATION

    # Workload Gen Block is not Running
    else:

        no_of_tmr_evts = get_number_of_imp_Timer_Events()
        if no_of_tmr_evts < 1:

            # termination confirm - no timer events and baseline block already terminated.

            # Send gEVT_CONFIRM_SIMENTITY_TERMINATION to SRC BLOCK
            g_log_handler.info("[SimEvent] %s EVT_CODE (%s) Processing - %s CAN be terminated! - %s [%s] is stopped and %d Timer Event(s) remain(s)!" \
                     % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_src), simgval.get_sim_code_str(baseline_block_id), str(g_Sim_Entity_Running_States[baseline_block_id]), no_of_tmr_evts))

            term_cfm_evt_code = simgval.gEVT_CONFIRM_SIMENTITY_TERMINATION
        else:

            # cannot be terminated --> timer events exits
            g_log_handler.info("[SimEvent] %s EVT_CODE (%s) Processing - %s CANNOT be terminated! - %d Timer Event(s) remain(s)" \
                 % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), simgval.get_sim_code_str(evt_src), no_of_tmr_evts))

            # Send EVT_REJECT_SIMENTITY_TERMINATION to SRC BLOCK
            term_cfm_evt_code = simgval.gEVT_REJECT_SIMENTITY_TERMINATION

    dst_block_id = evt_src
    term_cfm_evt = clib.make_queue_event(Global_Curr_Sim_Clock, g_my_block_id,
                                         dst_block_id, term_cfm_evt_code, None,
                                         None)
    r = send_EVT_to_Block(term_cfm_evt_code, dst_block_id, term_cfm_evt)
    if r is not True:
        g_log_handler.error("[SimEvent] %s Timer Event Send Out Error!!! - %s, %s" \
              % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(term_cfm_evt_code), term_cfm_evt))
        clib.sim_exit()

    print "[SimEvent] %s OUT Sentout_Timer_Event_IDs => %s" % (
        str(Global_Curr_Sim_Clock), str(Sentout_Timer_Event_IDs))
Exemple #15
0
def SEH_evt_set_clock_processing(q_msg):

    evt_clock = q_msg[1]  # EVT_CLOCK
    evt_code = q_msg[4]  # EVT_CODE
    evt_sub_code = q_msg[5]  # EVT_SUB_CODE : Timer Ticks

    return_vals = [False, None]

    if evt_code != simgval.gEVT_SET_CLOCK:
        g_log_handler.error("[SimEvent] %s SEH_evt_set_clock_processing EVT_CODE (%s) Error! => %s" \
              % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(evt_code), q_msg))
        clib.sim_exit()

    #print "EVT CODE:%s EVT_DATA:%d" % (evt_code, evt_data)
    if Global_Curr_Sim_Clock == evt_clock:
        return return_vals

    update_curr_sim_clock(evt_clock)
    print "[SimEvent] %s Update Sim Clock" % (str(Global_Curr_Sim_Clock))

    if Global_Curr_Sim_Clock > 0:
        ticks = evt_sub_code
        update_Timer_Events(-ticks)

    evt_indice = get_indice_timeout_Timer_Events()
    if len(evt_indice) > 0:

        print "[SimEvent] %s IN  Timer_Events=>" % str(
            Global_Curr_Sim_Clock), Timer_Events
        print "[SimEvent] %s IN  Sentout_Timer_Event_IDs=>" % str(
            Global_Curr_Sim_Clock), Sentout_Timer_Event_IDs
        print "[SimEvent] %s %d Timer_Event(s) need to send out" % (
            str(Global_Curr_Sim_Clock), len(evt_indice))

        no_q_out = 0
        for evt_index in evt_indice:
            so_evt = get_evt_timeout_Timer_Events(evt_index)
            if so_evt is not None:
                so_evt_timeout = so_evt[0]
                so_evt_data = so_evt[1]

                if so_evt_timeout > 0:
                    g_log_handler.error(
                        "[SimEvent] %s Timer is Malfunctioning!!! - timeout:%d"
                        % (str(Global_Curr_Sim_Clock), so_evt_timeout))
                    clib.sim_exit()
                else:
                    #[DEST_BLOCK, EVT_CODE, EVT_DATA[]]
                    #[simgval.gBLOCK_WORKLOAD_GEN, "EVT_WAKEUP", None]
                    dst_block_id = so_evt_data[0]
                    q_evt_so = clib.make_queue_event(
                        Global_Curr_Sim_Clock, g_my_block_id, dst_block_id,
                        simgval.gEVT_EXP_TIMER, so_evt_data[1], so_evt_data[2])

                    r = send_EVT_to_Block(simgval.gEVT_EXP_TIMER, dst_block_id,
                                          q_evt_so)
                    if r is True:
                        no_q_out += 1
                        # q_evt_id = q_evt_so[0]
                        # insert_Sentout_Timer_Event_IDs (q_evt_id) --> merged with send_EVT_to_Block 08072014
                    else:
                        g_log_handler.error("[SimEvent] %s Timer Event Send Out Error!!! - Invalid Dest Block %s" \
                              % (str(Global_Curr_Sim_Clock), simgval.get_sim_code_str(so_evt_data[0])))
                        clib.sim_exit()

            else:
                print "[SimEvent] %s No Item in Timer_Event[%d]" % (
                    str(Global_Curr_Sim_Clock), evt_index)

        no_deleted_evts = remove_Timer_Event(len(evt_indice))
        print "[SimEvent] %s %d Timer_Event(s) actually sent out" % (
            str(Global_Curr_Sim_Clock), no_q_out)
        print "[SimEvent] %s %d Timer_Event(s) are removed from Timer_Events" % (
            str(Global_Curr_Sim_Clock), no_deleted_evts)
        print "[SimEvent] %s OUT Timer_Events=>" % str(
            Global_Curr_Sim_Clock), Timer_Events
        print "[SimEvent] %s OUT Sentout_Timer_Event_IDs=>" % str(
            Global_Curr_Sim_Clock), Sentout_Timer_Event_IDs

    else:
        print "[SimEvent] %s Current Timer_Events => %s" % (
            str(Global_Curr_Sim_Clock), str(Timer_Events))
        print "[SimEvent] %s No Timer Event for this time clock => Activate Sim_Clock" % (
            str(Global_Curr_Sim_Clock))

        ticks = get_first_tick_Timer_Event()
        return_vals = [True, ticks]

    return return_vals