Exemplo n.º 1
0
void sleep_test(){
	if(system_env_fork()){
		printg("aaaaa\n");
		system_env_sleep(100);
		printg("bbbbbbb\n");
	}
	while(1);
	system_env_exit();
	printg("ccccccc");
}
Exemplo n.º 2
0
void init_game(){
	//init_idt();
	//init_intr();
	//system_init_serial();
	//system_init_timer();
	printg("aaaa\n");
	printg("bbbb\n");
	syscall(0,timer_event);
	syscall(1,keyboard_event);
	//while(1);
	//printg("game start!\n");

}
Exemplo n.º 3
0
	/** Hardens the Pending Checkpoint on the Blockchain, determined by a new block creating a new Timespan.
		The blockchain from genesis to new hardened checkpoint will then be fixed into place. **/
	bool HardenCheckpoint(CBlockIndex* pcheckpoint, bool fInit)
	{
			
		/** Only Harden New Checkpoint if it Fits new Timestamp. **/
		if(!IsNewTimespan(pcheckpoint->pprev))
			return false;

		
		/** Only Harden a New Checkpoint if it isn't already hardened. **/
		if(mapCheckpoints.count(pcheckpoint->pprev->PendingCheckpoint.first))
			return true;


		/** Update the Checkpoints into Memory. **/
		mapCheckpoints[pcheckpoint->pprev->PendingCheckpoint.first] = pcheckpoint->pprev->PendingCheckpoint.second;
		

		/** Dump the Checkpoint if not Initializing. **/
		if(!fInit)
			printg("===== Hardened Checkpoint %s Height = %u\n", 
			pcheckpoint->pprev->PendingCheckpoint.second.ToString().substr(0, 20).c_str(),
			pcheckpoint->pprev->PendingCheckpoint.first);
		
		return true;
	}
Exemplo n.º 4
0
Arquivo: stg1.c Projeto: acalvoa/SNAKE
void select_diff(){
	clear_screen();
	set_border();
	setcursor(8,5,1);
	printg("SNAKE: SELECT DIFFICULT",0,_C_YELLOW);
	draw_game_line(23,25,133,25,_C_YELLOW,1);
	setcursor(8,8,1);
	printg("1.- Easy",0,_C_YELLOW);
	setcursor(8,9,1);
	printg("2.- Medium",0,_C_YELLOW);
	setcursor(8,10,1);
	printg("3.- Hard",0,_C_YELLOW);
	setcursor(8,11,1);
	printg("4.- Adin",0,_C_YELLOW);
	get_difficult();
	write_diff();
}
Exemplo n.º 5
0
int fs_test(){
	printg("game start\n");	
	int fp1=open("poem1.txt",0);
	printg("fp1=%d\n",fp1);
	char poem[10][30];
	int i;
	for(i=0;i<4;i++){
		read(fp1,(void*)poem[i],30);
		printg("%s\n",poem[i]);
	}
	close(fp1);
	int fp2=open("poem2.txt",0);
	printg("fp2\n");
	for(i=0;i<4;i++){
		 write(fp2,(void*)poem[i],30);
		 printg("%s\n",poem[i]);
	}
	memset(poem,0,sizeof(poem));
	frewind(fp2);
	for(i=0;i<4;i++){
		read(fp2,(void*)poem[i],30);
		printg("%s\n",poem[i]);
	}
	close(fp2);
	printg("game over nice job");
	while(1);
	return 0;
 }
