// Called with the queue locked and with at least one element
CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
#if INCLUDE_JVMCI
  CompileTask *max_non_jvmci_task = NULL;
#endif
  CompileTask *max_task = NULL;
  Method* max_method = NULL;
  jlong t = os::javaTimeMillis();
  // Iterate through the queue and find a method with a maximum rate.
  for (CompileTask* task = compile_queue->first(); task != NULL;) {
    CompileTask* next_task = task->next();
    Method* method = task->method();
    update_rate(t, method);
    if (max_task == NULL) {
      max_task = task;
      max_method = method;
    } else {
      // If a method has been stale for some time, remove it from the queue.
      if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
        if (PrintTieredEvents) {
          print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
        }
        task->log_task_dequeued("stale");
        compile_queue->remove_and_mark_stale(task);
        method->clear_queued_for_compilation();
        task = next_task;
        continue;
      }

      // Select a method with a higher rate
      if (compare_methods(method, max_method)) {
        max_task = task;
        max_method = method;
      }
    }
    task = next_task;
  }

#if INCLUDE_JVMCI
  if (UseJVMCICompiler) {
    if (max_non_jvmci_task != NULL) {
      max_task = max_non_jvmci_task;
      max_method = max_task->method();
    }
  }
#endif

  if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
      && is_method_profiled(max_method)) {
    max_task->set_comp_level(CompLevel_limited_profile);
    if (PrintTieredEvents) {
      print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
    }
  }

  return max_task;
}
void set_event(uint8_t event_number)
{
	uint8_t which_pin = events[event_number].pin;
	
	actual_events[which_pin] = event_number;
	
	switch(which_pin)
	{
		case EXP0_PC2:
		case EXP1_PD4:
		case EXP2_PD7:
		case EXP3_PB0:
		set_pin(which_pin, events[event_number].pin_state);
		break;
		
		case PWM0_PD6:
		case PWM1_PD5:
		// not implemented yet case PWM2_PB1:
		// not implemented yet case PWM3_PD3:
		run_pwm(which_pin, &events[event_number]);
		break;
		
		default:break;
	}
	
	int32_t time = current_time();
	
	// event_time
	char formatted_date[30];
	timeToString(time, formatted_date);
	send_string(formatted_date);
	send_string(" ");
	
	print_event(event_number);
}
Exemple #3
0
event_response_t mm_callback(vmi_instance_t vmi, vmi_event_t *event) {

    vmi_get_vcpureg(vmi, &cr3, CR3, 0);
    vmi_pid_t current_pid = vmi_dtb_to_pid(vmi, cr3);

    reg_t rip_test;
    vmi_get_vcpureg(vmi, &rip_test, RIP, 0);

    printf("Memevent: {\n\tPID %u. RIP 0x%lx:\n", current_pid, rip_test);

    print_event(event);

    if( current_pid == pid && event->mem_event.gla == rip) {
        printf("\tCought the original RIP executing again!");
        vmi_clear_event(vmi, event, NULL);
        interrupted = 1;
    } else {
        printf("\tEvent on same page, but not the same RIP");
        vmi_clear_event(vmi, event, NULL);

        /* These two calls are equivalent */
        //vmi_step_event(vmi, event, event->vcpu_id, 1, NULL);
        vmi_step_event(vmi, event, event->vcpu_id, 1, step_callback);
    }

    printf("\n}\n");
    return 0;
}
Exemple #4
0
static void* get_event(void *unused)
{
	SaHpiEventT	event;
	SaErrorT	rv;        
	
	
	rv = saHpiSubscribe(sessionid, SAHPI_FALSE);
	if (rv != SA_OK) {
		printf("OpenHPI>Fail to Subscribe event\n");
		return (void *)0;
	}	
		
	for(;;){
		memset(&event, 0xF, sizeof(event));

		rv = saHpiEventGet(sessionid, SAHPI_TIMEOUT_BLOCK, &event, NULL, NULL);		
		if (rv != SA_OK ) {
			goto out;
		}
		
		if ( prt_flag == 1 ) 
			print_event(sessionid,&event);
	} /*the loop for retrieving event*/

out:
	printf( "Unsubscribe\n");
	rv = saHpiUnsubscribe( sessionid );

	return (void *)1;
}
Exemple #5
0
/*
 * print out the whole event LIST
 */
