Example #1
0
/*
 * do_IRQ()
 *	Primary interface for handling IRQ() requests.
 *
 * This function is force executed when the PIC switches a thread to it.
 */
asmlinkage void do_IRQ(struct pt_regs *regs, unsigned int irq)
{
	struct pt_regs *oldregs;
	struct thread_info *ti = current_thread_info();

	STOPWATCH_DECLARE;
	trace_hardirqs_off();

	/*
	 * Mark that we are inside of an interrupt and
	 * that interrupts are disabled.
	 */
	oldregs = set_irq_regs(regs);
	ti->interrupt_nesting++;
	irq_kernel_stack_check(irq, regs);

	/*
	 * Start the interrupt sequence
	 */
	irq_enter();

	/*
	 * Execute the IRQ handler and any pending SoftIRQ requests.
	 */
	BUG_ON(!irqs_disabled());
	STOPWATCH_START();
	generic_handle_irq(irq);
	STOPWATCH_END(&irq_watches[irq]);
	BUG_ON(!irqs_disabled());

	/*
	 * Exit the interrupt and process softirqs if needed.
	 */
	STOPWATCH_START();
	irq_exit();
	STOPWATCH_END(&irq_watches[INTERRUPT_COUNT]);
	BUG_ON(!irqs_disabled());

	/*
	 * Outside of an interrupt (or nested exit).
	 */
	trace_hardirqs_on();
	ti->interrupt_nesting--;
	set_irq_regs(oldregs);
}
void BallDetector::execute()
{
  //if there is no field percept, then, there is also no goal ?!
  /*
  if(!getFieldPercept().isValid())
  {
    getBallPercept().ballWasSeen = false;
    return;
  }
  */
  
  getBallPercept().reset();

  //initialize blob finder
  //theBlobFinder.init();

  BlobList blobList;
  //WholeArea wholeImageArea;

  //search only if field is marked as valid
  if(getFieldPercept().isValid())
  {
    //theBlobFinder.execute(blobList, connectedColors, wholeImageArea);
    STOPWATCH_START("BallDetector ~ BlobFinder");
    theBlobFinder.execute(blobList, connectedColors, getFieldPercept().getLargestValidPoly());
    STOPWATCH_STOP("BallDetector ~ BlobFinder");
  }


  // draw deteced blobs
  DEBUG_REQUEST("ImageProcessor:BallDetector:mark_ball_blob",
    for(int i = 0; i < blobList.blobNumber; i++)
    {
      const Blob& blob = blobList.blobs[i];
      RECT_PX(ColorClasses::orange,
              (unsigned int)(blob.upperLeft.x),
              (unsigned int)(blob.upperLeft.y),
              (unsigned int)(blob.lowerRight.x),
              (unsigned int)(blob.lowerRight.y));
      CIRCLE_PX(ColorClasses::orange, blob.centerOfMass.x, blob.centerOfMass.y, 4);
    }//end for
  );
Example #3
0
int 
main(void)
{
	unsigned int cycles = 1;
	unsigned int run_for = 2;
	unsigned int i;

	
	STOPWATCH_INIT(a);
	STOPWATCH_START(a);

	/**
	 * Calibrating the number of cycles so that the whole wait_for() process takes
	 * more than 400ms.
	 * This is not, and is not supposed to be, scientifically accurate. F.ex. possible
	 * application scheduling may mess this up.
	 *
	*/
	do {
		cycles *= 10;
		wait_for(cycles);

		STOPWATCH_STOP(a);
		i = STOPWATCH_ELAPSED_US(a);

	} while (i < 400000);

	printf("Cycles calibrated to %u\nRunning for %d+ seconds\n\n", cycles, run_for);


	/**
	 * Do wait_for() loops until run_for seconds has passed.
	 * Then print out the elapsed time and do some simple comparison.
	 *
	*/
	STOPWATCH_START(a);

	do {
		wait_for(cycles);
		
		STOPWATCH_STOP(a);
		i = STOPWATCH_ELAPSED_S(a);
	} while (i < run_for);

	STOPWATCH_PRINT(a);

	double const elap = STOPWATCH_ELAPSED_F(a);
	int const elap_s = STOPWATCH_ELAPSED_S(a);
	int const elap_us = STOPWATCH_ELAPSED_US(a);
	
	struct timeval *const tval = (struct timeval *) malloc(sizeof(struct timeval));
	STOPWATCH_TO_TIMEVAL(*tval, a);

	printf("Elapsed in floating point value: %f\n", elap);
	printf("Elapsed seconds: %d%s\n", elap_s, elap_s != (int) elap ? " <== BUG!": "");
	printf("Elapsed micro seconds: %d%s\n", elap_us, elap_us != ((int) (elap * 1000000 + 0.5)) % 1000000 ? " <== BUG!": "");
	printf("Copy to timeval %ld.%06lu%s\n", tval->tv_sec, tval->tv_usec, tval->tv_sec != elap_s  ||  tval->tv_usec != elap_us ? " <== BUG!" : "");

	free(tval);
	return 0;
}