DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T c

⟦3eade39a3⟧ TextFile

    Length: 1657 (0x679)
    Types: TextFile
    Names: »clock.c«

Derivation

└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/musbus/clock.c« 
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21F/musbus/clock.c« 

TextFile

/*
 *  clock -- check alarm signal accuracy
 *
 *  $Header: clock.c,v 5.2 87/12/09 14:42:34 kenj Exp $
 */

#include <stdio.h>
#include "musbus.h"
#include <sys/types.h>
#ifdef BSD4v1
#include <sys/timeb.h>
#endif
#ifdef BSD4v2
#include <sys/time.h>
#endif
#ifdef SysV
#include <sys/times.h>
long	times();
#ifdef interdata
#define HZ tbuffer.tms_cfreq
#endif
#endif

#define GRANULE		5
#define NUM_ALRM	12

main(argc, argv)
int	argc;
char	*argv[];
{
    int			onalarm();
    register int	i = 0;
    int			expected;
    float		wallclock;
    long		then;
#ifdef SysV
    struct tms		tbuffer;
#endif
#ifdef BSD4v1
    struct timeb	tbuf;
    int			msec;
#endif
#ifdef BSD4v2
    struct timeval	tval;
    struct timezone	tzone;
    long		usec;
#endif

#ifdef SysV
    then = times(&tbuffer);
#else
#ifdef BSD4v1
    ftime(&tbuf);
    then = tbuf.time;
    msec = tbuf.millitm;
#else
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    then = tval.tv_sec;
    usec = tval.tv_usec;
#else
	What sort of Unix system is this?
#endif
#endif
#endif
    while (i++ < NUM_ALRM) {
	    signal(SIGALRM, onalarm);
	    alarm(GRANULE);
	    pause();
    }
#ifdef SysV
    wallclock = (times(&tbuffer) - then)/HZ;
#endif
#ifdef BSD4v1
    ftime(&tbuf);
    wallclock = tbuf.time - then + (float)(tbuf.millitm - msec)/1000;
#endif
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    wallclock = tval.tv_sec - then + (float)(tval.tv_usec - usec)/1000000;
#endif
    expected = GRANULE * NUM_ALRM;
    printf("%d x %d sec delays takes %.2f wallclock secs (erreur %.2f%%)\n",
	NUM_ALRM, GRANULE, wallclock, 100.0*(float)(expected-wallclock)/expected);
    exit(0);
}

onalarm() { }