int main ()
 {
  /*
   * Называйте названия структур с заглавной, а переменные со строчной, тогда не надо выдумывать названия:
   * Dish dish;
   */
	struct dish
	{
		int size;
		int DirtinessRate;
	}dirtyDish;

	int fdin, fdout;
	int answer = 1;
    CreateFifo(name1);
    CreateFifo(name2);

  /*
   * Можно писать просто while (answer) {}
   */ 
	while ((1)&&(answer))
	{
        fdout = OpenFifo(name1, output);
		dirtyDish.size = (int) rand() % N + 1;
		dirtyDish.DirtinessRate = (int) rand() % N;
		printf("Dirty dish: size %d, dirtiness rate %d\n", dirtyDish.size, dirtyDish.DirtinessRate);
		write(fdout, &dirtyDish, sizeof(struct dish));
		close(fdout);
        fdin = OpenFifo(name2, input);
		read(fdin, &answer, sizeof(int));
		close(fdin);
	}
	return 0;
}
Exemple #2
0
/* Returns true/false if initialization was successful */
bool VMware::InitHardware(void)
{
	/* This has to be done first, otherwise we can't
	 * access the SVGA registers */
	if(!setupIoPorts())
	{
		dbprintf("VMware - Failed to setup the IO ports.\n");
		return false;
	}


	/*** Grab the SVGA Id ***/
	m_regId = vmwareGetSvgaId();
	if(m_regId == (uint32)SVGA_ID_2)
	{
		dbprintf("VMware - SVGA Id is SVGA_ID_2\n");
	}
	else if(m_regId == (uint32)SVGA_ID_1)
	{
		dbprintf("VMware - SVGA Id is SVGA_ID_1\n");
		return false;
	}
	else if(m_regId == (uint32)SVGA_ID_0)
	{
		dbprintf("VMware - SVGA Id is SVGA_ID_0\n");
		return false;
	}
	else
	{
		dbprintf("VMware - SVGA Id is SVGA_ID_INVALID\n");
		return false;
	}

	/*** Map the frame buffer and the command FIFO ***/
	if(!CreateFb())
	{
		dbprintf("VMware -Failed to map the frame buffer.\n");
		return false;
	}
	dbprintf("VMware - Successfully mapped the frame buffer.\n");


	if(!CreateFifo())
	{
		dbprintf("VMware - Failed to map the command FIFO.\n");
		return false;
	}
	dbprintf("VMware - Successfully mapped the command FIFO.\n");


	/*** Initialize the FB ***/
	if(!InitFb())
	{
		dbprintf("VMware - Failed to initialized the frame buffer.\n");
		return false;
	}
	dbprintf("VMware - Successfully initialized the frame buffer.\n");


	/*** Initialize the command FIFO ***/
	if(!InitFifo())
	{
		dbprintf("VMware - Failed to initialized the command FIFO.\n");
		return false;
	}
	dbprintf("VMware - Successfully initialized the command FIFO.\n");


	/*** Initially disable hardware cursor ***/
	vmwareWriteReg(SVGA_REG_CURSOR_X, 0);
	vmwareWriteReg(SVGA_REG_CURSOR_Y, 0);
	vmwareWriteReg(SVGA_REG_CURSOR_ON, SVGA_CURSOR_ON_HIDE);

	return true;
}