예제 #1
0
파일: break.c 프로젝트: 3112517927/otp
static void
process_killer(void)
{
    int i, j, max = erts_ptab_max(&erts_proc);
    Process* rp;

    erts_printf("\n\nProcess Information\n\n");
    erts_printf("--------------------------------------------------\n");
    for (i = max-1; i >= 0; i--) {
	rp = erts_pix2proc(i);
	if (rp && rp->i != ENULL) {
	    int br;
	    print_process_info(ERTS_PRINT_STDOUT, NULL, rp);
	    erts_printf("(k)ill (n)ext (r)eturn:\n");
	    while(1) {
		if ((j = sys_get_key(0)) <= 0)
		    erts_exit(0, "");
		switch(j) {
		case 'k': {
		    ErtsProcLocks rp_locks = ERTS_PROC_LOCKS_XSIG_SEND;
		    erts_aint32_t state;
		    erts_proc_inc_refc(rp);
		    erts_smp_proc_lock(rp, rp_locks);
		    state = erts_smp_atomic32_read_acqb(&rp->state);
		    if (state & (ERTS_PSFLG_FREE
				 | ERTS_PSFLG_EXITING
				 | ERTS_PSFLG_ACTIVE
				 | ERTS_PSFLG_ACTIVE_SYS
				 | ERTS_PSFLG_IN_RUNQ
				 | ERTS_PSFLG_RUNNING
				 | ERTS_PSFLG_RUNNING_SYS
				 | ERTS_PSFLG_DIRTY_RUNNING
				 | ERTS_PSFLG_DIRTY_RUNNING_SYS)) {
			erts_printf("Can only kill WAITING processes this way\n");
		    }
		    else {
			(void) erts_send_exit_signal(NULL,
						     NIL,
						     rp,
						     &rp_locks,
						     am_kill,
						     NIL,
						     NULL,
						     0);
		    }
		    erts_smp_proc_unlock(rp, rp_locks);
		    erts_proc_dec_refc(rp);
		}
		case 'n': br = 1; break;
		case 'r': return;
		default: return;
		}
		if (br == 1) break;
	    }
	}
    }
}
예제 #2
0
void __cdecl 
do_keep_window(void)
{
    printf("\nPress any key to close window.\n");
#ifdef LOAD_BEAM_DYNAMICALLY
    (*sys_get_key_p)(0);
#else 
    sys_get_key(0);
#endif 
}
예제 #3
0
파일: menu.c 프로젝트: korytov/bone
void sys_debounce_key(void)
{
    sys_key_second = sys_key_first;
    sys_key_first = sys_get_key();

    if ( sys_key_second == sys_key_first )
        sys_key_code = sys_key_first;
    else
        sys_key_code = KEY_NONE;
}
예제 #4
0
파일: adv_key.c 프로젝트: arsane/mp4sdk
//菜单读键
//返回键值,特点是持续按下按键会自动连发
u32 menu_get_key()
{
	u32 key;
	while( 1 )
	{
		key = sys_get_key();
		if( key )
		{
			sys_delay(200);
			return key;
		}
		sys_delay(10);
	}
}
예제 #5
0
파일: break.c 프로젝트: easemob/otp
void
do_break(void)
{
    int i;
#ifdef __WIN32__
    char *mode; /* enough for storing "window" */

    /* check if we're in console mode and, if so,
       halt immediately if break is called */
    mode = erts_read_env("ERL_CONSOLE_MODE");
    if (mode && strcmp(mode, "window") != 0)
	erl_exit(0, "");
    erts_free_read_env(mode);
#endif /* __WIN32__ */

    erts_printf("\n"
		"BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded\n"
		"       (v)ersion (k)ill (D)b-tables (d)istribution\n");

    while (1) {
	if ((i = sys_get_key(0)) <= 0)
	    erl_exit(0, "");
	switch (i) {
	case 'q':
	case 'a': 
	case '*': /* 
		   * The asterisk is an read error on windows, 
		   * where sys_get_key isn't that great in console mode.
		   * The usual reason for a read error is Ctrl-C. Treat this as
		   * 'a' to avoid infinite loop.
		   */
	    erl_exit(0, "");
	case 'A':		/* Halt generating crash dump */
	    erl_exit(1, "Crash dump requested by user");
	case 'c':
	    return;
	case 'p':
	    process_info(ERTS_PRINT_STDOUT, NULL);
	    return;
	case 'm':
	    return;
	case 'o':
	    port_info(ERTS_PRINT_STDOUT, NULL);
	    return;
	case 'i':
	    info(ERTS_PRINT_STDOUT, NULL);
	    return;
	case 'l':
	    loaded(ERTS_PRINT_STDOUT, NULL);
	    return;
	case 'v':
	    erts_printf("Erlang (%s) emulator version "
		       ERLANG_VERSION "\n",
		       EMULATOR);
	    erts_printf("Compiled on " ERLANG_COMPILE_DATE "\n");
	    return;
	case 'd':
	    distribution_info(ERTS_PRINT_STDOUT, NULL);
	    return;
	case 'D':
	    db_info(ERTS_PRINT_STDOUT, NULL, 1);
	    return; 
	case 'k':
	    process_killer();
	    return;
#ifdef OPPROF
	case 'X':
	    dump_frequencies();
	    return;
	case 'x':
	    {
		int i;
		for (i = 0; i <= HIGHEST_OP; i++) {
		    if (opc[i].name != NULL) {
			erts_printf("%-16s %8d\n", opc[i].name, opc[i].count);
		    }
		}
	    }
	    return;
	case 'z':
	    {
		int i;
		for (i = 0; i <= HIGHEST_OP; i++)
		    opc[i].count = 0;
	    }
	    return;
#endif
#ifdef DEBUG
	case 't':
	    erts_p_slpq();
	    return;
	case 'b':
	    bin_check();
	    return;
	case 'C':
	    abort();
#endif
	case '\n':
	    continue;
	default:
	    erts_printf("Eh?\n\n");
	}
    }

}
예제 #6
0
void main()
{
	byte i,x,y, d;
	byte *ptr;
	byte *src;
	unsigned int ct;

	vdp_set_mode(vdp_grp2);
	vdp_set_color(vdp_white, vdp_black);
	vdp_clear_grp1(0);
	sys_irq_init();


	/*
	 * load a tile set and generate a tile map manually
	 */

	INIT_TILE_SET(logo, retro_logo);
	tile_set_to_vram(&logo, 0);

	i = 0;
	for (y=0; y < retro_logo_tile_h; y++)
		for (x=0; x < retro_logo_tile_w; x++)
			vdp_poke(vdp_base_names_grp1 + 11 + 9 * 32 + x + y * 32, i++);

	do {
	} while (sys_get_key(8) & 1);
 
	/*
	 * load a pre-processed tile map
	 */

	INIT_TILE_SET(kv, tiles2);
	// need an offset of one
	tile_set_to_vram(&kv, 1);

	// inflate map into a buffer, at once
 	map_inflate(map_cmpr_dict, map, map_buf, 2000, map_w);

	x =0; y =0;
    do {
    	d = sys_get_stick(0);
    	if (d == 1 && y > 0)
    		y--;
    	if (d == 5 && y < (map_h - 26))
    		y++; 
    	if (d == 3 && x < map_w - 32)
    		x++;
    	if (d == 7 && x > 0)
    		x--;

		ptr = fb;
		src = map_buf + x + y * map_w;
		for (i = 0; i <= 23; i++) {
			sys_memcpy(ptr, src, 32);
			ptr += gfx_screen_tile_w;
			src += map_w;
		}

		//map_inflate_screen(map_cmpr_dict, map, fb, map_w, x, y);
		vdp_fastcopy_nametable(fb);

	} while(1); 
}
예제 #7
0
파일: adv_key.c 프로젝트: arsane/mp4sdk
//等待按键清空
void menu_clear_key()
{
	while( sys_get_key() )
		sys_delay(10);
}