Exemplo n.º 6
0
int game_main(){
		init_game();
	while(1){
		printg("game_main\n");
	//	printk("hello");
		clear_letter_pressed();
		printg("init_game");
		black_screen();
		prepare_buffer();
		draw_border();
		display_buffer();
		//system_enable_interrupt();
		init_block();
		printg("gamestart");
		game_loop();
		sleep(2);
	}
	return 0;
}
Exemplo n.º 7
0
void
addblanks(double *charslackused, double *charslackover)
{
        *charslackused+=*charslackover;
        while (*charslackused>0.5)
        {
                printg(" ");
                *charslackused-=1;
        }
}
Exemplo n.º 8
0
Arquivo: stg1.c Projeto: acalvoa/SNAKE
void stg1(){
	while(1){
		BACK_TO_FLAG = 0;
		clear_screen();
		setcursor(8,5,1);
		printg("SNAKE: ADIN EDITION MENU\n\r\0",0,_C_YELLOW);
		set_border();
		draw_game_line(23,25,133,25,_C_YELLOW,1);
		setcursor(8,8,1);
		printg("1.- Start Game",0,_C_YELLOW);
		setcursor(8,9,1);
		printg("2.- Select Difficult",0,_C_YELLOW);
		setcursor(8,10,1);
		printg("3.- Back to screen",0,_C_YELLOW);
		write_diff();
		write_highscore();
		select_menu();
		if(BACK_TO_FLAG == 1) break;
	}
}
Exemplo n.º 9
0
int test_fp2(){
	int fp=open("poem2.txt",0);
	char poem[10][30];
	int i;
	for(i=0;i<4;i++){
		read(fp,(void*)poem[i],30);
		printg("%s\n",poem[i]);
	}
	while(1);
	return -1;
}
Exemplo n.º 10
0
/*
** print the label of a system-statistics line and switch on
** colors if needed 
*/
static int
syscolorlabel(char *labeltext, int usecolors, unsigned int badness)
{
        if (screen)
        {
                if (badness >= 100)
                {
                        attron (A_BLINK);

		        if (usecolors)
                        	attron(COLOR_PAIR(COLORHIGH));
			else
                        	attron(A_BOLD);

                        printg(labeltext);

                        attroff(A_BLINK);

                        return COLORHIGH;
                }

                if (almostcrit && badness >= almostcrit)
                {
		        if (usecolors)
                        	attron(COLOR_PAIR(COLORMED));
			else
                        	attron(A_BOLD);

                        printg(labeltext);

                        return COLORMED;
                }
        }

        /*
        ** no colors required or no reason to show colors
        */
        printg(labeltext);
        return 0;
}
Exemplo n.º 11
0
void fork_test(){
	//if(system_env_fork()){
	//	printg("bang\n");
	//	system_env_sleep(100);
	//}
	int i;
	for(i=0;i<2;i++)
	{
	    system_env_fork();
	    printg("X\n");
	}
	while(1);
}
Exemplo n.º 12
0
Arquivo: hello.c Projeto: xjtuwjp/farm
int
main()
{
	int i = 0;

	printf("i = %d\n", i);

	printf("hello\n");

	G = 5;
	printg();

	return 0;
}
Exemplo n.º 13
0
void desalojar_tarea(enum razon_desalojo_de_tarea razon){
	pos_validas[tarea_actual] = 0;
	cant_validas --;
	imprimir_desalojo(razon);
	matar_clock(tarea_actual);
	huboDesalojo = TRUE;
	info_desalojo[tarea_actual].cr0=(unsigned int)rcr0;
	info_desalojo[tarea_actual].cr2=(unsigned int)rcr2;
	info_desalojo[tarea_actual].cr4=(unsigned int)rcr4;
	info_desalojo[tarea_actual].razon= razon;
	 
	char p = tarea_actual + 1 + '0';

	printg(p,7,60,C_FG_LIGHT_GREY,C_BG_RED);
	}