void print_el()
{
	struct el *el;
	struct es *es_hd;
	struct es *es;

	assert (g_el->next);

	printf("\n\n");
	printf("[es] >>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<\n");
	printf("[es] >>>>>>>>>> Dumping all event sets  <<<<<<<<<<<<<\n");
	printf("[es] >>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<\n");

	for (el = g_el->next ; el != g_el ; el = el->next) {

		assert(el);
		es_hd = el->es_head;
		assert (es_hd);
	
		printf("\n[es] ***** Dumping next event set *****\n");

		for (es=es_hd->next ; es!=es_hd ; es=es->next)
			print_event(es);
	}     
}
Exemple #6
0
/*
 * \brief Application task to start peer search
 *
 * \param arg arguments to start the peer search
 */
void peer_search_initiator_init(void *arg)
{
    /* Change LED pattern */
    app_led_event(LED_EVENT_START_PEER_SEARCH);

    /* Print the message if it is Range measurement mode */
    if (PEER_SEARCH_RANGE_TX == node_info.main_state)
    {
        print_event(PRINT_PEER_SEARCH_INITATED);
    }
    /* Peer search process seq number */
    seq_num = rand();

    /* assign a random address */
    do
    {
        node_info.peer_short_addr = (uint16_t)rand();
        /* Make sure random number is not zero */
    }
    while (!node_info.peer_short_addr);

    /* Reduce the TX power level to minium,if configuration mode is enabled */
    if (true == node_info.configure_mode)
    {
        /* set the tx power to lowest in configuration mode */
        uint8_t config_tx_pwr = CONFIG_MODE_TX_PWR;
        tal_pib_set(phyTransmitPower, (pib_value_t *)&config_tx_pwr);
    }

    /* Keep compiler happy */
    arg = arg;
}
Exemple #7
0
//callback function
void mm_callback(vmi_instance_t vmi, vmi_event_t *event) {

    print_event(event);
    vmi_get_vcpureg(vmi,&rax,RAX,0);
    vmi_get_vcpureg(vmi,&rbx,RBX,0);
    vmi_get_vcpureg(vmi,&rcx,RCX,0);
    vmi_get_vcpureg(vmi,&rdx,RDX,0);
    vmi_get_vcpureg(vmi,&rsi,RSI,0);
    vmi_get_vcpureg(vmi,&rdi,RDI,0);
    printf("HYPERCALL is: %s\n RAX value is: %lx\n RBX value is: %lx\n RCX value is: %lx\n RDX value is: %lx\n RSI value is: %lx\n RDI value is: %lx\n",
	event->mem_event.hypercall,rax,rbx,rcx,rdx,rsi,rdi);

    if(event->mem_event.gla == event->mem_event.gla2) {
        printf("\tCought the original hypercall executing again!");
        vmi_clear_event(vmi, event);
        interrupted = 1;
    } else {
        printf("\tEvent on same page, but not the hypercall: %s",event->mem_event.hypercall);
        vmi_clear_event(vmi, event);

        /* These two calls are equivalent */
        //vmi_step_event(vmi, event, event->vcpu_id, 1, NULL);
        vmi_step_event(vmi, event, event->vcpu_id, 1, NULL);
    }

    printf("\n}\n");
}
Exemple #8
0
nmethod* SimpleThresholdPolicy::event(const methodHandle& method, const methodHandle& inlinee,
                                      int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) {
  if (comp_level == CompLevel_none &&
      JvmtiExport::can_post_interpreter_events() &&
      thread->is_interp_only_mode()) {
    return NULL;
  }
  if (CompileTheWorld || ReplayCompiles) {
    // Don't trigger other compiles in testing mode
    return NULL;
  }

  handle_counter_overflow(method());
  if (method() != inlinee()) {
    handle_counter_overflow(inlinee());
  }

  if (PrintTieredEvents) {
    print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
  }

  if (bci == InvocationEntryBci) {
    method_invocation_event(method, inlinee, comp_level, nm, thread);
  } else {
    // method == inlinee if the event originated in the main method
    method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
    // Check if event led to a higher level OSR compilation
    nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false);
    if (osr_nm != NULL && osr_nm->comp_level() > comp_level) {
      // Perform OSR with new nmethod
      return osr_nm;
    }
  }
  return NULL;
}
static void
print_variable(Variable *var)
{
    GList *itr;

    printf("= Variable: %s =\n", var->name);

    printf("struct sml_object Variable: %p\n", var->sml_var);
    printf("Range %f - %f\n", var->min, var->max);
    printf("Current value: %f\n", var->cur_value);
    printf("Guess value: %f\n", var->guess_value);
    printf("Last event: %p\n", var->last_event);

    printf("Terms:\n");
    for (itr = var->terms; itr; itr = itr->next) {
        print_term(itr->data);
    }

    printf("Events:\n");
    for (itr = var->events; itr; itr = itr->next)
        print_event(itr->data);

    printf("Status Events:\n");
    for (itr = var->status_events; itr; itr = itr->next)
        print_status_event(itr->data);

    printf("====================\n");
}
// Check if the method can be compiled, change level if necessary
void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
  assert(level <= TieredStopAtLevel, "Invalid compilation level");
  if (level == CompLevel_none) {
    return;
  }
  // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
  // in the interpreter and then compile with C2 (the transition function will request that,
  // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
  // pure C1.
  if (!can_be_compiled(mh, level)) {
    if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
        compile(mh, bci, CompLevel_simple, thread);
    }
    return;
  }
  if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
    return;
  }
  if (!CompileBroker::compilation_is_in_queue(mh)) {
    if (PrintTieredEvents) {
      print_event(COMPILE, mh, mh, bci, level);
    }
    submit_compile(mh, bci, level, thread);
  }
}
Exemple #11
0
static leaf_error_t leaf_run()
{
	xcb_generic_event_t *event = NULL;
	int etype;
	leaf_error_t status = ERR_NONE;

	/* Start main loop */
	gconf.running = true;
	do {
		event = xcb_poll_for_event(gconf.conn);
		if (!event) {
            if (xcb_connection_has_error(gconf.conn))
	            return ERR_CONN;
			continue;
		}
		etype = XCB_EVENT_RESPONSE_TYPE(event);

		/* Only for debug prupose */
		print_event(etype);

		/* Execute specific event handler */
		if (geventhandlers[etype])
			if (geventhandlers[etype](event) != EVENT_ERR_NONE)
				status = ERR_EVENT;
		free(event);
	} while (gconf.running && status == ERR_NONE);

	return status;
}
/**
 * \brief Timer handler for supporting peer search
 *
 * \param parameter pass parameters to timer handler
 */
