diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-08-12 21:01:31 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-08-12 21:01:31 +0000 |
commit | 13ae658495538f1f2164654c49656b20355cb967 (patch) | |
tree | 1978e60f441a4727e29ac770959092e322f358e0 | |
parent | 4eda8fcc9c7e4d209445756e81454e19e3adb3c8 (diff) | |
download | klibc-13ae658495538f1f2164654c49656b20355cb967.tar.gz |
Better handling of nice(); add setpriority() getpriority()klibc-0.23
sched_setscheduler() sched_yield()
-rw-r--r-- | SYSCALLS | 4 | ||||
-rw-r--r-- | getpriority.c | 25 | ||||
-rw-r--r-- | include/sched.h | 23 | ||||
-rw-r--r-- | include/sys/resource.h | 3 | ||||
-rw-r--r-- | klibc/Makefile | 2 | ||||
-rw-r--r-- | klibc/SYSCALLS | 4 | ||||
-rw-r--r-- | klibc/getpriority.c | 25 | ||||
-rw-r--r-- | klibc/include/sched.h | 23 | ||||
-rw-r--r-- | klibc/include/sys/resource.h | 3 | ||||
-rw-r--r-- | klibc/nice.c | 21 | ||||
-rw-r--r-- | klibc/syscommon.h | 1 | ||||
-rw-r--r-- | nice.c | 21 | ||||
-rw-r--r-- | syscommon.h | 1 |
13 files changed, 153 insertions, 3 deletions
diff --git a/SYSCALLS b/SYSCALLS index 48e2811c90109..ba30a3e1fb9cd 100644 --- a/SYSCALLS +++ b/SYSCALLS @@ -23,7 +23,9 @@ pid_t setsid() pid_t getsid(pid_t) pid_t wait4(pid_t, int *, int, struct rusage *) int execve(const char *, char * const *, char * const *) -<!x86_64,ia64,alpha> int nice(int) +int setpriority(int, int, int); +int sched_setscheduler(pid_t, int, const struct sched_param *) +int sched_yield() # # User and group IDs diff --git a/getpriority.c b/getpriority.c new file mode 100644 index 0000000000000..d6db2cc6b9542 --- /dev/null +++ b/getpriority.c @@ -0,0 +1,25 @@ +/* + * getpriority.c + * + * Needs to do some post-syscall mangling to distinguish error returns... + * but only on some platforms. Sigh. + */ + +#include <unistd.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/syscall.h> + +#define __NR__getpriority __NR_getpriority + +static inline _syscall2(int,_getpriority,int,which,int,who); + +int getpriority(int which, int who) +{ +#if defined(__alpha__) || defined(__ia64__) + return _getpriority(which, who); +#else + int rv = _getpriority(which, who); + return ( rv < 0 ) ? rv : 20-rv; +#endif +} diff --git a/include/sched.h b/include/sched.h new file mode 100644 index 0000000000000..5e6103965f9d5 --- /dev/null +++ b/include/sched.h @@ -0,0 +1,23 @@ +/* + * sched.h + */ + +#ifndef _SCHED_H +#define _SCHED_H + +#include <klibc/extern.h> + +/* linux/sched.h is unusable; put the declarations we need here... */ + +#define SCHED_NORMAL 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 + +struct sched_param { + int sched_priority; +}; + +__extern int sched_setschedule(pid_t, int, const struct sched_param *); +__extern int sched_yield(void); + +#endif /* _SCHED_H */ diff --git a/include/sys/resource.h b/include/sys/resource.h index 93c44390d4996..7cb11f2c052de 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -8,4 +8,7 @@ #include <sys/types.h> /* MUST be included first! */ #include <linux/resource.h> +__extern int getpriority(int, int); +__extern int setpriority(int, int, int); + #endif /* _SYS_RESOURCE_H */ diff --git a/klibc/Makefile b/klibc/Makefile index f4ebe3fa860e1..27d0fbc8b8898 100644 --- a/klibc/Makefile +++ b/klibc/Makefile @@ -34,7 +34,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \ strncmp.o strncpy.o strrchr.o strspn.o strsep.o strtok.o \ gethostname.o getdomainname.o getcwd.o seteuid.o setegid.o \ getenv.o setenv.o unsetenv.o getopt.o readdir.o \ - time.o fdatasync.o llseek.o select.o + time.o fdatasync.o llseek.o select.o nice.o getpriority.o LIB = libc.a SOFLAGS = -fPIC diff --git a/klibc/SYSCALLS b/klibc/SYSCALLS index 48e2811c90109..ba30a3e1fb9cd 100644 --- a/klibc/SYSCALLS +++ b/klibc/SYSCALLS @@ -23,7 +23,9 @@ pid_t setsid() pid_t getsid(pid_t) pid_t wait4(pid_t, int *, int, struct rusage *) int execve(const char *, char * const *, char * const *) -<!x86_64,ia64,alpha> int nice(int) +int setpriority(int, int, int); +int sched_setscheduler(pid_t, int, const struct sched_param *) +int sched_yield() # # User and group IDs diff --git a/klibc/getpriority.c b/klibc/getpriority.c new file mode 100644 index 0000000000000..d6db2cc6b9542 --- /dev/null +++ b/klibc/getpriority.c @@ -0,0 +1,25 @@ +/* + * getpriority.c + * + * Needs to do some post-syscall mangling to distinguish error returns... + * but only on some platforms. Sigh. + */ + +#include <unistd.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/syscall.h> + +#define __NR__getpriority __NR_getpriority + +static inline _syscall2(int,_getpriority,int,which,int,who); + +int getpriority(int which, int who) +{ +#if defined(__alpha__) || defined(__ia64__) + return _getpriority(which, who); +#else + int rv = _getpriority(which, who); + return ( rv < 0 ) ? rv : 20-rv; +#endif +} diff --git a/klibc/include/sched.h b/klibc/include/sched.h new file mode 100644 index 0000000000000..5e6103965f9d5 --- /dev/null +++ b/klibc/include/sched.h @@ -0,0 +1,23 @@ +/* + * sched.h + */ + +#ifndef _SCHED_H +#define _SCHED_H + +#include <klibc/extern.h> + +/* linux/sched.h is unusable; put the declarations we need here... */ + +#define SCHED_NORMAL 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 + +struct sched_param { + int sched_priority; +}; + +__extern int sched_setschedule(pid_t, int, const struct sched_param *); +__extern int sched_yield(void); + +#endif /* _SCHED_H */ diff --git a/klibc/include/sys/resource.h b/klibc/include/sys/resource.h index 93c44390d4996..7cb11f2c052de 100644 --- a/klibc/include/sys/resource.h +++ b/klibc/include/sys/resource.h @@ -8,4 +8,7 @@ #include <sys/types.h> /* MUST be included first! */ #include <linux/resource.h> +__extern int getpriority(int, int); +__extern int setpriority(int, int, int); + #endif /* _SYS_RESOURCE_H */ diff --git a/klibc/nice.c b/klibc/nice.c new file mode 100644 index 0000000000000..c3d9da630a9ae --- /dev/null +++ b/klibc/nice.c @@ -0,0 +1,21 @@ +/* + * nice.c + */ + +#include <unistd.h> +#include <sched.h> +#include <sys/syscall.h> + +#ifdef __NR_nice + +_syscall1(int,nice,int,inc); + +#else + +int nice(int inc) +{ + pid_t me = getpid(); + return setpriority(me, PRIO_PROCESS, getpriority(me, PRIO_PROCESS)); +} + +#endif diff --git a/klibc/syscommon.h b/klibc/syscommon.h index cdd225f8c35da..46777db8b86cb 100644 --- a/klibc/syscommon.h +++ b/klibc/syscommon.h @@ -11,6 +11,7 @@ #include <sys/syscall.h> #include <poll.h> +#include <sched.h> #include <sys/dirent.h> #include <sys/mman.h> #include <sys/module.h> diff --git a/nice.c b/nice.c new file mode 100644 index 0000000000000..c3d9da630a9ae --- /dev/null +++ b/nice.c @@ -0,0 +1,21 @@ +/* + * nice.c + */ + +#include <unistd.h> +#include <sched.h> +#include <sys/syscall.h> + +#ifdef __NR_nice + +_syscall1(int,nice,int,inc); + +#else + +int nice(int inc) +{ + pid_t me = getpid(); + return setpriority(me, PRIO_PROCESS, getpriority(me, PRIO_PROCESS)); +} + +#endif diff --git a/syscommon.h b/syscommon.h index cdd225f8c35da..46777db8b86cb 100644 --- a/syscommon.h +++ b/syscommon.h @@ -11,6 +11,7 @@ #include <sys/syscall.h> #include <poll.h> +#include <sched.h> #include <sys/dirent.h> #include <sys/mman.h> #include <sys/module.h> |