time( &1 );
for(;;)
{
:
 time( &2 );
 if (difftime(t2,t1)>300.0) break;
}

もしくは、アラームのシグナルハンドラー登録かな?

pthread_XXXXは環境が提供されていと使えまへん。