SetTimeout()

I use this (using the timer 2) to check my serial connection status, but you might need to modify a little bit for your usage. It checks if a condition is met every second, the condition being that the "timeout" variable should be different of zero, otherwise it shows a timeout occurred.

byte timeout = 0;

void setup()
{
  // initialize counter
  TCNT2 = 0;
  // set prescaler to 256
  TCCR2 = 0x06;
  // enable overflow interrupt
  TIMSK |= (1 << TOIE2);
  // enable global interrupts
  asm("SEI");
}

void loop() {
  while(/* blocking function */)
  {
    // prevent timeout
    timeout = 1;
  }
}

ISR(TIMER2_OVF_vect)
{
  // 8e6Hz / 256 / 256 / 122 = 1Hz (check every second)
  if(timerCounter++ < 122)
  {
    return;
  }

  // verify timeout status
  if(timeout == 0)
  {
    // interpret as timeout failure
    /* do something drastic */
  }
  timeout = 0;
  timerCounter = 0;
}