static void app_peer_conf_tmr_handler_cb( void *parameter)
{
	trx_id_t trx = (trx_id_t)parameter;
	print_event(trx, PRINT_PEER_SEARCH_FAILED);
	/* No PEER CONF so change to WAIT_FOR_EVENT state*/
	set_main_state(trx, WAIT_FOR_EVENT, 0);
}
Exemple #13
0
void handle_event(int epfd, struct epoll_event ev) {
	struct fdinfo *fdinfo = ev.data.ptr;

	switch (fdinfo->type) {
	case LSOCK:
		accept_one(epfd, fdinfo->fd);
		break;
	case CLIENT:
		print_event(fdinfo->fd, ev);
		if (ev.events & EPOLLHUP) {
			kill_cli(epfd, fdinfo);
			return;
		}

		if (ev.events & EPOLLIN) {
			handle_cli(fdinfo);
		}

		if (ev.events & EPOLLRDHUP)  {
			handle_cli(fdinfo);
			kill_cli(epfd, fdinfo);
			return;
		}

		break;
	}
}
Exemple #14
0
/**
 * \brief Peer rsp received state init function
 *
 * \arg argument to be used in init function
 */
static void peer_rsp_rcvd_init(void *arg)
{
    /* Set the newly assigned address */
    tal_pib_set(macShortAddress, (pib_value_t *)arg);

    if (send_peer_conf())
    {
        /* Print messge if the Peer search failed in Range mode  */
        if (PEER_SEARCH_RANGE_TX == node_info.main_state)
        {
            print_event(PRINT_PEER_SEARCH_FAILED);
        }
        else if (PEER_SEARCH_PER_TX == node_info.main_state)
        {
            /* Send the confirmation to the PC application via Serial interface */
            usr_perf_start_confirm(NO_PEER_FOUND,
                                   START_MODE_PER,
                                   NULL,
                                   NUL_VAL,
                                   NULL,
                                   NULL,
                                   NULL,
                                   NUL_VAL);
        }
        /* PEER CONF send failed - so change to WAIT_FOR_EVENT state*/
        set_main_state(WAIT_FOR_EVENT, NULL);
    }
}
Exemple #15
0
static void
check_event(FAMConnection * fc)
{
    int ret;
    FAMEvent fe;

    ret = FAMPending(fc);
    if (ret < 0) {
        fprintf(stderr, "FAMPending() failed\n");
        exit(1);
    }
    while (ret > 0) {
        ret = FAMNextEvent(fc, &fe);
        if (ret < 0) {
            fprintf(stderr, "FAMNextEvent() failed\n");
            exit(1);
        }
        print_event(&fe);
        ret = FAMPending(fc);
        if (ret < 0) {
            fprintf(stderr, "FAMPending() failed\n");
            exit(1);
        }
    }
}
Exemple #16
0
void print_event_to_log(Display* dpy, XEvent* ev)
{
#ifdef DEBUG_PRINTOUTS
  if ((ev->type != PropertyNotify) && (ev->type != ConfigureNotify)) {
    print_event(g_out_stream, ev, dpy);
  }
#endif
}
Exemple #17
0
/* Print all events */
void print_events(void)
{
	list_node_t *it;
	for (it = events->head; it; it = it->next) {
		struct event *event = it->data;
		if (event)
			print_event(event);
	}
}
/**
 * \brief Timer handler for supporting peer search
 *
 * \param parameter pass parameters to timer handler
 */
