Esempio n. 1
0
int
ts_main(int argc, char *argv[])
{
	unsigned i, ntasks, n, skip;
	TaskInfo_t *ti, *info;
	bool enabled[NVCONS];
	bool check_cons = false;				// por defecto habilitar todas las consolas
	bool cursor = mt_cons_cursor(false);

	memset(enabled, 0, sizeof enabled);
	for ( i = 1 ; i < argc ; i++ )			// habilitar las consolas especificadas
	{
		unsigned cons = atoi(argv[i]);
		if ( cons < NVCONS )
			enabled[cons] = check_cons = true;
	}

	mt_cons_clear();
	cprintk(WHITE, BLUE, "%s", title);
	mt_cons_gotoxy(0, 24);
	cprintk(WHITE, BLUE, "%s", foot);
	skip = 0;
	do
	{
		info = GetTasks(&ntasks);
		for ( n = 0, i = 1, ti = info ; i < 24 && ntasks-- ; ti++ )
		{
			if ( (check_cons && !enabled[ti->consnum]) || n++ < skip )
				continue;
			mt_cons_gotoxy(0, i++);
			char namebuf[20];
			sprintf(namebuf, ti->protected ? "[%.16s]" : "%.18s", name(ti->task));
			cprintk(WHITE, BLACK, "%8x %-18s %u %10u %-9s %-18.18s", ti->task, namebuf, 
				ti->consnum, ti->priority, statename(ti->state), name(ti->waiting));
			if ( ti->is_timeout )
				cprintk(WHITE, BLACK, " %10u", ti->timeout);
			else
				mt_cons_clreol();
		}
		while ( i < 24 )
		{
			mt_cons_gotoxy(0, i++);
			mt_cons_clreol();
		}
		Free(info);
	}
	while ( getuser(&skip) );
	mt_cons_clear();
	mt_cons_cursor(cursor);	
	return 0;
}
Esempio n. 2
0
int
camino_ns_main(int argc, char **argv)
{
	bool cursor;
	unsigned c;

	ncars = 0;
	pass_max = argc > 1 ? atoi(argv[1]): PASS_MAX;

	mt_cons_clear();
	cursor = mt_cons_cursor(false);

	init_road();

	Ready(ctl = CreateTask(control, 0, NULL, "control", DEFAULT_PRIO));

	mprint(OFFSET, MSGLINE,		"I: auto hacia la izquierda");
	mprint(OFFSET, MSGLINE+1,	"D: auto hacia la derecha");
	mprint(OFFSET, MSGLINE+2,	"S: salir");

	do
		switch ( c = mgetch() )
		{
			case 'I':
			case 'i':
				send_car(LEFTBOUND);
				break;
			case 'D':
			case 'd':
				send_car(RIGHTBOUND);
				break;
			default:
				break;
		}
	while ( c != 's' && c != 'S' ); 

	mprint(OFFSET, MSGLINE + 3, "Esperando que terminen los autos...");
	while ( ncars )
		Yield();

	DeleteTask(ctl);

	mt_cons_clear();
	mt_cons_cursor(cursor);

	return 0;
}