🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #13606

Re: [c]retardos,timers,temporizadores

#13606
From: Ignacio Arenaza
Date: Sat, 10 Feb 2001 12:36
34 lines
2329 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "David" == David Ram�n Yanes Fari�a <a5dy2NOSPAM@bigfoot.com> writes:

    David> �Que hay mal en ese c�digo?  No deber�a dar 2 segundos?

No, ese es el problema, deberia dar 0 segundos (mas o menos). clock(3)
no te da el tiempo transcurrido entre dos llamadas, sino el tiempo de
CPU usado por el proceso hasta ese momento. Si tu haces sleep(2),
suspendes tu programa durante dos segundos, es decir, le dices al
S.O. que durante 2 segundos no le de tiempo de CPU a tu proceso, con
lo cual, en ese tiempo has consumido 0 segundos de CPU, lo cual es
coherente con tu resultado ;-)

Estrictamente hablando, no sera 0 segundos (las propias llamadas a la
libc, el kernel etc consumen unos microsegundos), pero la idea es esa.

Creo que lo que tu buscas se obtiene con gettimeofday (que es como lo
hace el comando time para calcular el tiempo de uso real).

Saludos. I�aki.

- -- 
  Get PGP/GPG Keys at http://www.escomposlinux.org/iarenaza/pgpkey.html

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Processed by Mailcrypt and GPG

iD8DBQE6hTWfZXLnGT1HLgcRAj4MAJ9qpSt+n/0Ka6b+XF08XsxJ1M1egACgiSYd
aAWFb3apzjhELih3N9puoyQ=
=2AbY
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <87ae7uu32y.fsf@eb2ebu.ampr.org>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!xfer13.netnews.com!netnews.com!opentransit.net!newsfeed.comtenidos.com!m2newsfeeder01!44.133.1.30!nobody
References: <3A832EEA.C30F2461@bigfoot.com>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,89a84b7821a48b84
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-02-10 08:17:13 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!xfer13.netnews.com!netnews.com!opentransit.net!newsfeed.comtenidos.com!m2newsfeeder01!44.133.1.30!nobody
From: Ignacio Arenaza <iarenaza@eb2ebu.ampr.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: [c]retardos,timers,temporizadores
Date: 10 Feb 2001 13:36:53 +0100
Organization: Servidor NNTP de eb2ebu.ampr.org
Lines: 34
Message-ID: <87ae7uu32y.fsf@eb2ebu.ampr.org>
References: <3A832EEA.C30F2461@bigfoot.com>
NNTP-Posting-Host: usuario2-36-88-42.dialup.uni2.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: m2wpersoisp01.wanadoo.es 981820960 15252 62.36.88.42 (10 Feb 2001 16:02:40 GMT)
X-Complaints-To: usenet@m2wpersoisp01.wanadoo.es
NNTP-Posting-Date: Sat, 10 Feb 2001 16:02:40 +0000 (UTC)
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7