Exemplo n.º 14
0
int main(int argc, char *argv[]) {

	// Allocate stack

	stack st[N];

	// Create shortest paths matrix

	const unsigned seed = atoi(argv[1]);
	st->sp = createsp(seed);

	// Generate random set of drivers

	for (agent i = 0; i < D; i++)
		st->dr[i] = 1;

	memset(st->dr + D, 0, sizeof(agent) * (N - D));
	shuffle(st->dr, N, sizeof(agent));
	memcpy(drg, st->dr, N * sizeof(agent));

	// Initialise n, s, and cs data structures

	st->n[N] = N;

	for (agent i = 0; i < N; i++) {
		X(sg, i) = X(st->s, i) = 1;
		Y(sg, i) = Y(st->s, i) = csg[i] = st->cs[i] = i;
		st->l[i] = st->sp[4 * i * N + 2 * i + 1];
		min += COST(i, st->dr, st->l);
		st->n[st->n[i] = N + i + 1] = i;
	}

	// Initialise c and r bitmasks

	ONES(st->c, E + 1, C);
	CLEAR(st->c, 0);
	ONES(st->r, E + 1, C);
	CLEAR(st->r, 0);

	// Create graph

	#ifdef M
	init(seed);
	memset(st->g, 0, sizeof(edge) * N * N);
	scalefree(st->g, st->a);
	#else
	FILE *f = fopen(argv[2], "r");
	for (agent e = 1; e <= E; e++) {
		agent v1, v2;
		fscanf(f, "%u %u", &v1, &v2);
		createedge(st->g, st->a, v1, v2, e);
	}
	fclose(f);
	#endif

	// Reorder (eventually)

	#ifdef REORDER
	edge go[N * N] = {0};
	agent ao[2 * (E + 1)];
	#ifdef METIS
	idx_t options[METIS_NOPTIONS];
	METIS_SetDefaultOptions(options);
	options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_CUT;
	options[METIS_OPTION_SEED] = seed;
	real_t tpwgts[2] = {0.5, 0.5}, ubvec = TOLERANCE;
	agent map[N];
	edge e = 1;
	for (agent i = 0; i < N; i++) map[i] = i;
	reorderedges(st->g, map, N, E, go, ao, &e, tpwgts, &ubvec, options);
	#else
	driversbfs(st->a, st->dr, go, ao);
	#endif
	memcpy(st->g, go, sizeof(edge) * N * N);
	memcpy(st->a, ao, sizeof(agent) * 2 * (E + 1));
	#endif

	#ifdef TREEDOT
	st->dot = fopen(TREEDOT, "w+");
	fprintf(st->dot, "digraph TREE {\n");
	fprintf(st->dot, "\tnode [color = none; shape = plaintext, width = 0.2, height = 0.2];\n");
	#endif

	// Solve

	sol = *st;
	#ifdef LIMIT
	value bou = bound(st);
	#endif
	gettimeofday(&t1, NULL);
	srcfss(st, min);
	gettimeofday(&t2, NULL);

	// Print solution

	#ifdef TREEDOT
	printf("SOLUTION = %zu\n", sol.id);
	fprintf(st->dot, "\t%zu [shape = circle, style = filled, fillcolor = green];\n", sol.id);
	#endif

	#ifdef PK
	FILE *pk = fopen(PK, "w+");
	fprintf(pk, "%u\n%u\n%u\n", N, K, seed);
	printg(st->g, pk);
	printpk(&sol, pk);
	fclose(pk);
	#endif

	#ifdef CSV
	printf("%u,%u,%s,%.2f,%f,%zu\n", N, E, argv[1], 0.01 * min, 
	       (double)(t2.tv_usec - t1.tv_usec) / 1e6 + t2.tv_sec - t1.tv_sec, count);
	#else
	printcs(&sol);
	printf("Visited nodes = %zu\n", count);
	printf("Elapsed time = %f\n", (double)(t2.tv_usec - t1.tv_usec) / 1e6 + t2.tv_sec - t1.tv_sec);
	printf("Solution = %.2f€\n", 0.01 * min);
	#ifdef LIMIT
	printf("Bound = %.2f€\n", 0.01 * bou);
	#endif
	#endif

	// Free data structures

	#ifdef TREEDOT
	fprintf(st->dot, "}");
	fclose(st->dot);
	#endif
	free(st->sp);

	return 0;
}
Exemplo n.º 15
0
void sigchild(int signo)
{
	printg("We have a signal right now!\n");
	GrClose();
	exit(0);
}
Exemplo n.º 16
0
// El ID llega de 1 a 8
void imprimir_regs_desalojo(unsigned int id){
	
	unsigned short fila = 0;
	unsigned short col  = 0;
	
	int i;
	char* imprimir = buffer8B;
	unsigned char letra = C_FG_LIGHT_BROWN;
	unsigned char	formato = C_BG_LIGHT_GREY;
	
	razon_desalojo t;
	t = (razon_desalojo) info_desalojo[id-1].razon;
	imprimir_desalojo(t);
	
	
	
	// Imprimo EAX
	fila = 9;
	col = 56;
	int2s(tareas_tss[id-1].eax);
	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);	
		imprimir++;
		col++;	
	}
	
	// Imprimo EBX
	imprimir = buffer8B;
	fila=11;
	col= 56;
	int2s(tareas_tss[id-1].ebx);
	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo ECX
	imprimir = buffer8B;
	fila=13;
	col=56;
	int2s(tareas_tss[id-1].ecx);
	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo EDX
	imprimir = buffer8B;
	fila= 15;
	col= 56;
	int2s(tareas_tss[id-1].edx);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	

	// Imprimo ESI
	imprimir = buffer8B;
	fila=17;
	col=56;
	int2s(tareas_tss[id-1].esi);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo EDI
	imprimir = buffer8B;
	fila=19;
	col=56;
	int2s(tareas_tss[id-1].edi);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo EBP
	imprimir = buffer8B;
	fila=21;
	col=56;
	int2s(tareas_tss[id-1].ebp);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo CR0
	imprimir = buffer8B;
	fila=9;
	col=71;
	int2s(info_desalojo[id-1].cr0);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	
	// Imprimo CR2
	imprimir = buffer8B;
	fila=11;
	col=71;
	int2s(info_desalojo[id-1].cr2);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo CR3
	imprimir = buffer8B;
	fila=13;
	col=71;
	int2s(info_desalojo[id-1].cr3);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	
	// Imprimo CR4
	imprimir = buffer8B;
	fila=15;
	col=71;
	int2s(info_desalojo[id-1].cr4);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	
	// Imprimo DS
	imprimir = buffer4B;
	fila=29;
	col=56;
	short2s(tareas_tss[id-1].ds);

	for (i = 0; i < 4; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	
	// Imprimo ES
	imprimir = buffer4B;
	fila=31;
	col=56;
	short2s(tareas_tss[id-1].es);

	for (i = 0; i < 4; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	
	// Imprimo FS
	imprimir = buffer4B;
	fila=33;
	col=56;
	short2s(tareas_tss[id-1].fs);

	for (i = 0; i < 4; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	

	
	// Imprimo GS
	imprimir = buffer4B;
	fila=35;
	col=56;
	short2s(tareas_tss[id-1].gs);

	for (i = 0; i < 4; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}

	// Imprimo EIP
	imprimir = buffer8B;
	fila= 25;
	col= 56;
	int2s(tareas_tss[id-1].eip);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);	
		imprimir++;
		col++;
	}
	
	// Imprimo CS
	imprimir = buffer4B;
	fila=27;
	col=56;
	short2s(tareas_tss[id-1].cs);			// Lo trunco a short
	for (i = 0; i < 4; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}	
	
	// Imprimo EFLAGS
	imprimir = buffer8B;
	fila=39;
	col=59;
	int2s(tareas_tss[id-1].eflags);
	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	// Imprimo ESP
	imprimir = buffer8B;
	fila=23;
	col=56;
	int2s(tareas_tss[id-1].esp);

	for (i = 0; i < 8; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
	
	// Imprimo SS
	imprimir = buffer4B;
	fila=37;
	col=56;
	short2s(tareas_tss[id-1].ss);
	for (i = 0; i < 4; i++){
		printg(*imprimir,fila,col,letra,formato);
		imprimir++;
		col++;
	}
		

	// Imprimo PILA
	unsigned int j;
	fila=28;
	col=65;
	unsigned int* p = (unsigned int*) tareas_tss[id-1].esp;
	for (i = 0; i < 5; i++){
		unsigned short col_temp = col;
		imprimir = buffer8B;
		int2s(*p);
		for (j = 0; j < 8; j++){
			printg(*imprimir,fila,col_temp,letra,formato);
			imprimir++;
			col_temp++;
		}
		p++;
		fila++;	
	}
	
}
Exemplo n.º 17
0
/*
 * showsysline
 * print an array of sys_printpair things.  If the screen contains to
 * few character columns, lower priority items are removed
 *
 */
void showsysline(sys_printpair* elemptr, 
                 struct sstat* sstat, extraparam *extra,
                 char *labeltext, int usecolors, unsigned int badness
                 )
{
        sys_printdef    *curelem;
        char            coloron=0;
        int maxw = screen ? COLS : linelen;

        // every 15-char item is printed as:
        // >>>> | datadatadata<<<<<
        //     012345678901234
        
        /* how items will fit on one line? */
        int avail = (maxw-5)/15;


        coloron   = syscolorlabel(labeltext, usecolors, badness);

        /* count number of items */
        sys_printpair newelems[40];     // MURPHY
        int nitems;
        for (nitems=0; elemptr[nitems].f != 0; ++nitems)
        {
                newelems[nitems]=elemptr[nitems];
        }
        newelems[nitems].f=0;

        /* remove lowest priority box to make room as needed */
        while (nitems > avail)
        {
                int lowestprio=999999;
                int lowestprio_index=-1;
                int i;
                for (i=0; i<nitems; ++i) 
                {
                        if (newelems[i].prio < lowestprio) 
                        {
                                lowestprio=newelems[i].prio;
                                lowestprio_index=i;
                        }
                }
                
                // lowest priority item found, remove from newelems;
                memmove(newelems+lowestprio_index, 
                        newelems+lowestprio_index+1, 
                        (nitems-lowestprio_index)* sizeof(sys_printpair));   
                       // also copies final 0 entry
                nitems--;
                
        }

        /* 
         * ``item shortage'' is used to make entire blank boxes
         * these boxes are spread out as much as possible
         * remaining slack is used to add spaces around the vertical
         * bars
         */
        double slackitemsover;
        if (nitems >1)
        {
                slackitemsover=(double)(avail-nitems)/(nitems-1);
        }
        else 
        {
                slackitemsover=(avail-nitems)/2;
        }


        // charslack: the slack in characters after using as many
        // items as possible
        double charslackover = screen ? ((COLS - 5) % 15) : 0.0;


        // two places per items where blanks can be added
        charslackover /= (avail * 2);    


        double charslackused=0.0;
        double itemslackused=0.0;
        elemptr=newelems;
        while ((curelem=elemptr->f)!=0) 
        {
                printg(" | ");
                addblanks(&charslackused, &charslackover);
                printg("%s", curelem->doconvert(sstat, extra));
                if (screen)
                {
                        itemslackused+=slackitemsover;
                        while (itemslackused>0.5)
                        {
                                addblanks(&charslackused, &charslackover);
                                printg(" | ");
                                printg("%s", sysprt_BLANKBOX(0, 0));
                                addblanks(&charslackused, &charslackover);
                                itemslackused-=1;
                        }
                }
                elemptr++;

                addblanks(&charslackused, &charslackover);
        }

        printg(" |");

        if (coloron)
        {
		if (screen)
		{
			if (usecolors)
                		attroff(COLOR_PAIR(coloron));
			else
                		attroff(A_BOLD);
		}
        }

        if (!screen) 
        {
                printg("\n");
        }
}
Exemplo n.º 18
0
void matar_clock (unsigned int id){
	printg('X',49,(54 + id*2),C_FG_RED,C_BG_LIGHT_GREY);
}