timelimit.c

来自「mpi并行计算的c++代码 可用vc或gcc编译通过 可以用来搭建并行计算试验环」· C语言 代码 · 共 50 行

C
50
字号
/* -*- Mode: C; c-basic-offset:4 ; -*- *//*  $Id: timelimit.c,v 1.2 2004/02/02 14:46:35 gropp Exp $ * *  (C) 2001 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */#include "mpiimpl.h"#include <sys/time.h>/*  * This file provides a time-limit capability. * NOT YET COMPLETE *//*    Generate a SIGALRM after the specified number of seconds.   If seconds is zero, turn off the alarm */void MPIU_SetTimeout( int seconds ){#ifdef HAVE_SETITIMER    struct itimerval timelimit;    struct timeval tval;    struct timeval tzero;    if (seconds > 0) {	tval.tv_sec	      = seconds;	tval.tv_usec	      = 0;	timelimit.it_interval = tzero;       /* Only one alarm */	timelimit.it_value    = tval;	setitimer( ITIMER_REAL, &timelimit, 0 );    }    else {	tzero.tv_sec	  = 0;	tzero.tv_usec	  = 0;	timelimit.it_value	  = tzero;   /* Turn off timer */	setitimer( ITIMER_REAL, &timelimit, 0 );    }    #elif defined(HAVE_ALARM)    /* alarm(0) turns off the alarm */    alarm( seconds );#else#error "No timer available"    #endif}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?