qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Timer/clock for Linux


From: NyOS
Subject: Re: [Qemu-devel] [PATCH] Timer/clock for Linux
Date: Tue, 25 Apr 2006 13:04:45 +0200
User-agent: Opera M2/8.52 (Linux, build 1631)

On Mon, 24 Apr 2006 23:41:23 +0200, Fabrice Bellard <address@hidden> wrote:

Hi,

Can other people confirm that it is better to always use /dev/rtc on Linux ? Is there a way to get the real resolution of the host timer ?

Fabrice.

Hi!

There must be one.
Mplayer says this after setting /proc/sys/dev/rtc/max-user-freq below 1024:

Linux RTC init error in ioctl (rtc_irqp_set 1024): Permission denied
Try adding "echo 1024 > /proc/sys/dev/rtc/max-user-freq" to your system startup scripts.
Using nanosleep() timing

URL=http://mplayerhq.hu/homepage/design7/dload.html

this code can be found in mplayer.c file aprox. 1100th line:

#ifdef HAVE_RTC
  if(!nortc)
  {
    // seteuid(0); /* Can't hurt to try to get root here */
if ((rtc_fd = open(rtc_device ? rtc_device : "/dev/rtc", O_RDONLY)) < 0) mp_msg(MSGT_CPLAYER, MSGL_WARN, "Failed to open %s: %s (it should be readable by the user.)\n",
            rtc_device ? rtc_device : "/dev/rtc", strerror(errno));
     else {
        unsigned long irqp = 1024; /* 512 seemed OK. 128 is jerky. */

        if (ioctl(rtc_fd, RTC_IRQP_SET, irqp) < 0) {
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Linux RTC init error in ioctl (rtc_irqp_set %lu): %s\n", irqp, strerror(errno)); mp_msg(MSGT_CPLAYER, MSGL_HINT, "Try adding \"echo %lu > /proc/sys/dev/rtc/max-user-freq\" to your system startup scripts.\n", irqp);
            close (rtc_fd);
            rtc_fd = -1;
        } else if (ioctl(rtc_fd, RTC_PIE_ON, 0) < 0) {
            /* variable only by the root */
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC init error in ioctl (rtc_pie_on): %s\n", strerror(errno));
            close (rtc_fd);
            rtc_fd = -1;
        } else
            mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_UsingRTCTiming, irqp);
    }
  }

I've never used RTC in my programs, but ioctl seems to return negative value on such an error. A hint like that can also be good on startup.

Miklos Gyozo (Nyos)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]