Module Name: src Committed By: jmcneill Date: Thu Dec 15 00:40:03 UTC 2011
Modified Files: src/sys/arch/usermode/dev: cpu.c src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: implement cpu idle via sigsuspend To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/arch/usermode/dev/cpu.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.43 -r1.44 src/sys/arch/usermode/usermode/thunk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/usermode/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.52 src/sys/arch/usermode/dev/cpu.c:1.53 --- src/sys/arch/usermode/dev/cpu.c:1.52 Wed Dec 14 12:29:59 2011 +++ src/sys/arch/usermode/dev/cpu.c Thu Dec 15 00:40:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.52 2011/12/14 12:29:59 jmcneill Exp $ */ +/* $NetBSD: cpu.c,v 1.53 2011/12/15 00:40:03 jmcneill Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca> @@ -30,7 +30,7 @@ #include "opt_hz.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.52 2011/12/14 12:29:59 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.53 2011/12/15 00:40:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -247,9 +247,7 @@ cpu_idle(void) if (ci->ci_want_resched) return; -#if notyet - thunk_usleep(10000); -#endif + thunk_idle(); } void Index: src/sys/arch/usermode/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.37 src/sys/arch/usermode/include/thunk.h:1.38 --- src/sys/arch/usermode/include/thunk.h:1.37 Mon Dec 12 16:39:16 2011 +++ src/sys/arch/usermode/include/thunk.h Thu Dec 15 00:40:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.37 2011/12/12 16:39:16 jmcneill Exp $ */ +/* $NetBSD: thunk.h,v 1.38 2011/12/15 00:40:03 jmcneill Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -130,6 +130,8 @@ int thunk_munmap(void *addr, size_t len) int thunk_mprotect(void *addr, size_t len, int prot); int thunk_posix_memalign(void **, size_t, size_t); +int thunk_idle(void); + char * thunk_getenv(const char *); vaddr_t thunk_get_vm_min_address(void); Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.43 src/sys/arch/usermode/usermode/thunk.c:1.44 --- src/sys/arch/usermode/usermode/thunk.c:1.43 Tue Dec 13 22:22:08 2011 +++ src/sys/arch/usermode/usermode/thunk.c Thu Dec 15 00:40:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.43 2011/12/13 22:22:08 jmcneill Exp $ */ +/* $NetBSD: thunk.c,v 1.44 2011/12/15 00:40:03 jmcneill Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.43 2011/12/13 22:22:08 jmcneill Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.44 2011/12/15 00:40:03 jmcneill Exp $"); #endif #include <sys/types.h> @@ -41,6 +41,7 @@ __RCSID("$NetBSD: thunk.c,v 1.43 2011/12 #include <assert.h> #include <errno.h> #include <fcntl.h> +#include <sched.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> @@ -586,3 +587,12 @@ thunk_get_vm_min_address(void) return VM_MIN_ADDRESS; } +int +thunk_idle(void) +{ + sigset_t sigmask; + + sigemptyset(&sigmask); + + return sigsuspend(&sigmask); +}