lkml.org 
[lkml]   [2009]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] hpfall.c improvements, thoughts
Hi!

> Some conversation I had with Pavel,
>
> imo the example code should be at least barely useable as in not causing
> harm like I sketched in (1.). Maybe someone else picks that up and
> improves it later on. Patch at the end, quite sketchy and imature as it
> doesn't check for errors, but certainly better than before.

Thanks. Acked-by: Pavel Machek <pavel@ucw.cz>
Pavel


> Signed-off-by: Christian Thaeter <ct@pipapo.org>
> ---
>
> diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c
> index bbea1cc..f3cde67 100644
> --- a/Documentation/hwmon/hpfall.c
> +++ b/Documentation/hwmon/hpfall.c
> @@ -16,6 +16,8 @@
> #include <stdint.h>
> #include <errno.h>
> #include <signal.h>
> +#include <sys/mman.h>
> +#include <sched.h>
>
> void write_int(char *path, int i)
> {
> @@ -63,6 +65,7 @@ void ignore_me(void)
> int main(int argc, char* argv[])
> {
> int fd, ret;
> + struct sched_param param;
>
> fd = open("/dev/freefall", O_RDONLY);
> if (fd < 0) {
> @@ -70,7 +73,12 @@ int main(int argc, char* argv[])
> return EXIT_FAILURE;
> }
>
> - signal(SIGALRM, ignore_me);
> + daemon(0,0);
> + param.sched_priority = sched_get_priority_max(SCHED_FIFO);
> + sched_setscheduler(0, SCHED_FIFO, &param);
> + mlockall(MCL_CURRENT|MCL_FUTURE);
> +
> + signal(SIGALRM, ignore_me);
>
> for (;;) {
> unsigned char count;

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


\
 
 \ /
  Last update: 2009-03-25 22:33    [W:0.050 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site