예제 #1
0
int main(int argc, char *argv[]) {
	static char pwd[1024];
	if(argc < 2) {
		WARN("No Command Specified.");
		_exit(1);
	}
	INFO("Current Working Directory:");
	INFO((char *)getcwd(pwd, 1024));
	struct res_lim *lim = (struct res_lim*) malloc(sizeof(struct res_lim));
	memset(lim, 0, sizeof(struct res_lim));
	lim -> mem_cur = lim -> mem_max = 16777216;
	lim -> fs_cur = lim -> fs_max = 16777216;
	lim -> fn_cur = 3, lim -> fn_max = 3;
	lim -> cpu_cur.tv_sec = 1, lim -> cpu_cur.tv_nsec = 0;
	lim -> cpu_max.tv_sec = 2, lim -> cpu_max.tv_nsec = 0;
	lim -> st_cur = lim -> st_max = 16777216;
	lim -> ps_cur = 1, lim -> ps_max = 1;
	lim -> uid = 9998, lim -> gid = 9998;
	lim -> root = pwd;
	lim -> filein = "/tmp/input.txt", lim -> fileout = "/tmp/output.txt";
	//lim -> root = NULL;
	static char* args[1024];
	register int i;
	for(i = 1; i < argc; ++ i) args[i - 1] = argv[i];
	args[argc - 1] = NULL;
	pid_t child = execute(args, lim);
	if(child < 0) {
		ERROR("execute failed!");
		exit(1);
	}
	static struct res_usage result;
	static struct timeval timeout;
	timeout.tv_sec = 0, timeout.tv_usec = 500000;
	getProgramStatus(child, &timeout, &result);
	sprintf(_buff, "Child exit status code: %ld", result.exitcode);
	INFO(_buff);
	sprintf(_buff, "CPU Time: %ld s, %ld ns", result.cputime.tv_sec, result.cputime.tv_nsec);
	INFO(_buff);
	sprintf(_buff, "Real Time: %ld s, %ld ns", result.realtime.tv_sec, result.realtime.tv_nsec);
	INFO(_buff);
	sprintf(_buff, "Memory Usage: %ld", result.memusage);
	INFO(_buff);
	return 0;
}
예제 #2
0
/*******************************************************************************
* Function Name  : VN_SPI_SendReceiveWord(unsigned long data)
* Description    : Transmits the given 32-bit word on the SPI bus. The user needs
*                  to place their hardware specific logic here to send 4 bytes
*                  out the SPI bus. The slave select line is controlled by the 
*                  function VN_SPI_SetSS given above, so the user only needs
*                  to deal with sending the data out the SPI bus with this
*                  function.
* Input          : data -> The 32-bit data to send over the SPI bus
* Output         : None
* Return         : The data received on the SPI bus
*******************************************************************************/
unsigned long VN_SPI_SendReceive(unsigned long data){

char smAllowed = getProgramStatus() > ARMING;
/* User code to send out 4 bytes over SPI goes here */
  unsigned long ret = 0;
    /* Wait for SPI1 Tx buffer empty */
    //while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
  	while (SPI2STATbits.SPITBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
    /* Send SPI1 requests */
    //SPI_I2S_SendData(SPI1, VN_BYTE(data, i));
	SPI2BUF = VN_BYTE4(data);
        while (SPI2STATbits.SPITBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
    /* Wait for response from VN-100 */
    //while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
  	while (!SPI2STATbits.SPIRBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
        
    /* Save received data in buffer */
    //ret |= ((unsigned long)SPI_I2S_ReceiveData(SPI1) << (8*i));
	ret |= ((unsigned long)SPI2BUF << (0));

  	while (SPI2STATbits.SPITBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
    /* Send SPI1 requests */
    //SPI_I2S_SendData(SPI1, VN_BYTE(data, i));
	SPI2BUF = VN_BYTE3(data);

    /* Wait for response from VN-100 */
    //while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
  	while (!SPI2STATbits.SPIRBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
    /* Save received data in buffer */
    //ret |= ((unsigned long)SPI_I2S_ReceiveData(SPI1) << (8*i));
	ret |= ((unsigned long)SPI2BUF << (8));

  	while (SPI2STATbits.SPITBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
    /* Send SPI1 requests */
    //SPI_I2S_SendData(SPI1, VN_BYTE(data, i));
	SPI2BUF = VN_BYTE2(data);

    /* Wait for response from VN-100 */
    //while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
  	while (!SPI2STATbits.SPIRBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }

    /* Save received data in buffer */
    //ret |= ((unsigned long)SPI_I2S_ReceiveData(SPI1) << (8*i));
	ret |= ((unsigned long)SPI2BUF << (16));

  	while (SPI2STATbits.SPITBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }

    /* Send SPI1 requests */
    //SPI_I2S_SendData(SPI1, VN_BYTE(data, i));
	SPI2BUF = VN_BYTE1(data);

    /* Wait for response from VN-100 */
    //while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
  	while (!SPI2STATbits.SPIRBF){//if (smAllowed){StateMachine(STATEMACHINE_IMU);}
        }
    /* Save received data in buffer */
    //ret |= ((unsigned long)SPI_I2S_ReceiveData(SPI1) << (8*i));
	ret |= ((unsigned long)SPI2BUF << (24));



  return ret;
}