static void app_peer_conf_tmr_handler_cb(void *parameter)
{
	print_event(PRINT_PEER_SEARCH_FAILED);
	/* No PEER CONF so change to WAIT_FOR_EVENT state*/
	set_main_state(WAIT_FOR_EVENT, 0);

	/* keep compiler happy */
	parameter = parameter;
}
Exemple #19
0
// Called with the queue locked and with at least one element
CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
  CompileTask *max_task = NULL;
  methodOop max_method;
  jlong t = os::javaTimeMillis();
  // Iterate through the queue and find a method with a maximum rate.
  for (CompileTask* task = compile_queue->first(); task != NULL;) {
    CompileTask* next_task = task->next();
    methodOop method = (methodOop)JNIHandles::resolve(task->method_handle());
    methodDataOop mdo = method->method_data();
    update_rate(t, method);
    if (max_task == NULL) {
      max_task = task;
      max_method = method;
    } else {
      // If a method has been stale for some time, remove it from the queue.
      if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
        if (PrintTieredEvents) {
          print_event(KILL, method, method, task->osr_bci(), (CompLevel)task->comp_level());
        }
        CompileTaskWrapper ctw(task); // Frees the task
        compile_queue->remove(task);
        method->clear_queued_for_compilation();
        task = next_task;
        continue;
      }

      // Select a method with a higher rate
      if (compare_methods(method, max_method)) {
        max_task = task;
        max_method = method;
      }
    }
    task = next_task;
  }

  if (max_task->comp_level() == CompLevel_full_profile && is_method_profiled(max_method)) {
    max_task->set_comp_level(CompLevel_limited_profile);
    if (PrintTieredEvents) {
      print_event(UPDATE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
    }
  }

  return max_task;
}
/**
 * \brief Application task handling peer search
 *
 * This function
 * - Implements the peer search state machine.
 */
