Return to BSD News archive
Xref: sserve comp.sources.wanted:14239 comp.unix.bsd:8243 comp.unix.questions:28830 comp.benchmarks:2466 Newsgroups: comp.sources.wanted,comp.unix.bsd,comp.unix.questions,comp.benchmarks Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.hawaii.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!gate.fzi.de!schreib From: schreib@fzi.de (Hartmut Schreiber) Subject: ALARM(): Does it work correct? / Better solutions? Message-ID: <1992Nov27.112915.7495@fzi.de> Followup-To: comp.benchmarks Keywords: alarm() Sender: news@fzi.de (FZI-news) Reply-To: schreiber@fzi.de Organization: Forschungszentrum Informatik (FZI), Karlsruhe, Germany Date: Fri, 27 Nov 1992 11:29:15 GMT Lines: 37 I'm looking for a function which interrupts another in EXACTLY n seconds. To test, whether alarm() works correctly, I tested it using the following algorithm: (1) gettimeofday --> timestamp1 What time is it? (2) alarm(10) Wake me up in 10 Seconds. (3) ... any work ... ... Do something until SIGALRM ... --> Interupt by SIGALRM break 'something' by interrupt (4) gettimeofday --> timestamp2 What time is it now? (5) measuredTime = timestamp2 - timestamp1 What time did we measure? (6) difference = measuredTime - 10 Compute divergence between measured and programmed time. You would expect that difference is slightly bigger than 0 because of the interrupt handling. But I found out, that it is NEGATIVE, i.e. alarm(10) sent SIGALRM *before* 10 seconds have elapsed. Now my questions are: - Do you know a better way to setup a time frame of EXACTLY n seconds (or preferably m microseconds ;-) ) - Is there another 'alarm' Function which works better? My machine is a Sun SPARCstation1 operating SunOS 4.1.3. Please reply by e-mail or by sending comments to comp.benchmarks. I don't read the comp.unix.* newsgroups, so please don't post answers there. If there is enough interest I'll post a summary to comp.benchmarks or send one by e-mail. Thanks in advance. -- Computer Science Research Center at the University of Karlsruhe Database Systems Division Hartmut Schreiber e-mail: schreiber@fzi.de Haid-und-Neu-Str. 10-14 phone: (+49) 721 9654 744 W7500 Karlsruhe 1 (FRG) fax: (+49) 721 9654 709