Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.hardware > #2408

Re: Realtime clock accessible without context-switch?

From Jan Pieter <jp@jp.dhs.orig>
Newsgroups comp.os.linux.misc, comp.os.linux.hardware
Subject Re: Realtime clock accessible without context-switch?
Date 2014-06-01 09:58 +0200
Organization Badly Configured Clients, Inc.
Message-ID <lmemef$8dc$1@news.albasani.net> (permalink)
References <llfapk$mhc$2@dont-email.me> <bu1qcoFt9amU1@mid.individual.net> <llhkkb$56l$1@dont-email.me> <bu46amFe2ebU1@mid.individual.net>

Cross-posted to 2 groups.

Show all headers | View raw


On 05/21/2014 07:32 PM, Clemens Ladisch wrote:

> #include<stdio.h>
> #include<fcntl.h>
> #include<unistd.h>
> #include<sys/mman.h>
>
> int main(void)
> {
> 	int fd = open("/dev/hpet", O_RDONLY);
> 	if (fd == -1) {
> 		perror("/dev/hpet");
> 		return 1;
> 	}
> 	const volatile unsigned int *ptr = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0);
> 	if (ptr == MAP_FAILED) {
> 		perror("mmap");
> 		return 1;
> 	}
> 	printf("frequency: %.5f MHz\n", 1e9 / ptr[1]);
> 	for (;;) {
> 		printf("\rcounter: %08x", ptr[60]);
> 		fflush(stdout);
> 		usleep(123456);
> 	}
> }

as user:
/dev/hpet: Permission denied

as root:
/dev/hpet: Device or resource busy

Jan Pieter.

Back to comp.os.linux.hardware | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Realtime clock accessible without context-switch? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-20 10:29 +0000
  Re: Realtime clock accessible without context-switch? Clemens Ladisch <clemens@ladisch.de> - 2014-05-20 21:56 +0200
    Re: Realtime clock accessible without context-switch? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-21 07:29 +0000
      Re: Realtime clock accessible without context-switch? Thomas Richter <thor@math.tu-berlin.de> - 2014-05-21 09:47 +0200
      Re: Realtime clock accessible without context-switch? William Unruh <unruh@invalid.ca> - 2014-05-21 15:51 +0000
      Re: Realtime clock accessible without context-switch? Clemens Ladisch <clemens@ladisch.de> - 2014-05-21 19:32 +0200
        Re: Realtime clock accessible without context-switch? Richard Kettlewell <rjk@greenend.org.uk> - 2014-05-21 23:35 +0100
          Re: Realtime clock accessible without context-switch? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-22 07:53 +0000
            Re: Realtime clock accessible without context-switch? Clemens Ladisch <clemens@ladisch.de> - 2014-05-22 20:36 +0200
              Re: Realtime clock accessible without context-switch? Richard Kettlewell <rjk@greenend.org.uk> - 2014-05-22 20:26 +0100
                Re: Realtime clock accessible without context-switch? William Unruh <unruh@invalid.ca> - 2014-05-22 22:48 +0000
        Re: Realtime clock accessible without context-switch? Jan Pieter <jp@jp.dhs.orig> - 2014-06-01 09:58 +0200
  Re: Realtime clock accessible without context-switch? Todd <Todd@invalid.invalid> - 2014-05-23 14:20 -0700

csiph-web