static void peer_rsp_send_init(void *arg)
{
	peer_search_receptor_arg_t *arg_ptr = (peer_search_receptor_arg_t *)arg;

	if (send_peer_rsp(&(arg_ptr->peer_ieee_addr))) {
		print_event(PRINT_PEER_SEARCH_FAILED);
		/* PEER RSP send failed - so change to WAIT_FOR_EVENT state*/
		set_main_state(WAIT_FOR_EVENT, 0);
	}
}
Exemple #21
0
static void test_handler(void *_w, struct inotify_event *event)
{
    struct iv_inotify_watch *w = _w;

    printf("%s", w->pathname);
    if (event->len != 0)
        printf("/%s", event->name);
    printf(":");
    print_event(event->mask);
    printf("\n");
}
Exemple #22
0
void syscall_compat_cb(vmi_instance_t vmi, vmi_event_t *event){
    reg_t rdi, rax;
    vmi_get_vcpureg(vmi, &rax, RAX, event->vcpu_id);
    vmi_get_vcpureg(vmi, &rdi, RDI, event->vcpu_id);

    printf("Syscall happened: RAX(syscall#)=%u RDI(1st argument)=%u\n", (unsigned int)rax, (unsigned int)rdi);

    print_event(*event);

    vmi_clear_event(vmi, &msr_syscall_compat_event);
}
static void
print_expectation(Expectation *expec)
{
    GList *itr;

    printf("= Expectation: %s for %p =\n", expec->name, expec->output);
    printf("Last event: %p\n", expec->last_event);
    printf("Events:\n");
    for (itr = expec->events; itr; itr = itr->next)
        print_event(itr->data);
    printf("====================\n");
}
Exemple #24
0
event_response_t msr_syscall_sysenter_cb(vmi_instance_t vmi, vmi_event_t *event){
    reg_t rdi, rax;
    vmi_get_vcpureg(vmi, &rax, RAX, event->vcpu_id);
    vmi_get_vcpureg(vmi, &rdi, RDI, event->vcpu_id);

    printf("Syscall happened: RAX(syscall#)=%u RDI(1st argument)=%u\n", (unsigned int)rax, (unsigned int)rdi);

    print_event(*event);

    vmi_clear_event(vmi, &msr_syscall_sysenter_event, NULL);
    return 0;
}
/**
 * \brief Callback that is called once tx is done in wait for peer search conf
 * state.
 *
 * \param status    Status of the transmission procedure
 * \param frame     Pointer to the transmitted frame structure
 */
static void wait_for_conf_rx_cb(frame_info_t *mac_frame_info)
{
	app_payload_t *msg;

	if (*(mac_frame_info->mpdu) == (FRAME_OVERHEAD
			+ ((sizeof(app_payload_t)
			- sizeof(general_pkt_t))
			+ sizeof(peer_conf_t)))) {
		/* Point to the message : 1 =>size is first byte and 2=>FCS*/
		msg
			= (app_payload_t *)(mac_frame_info->mpdu + 1 +
				FRAME_OVERHEAD - 2);
		if ((msg->cmd_id) == PEER_CONFIRM) {
			if (node_info.peer_short_addr ==
					(msg->payload.peer_conf_data.nwk_addr))
			{
				print_event(PRINT_PEER_SEARCH_SUCCESS);
				app_led_event(LED_EVENT_PEER_SEARCH_DONE);
				switch (node_info.main_state) {
				case PEER_SEARCH_RANGE_RX:

					/* Peer success - set the board to
					 * RANGE_TEST_TX_OFF state */
					set_main_state(RANGE_TEST_TX_OFF, 0);
					break;

				case PEER_SEARCH_PER_RX:

					/* Peer success - set the board to
					 * RANGE_TEST_TX_OFF state */
					set_main_state(PER_TEST_RECEPTOR, 0);
					break;

				/* To keep the GCC compiler happy */
				case INIT:
				case WAIT_FOR_EVENT:
				case PEER_SEARCH_RANGE_TX:
				case PEER_SEARCH_PER_TX:
				case RANGE_TEST_TX_ON:
				case RANGE_TEST_TX_OFF:
				case SINGLE_NODE_TESTS:
				case PER_TEST_INITIATOR:
				case PER_TEST_RECEPTOR:
				case NUM_MAIN_STATES:
					break;

				default: /* Do nothing */
					break;
				}
			}
		}
	}
}
Exemple #26
0
void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
  for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) {
    if (PrintTieredEvents) {
      methodHandle mh(sd->method());
      print_event(REPROFILE, mh, mh, InvocationEntryBci, CompLevel_none);
    }
    MethodData* mdo = sd->method()->method_data();
    if (mdo != NULL) {
      mdo->reset_start_counters();
    }
    if (sd->is_top()) break;
  }
}
/**
 * \brief Callback that is called once tx is done in PEER_RSP_SEND state.
 *
 * \param status    Status of the transmission procedure
 * \param frame     Pointer to the transmitted frame structure
 */
static void peer_rsp_send_tx_done_cb(retval_t status, frame_info_t *frame)
{
	if (status == MAC_SUCCESS) {
		peer_search_receptor_set_sub_state(WAIT_FOR_PEER_CONF, 0);
	} else {
		print_event(PRINT_PEER_SEARCH_FAILED);
		/* No PEER RSP send failed so change to WAIT_FOR_EVENT state*/
		set_main_state(WAIT_FOR_EVENT, 0);
	}

	/* Keep compiler happy */
	frame = frame;
}
Exemple #28
0
/*
 * \brief Application task handling user events like key press or
 * character on UART
 *
 * This function
 * - Implements the event handling in WAIT_FOR_EVENT state.
 */
void wait_for_event_task(void)
{
    uint8_t key_press;

    /* Check for any key press */
    key_press = app_debounce_button();

    if (key_press != 0)
    {
        print_event(PRINT_KEY_PRESS_PEER_SEARCH_INITIATOR);
        /* key press detected - so change to state PEER_SEARCH_RANGE_TX */
        set_main_state(PEER_SEARCH_RANGE_TX, NULL);
    }
}
Exemple #29
0
void print_events()
{
	char ts[30];
	
	send_string("Number of events: ");
	sprintf(ts, "%d", events_count);
	send_string(ts);
	send_enter();
	
	for (uint8_t i = 0; i < events_count; i++)
	{
		print_event(i);
	}
	
}
Exemple #30
0
/*
 * \brief Initialization of Range Measurement mode in RANGE_TX_ON State
 *
 * \param arg arguments to init RANGE_TX_ON state
 */
void range_test_tx_on_init(void *arg)
{
    print_event(PRINT_RANGE_MEASURE_TX_START);

    /* Peer process seq number */
    seq_num = rand();

    sw_timer_start(APP_TIMER_TO_TX,
                    APP_SEND_TEST_PKT_INTERVAL_IN_MICRO_SEC,
                    SW_TIMEOUT_RELATIVE,
                    (FUNC_PTR)range_test_tx_timer_handler_cb,
                    NULL);

    /* Keep compiler happy */
    arg = arg;
}