From 6b2b9d447d15b6a1d7dbc2c6a5247e0e894ad0fb Mon Sep 17 00:00:00 2001 From: trhodes Date: Sat, 11 Nov 2006 16:29:38 +0000 Subject: [PATCH] These files have been repo-copied to the "normal" kernel hierarchy. --- sys/posix4/_semaphore.h | 73 --------- sys/posix4/ksched.c | 331 -------------------------------------- sys/posix4/ksem.h | 59 ------- sys/posix4/p1003_1b.c | 345 ---------------------------------------- sys/posix4/posix4.h | 116 -------------- sys/posix4/posix4_mib.c | 150 ----------------- sys/posix4/sched.h | 77 --------- sys/posix4/semaphore.h | 67 -------- 8 files changed, 1218 deletions(-) delete mode 100644 sys/posix4/_semaphore.h delete mode 100644 sys/posix4/ksched.c delete mode 100644 sys/posix4/ksem.h delete mode 100644 sys/posix4/p1003_1b.c delete mode 100644 sys/posix4/posix4.h delete mode 100644 sys/posix4/posix4_mib.c delete mode 100644 sys/posix4/sched.h delete mode 100644 sys/posix4/semaphore.h diff --git a/sys/posix4/_semaphore.h b/sys/posix4/_semaphore.h deleted file mode 100644 index df3c5da1bd65..000000000000 --- a/sys/posix4/_semaphore.h +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (c) 2002 Alfred Perlstein - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ -#ifndef __SEMAPHORE_H_ -#define __SEMAPHORE_H_ - -typedef intptr_t semid_t; -struct timespec; - -#ifndef _KERNEL - -#include - -/* - * Semaphore definitions. - */ -struct sem { -#define SEM_MAGIC ((u_int32_t) 0x09fa4012) - u_int32_t magic; - pthread_mutex_t lock; - pthread_cond_t gtzero; - u_int32_t count; - u_int32_t nwaiters; -#define SEM_USER (NULL) - semid_t semid; /* semaphore id if kernel (shared) semaphore */ - int syssem; /* 1 if kernel (shared) semaphore */ - LIST_ENTRY(sem) entry; - struct sem **backpointer; -}; - -__BEGIN_DECLS - -int ksem_close(semid_t id); -int ksem_post(semid_t id); -int ksem_wait(semid_t id); -int ksem_trywait(semid_t id); -int ksem_timedwait(semid_t id, const struct timespec *abstime); -int ksem_init(semid_t *idp, unsigned int value); -int ksem_open(semid_t *idp, const char *name, int oflag, mode_t mode, - unsigned int value); -int ksem_unlink(const char *name); -int ksem_getvalue(semid_t id, int *val); -int ksem_destroy(semid_t id); - -__END_DECLS - -#endif /* !_KERNEL */ - -#endif /* __SEMAPHORE_H_ */ diff --git a/sys/posix4/ksched.c b/sys/posix4/ksched.c deleted file mode 100644 index e8af76be0c9f..000000000000 --- a/sys/posix4/ksched.c +++ /dev/null @@ -1,331 +0,0 @@ -/*- - * Copyright (c) 1996, 1997 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* ksched: Soft real time scheduling based on "rtprio". - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_posix.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* ksched: Real-time extension to support POSIX priority scheduling. - */ - -struct ksched { - struct timespec rr_interval; -}; - -int -ksched_attach(struct ksched **p) -{ - struct ksched *ksched= p31b_malloc(sizeof(*ksched)); - - ksched->rr_interval.tv_sec = 0; - ksched->rr_interval.tv_nsec = 1000000000L / sched_rr_interval(); - - *p = ksched; - return 0; -} - -int -ksched_detach(struct ksched *ks) -{ - p31b_free(ks); - - return 0; -} - -/* - * XXX About priorities - * - * POSIX 1003.1b requires that numerically higher priorities be of - * higher priority. It also permits sched_setparam to be - * implementation defined for SCHED_OTHER. I don't like - * the notion of inverted priorites for normal processes when - * you can use "setpriority" for that. - * - * I'm rejecting sched_setparam for SCHED_OTHER with EINVAL. - */ - -/* Macros to convert between the unix (lower numerically is higher priority) - * and POSIX 1003.1b (higher numerically is higher priority) - */ - -#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P)) -#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P)) - -/* These improve readability a bit for me: - */ -#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX) -#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN) - -static __inline int -getscheduler(struct ksched *ksched, struct thread *td, int *policy) -{ - struct rtprio rtp; - int e = 0; - - mtx_lock_spin(&sched_lock); -#ifdef KSE - pri_to_rtp(td->td_ksegrp, &rtp); -#else - pri_to_rtp(td, &rtp); -#endif - mtx_unlock_spin(&sched_lock); - switch (rtp.type) - { - case RTP_PRIO_FIFO: - *policy = SCHED_FIFO; - break; - - case RTP_PRIO_REALTIME: - *policy = SCHED_RR; - break; - - default: - *policy = SCHED_OTHER; - break; - } - - return e; -} - -int -ksched_setparam(struct ksched *ksched, - struct thread *td, const struct sched_param *param) -{ - int policy; - int e; - - e = getscheduler(ksched, td, &policy); - - if (e == 0) - { - if (policy == SCHED_OTHER) - e = EINVAL; - else - e = ksched_setscheduler(ksched, td, policy, param); - } - - return e; -} - -int -ksched_getparam(struct ksched *ksched, - struct thread *td, struct sched_param *param) -{ - struct rtprio rtp; - - mtx_lock_spin(&sched_lock); -#ifdef KSE - pri_to_rtp(td->td_ksegrp, &rtp); -#else - pri_to_rtp(td, &rtp); -#endif - mtx_unlock_spin(&sched_lock); - if (RTP_PRIO_IS_REALTIME(rtp.type)) - param->sched_priority = rtpprio_to_p4prio(rtp.prio); - - return 0; -} - -/* - * XXX The priority and scheduler modifications should - * be moved into published interfaces in kern/kern_sync. - * - * The permissions to modify process p were checked in "p31b_proc()". - * - */ -int -ksched_setscheduler(struct ksched *ksched, - struct thread *td, int policy, const struct sched_param *param) -{ - int e = 0; - struct rtprio rtp; -#ifdef KSE - struct ksegrp *kg = td->td_ksegrp; -#endif - - switch(policy) - { - case SCHED_RR: - case SCHED_FIFO: - - if (param->sched_priority >= P1B_PRIO_MIN && - param->sched_priority <= P1B_PRIO_MAX) - { - rtp.prio = p4prio_to_rtpprio(param->sched_priority); - rtp.type = (policy == SCHED_FIFO) - ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; - - mtx_lock_spin(&sched_lock); -#ifdef KSE - rtp_to_pri(&rtp, kg); - FOREACH_THREAD_IN_GROUP(kg, td) { /* XXXKSE */ - if (TD_IS_RUNNING(td)) { - td->td_flags |= TDF_NEEDRESCHED; - } else if (TD_ON_RUNQ(td)) { - if (td->td_priority > kg->kg_user_pri) { - sched_prio(td, kg->kg_user_pri); - } - } - } -#else - rtp_to_pri(&rtp, td); -#endif - mtx_unlock_spin(&sched_lock); - } - else - e = EPERM; - - - break; - - case SCHED_OTHER: - { - rtp.type = RTP_PRIO_NORMAL; - rtp.prio = p4prio_to_rtpprio(param->sched_priority); - mtx_lock_spin(&sched_lock); -#ifdef KSE - rtp_to_pri(&rtp, kg); - - /* XXX Simply revert to whatever we had for last - * normal scheduler priorities. - * This puts a requirement - * on the scheduling code: You must leave the - * scheduling info alone. - */ - FOREACH_THREAD_IN_GROUP(kg, td) { - if (TD_IS_RUNNING(td)) { - td->td_flags |= TDF_NEEDRESCHED; - } else if (TD_ON_RUNQ(td)) { - if (td->td_priority > kg->kg_user_pri) { - sched_prio(td, kg->kg_user_pri); - } - } - - } -#else - rtp_to_pri(&rtp, td); -#endif - mtx_unlock_spin(&sched_lock); - } - break; - - default: - e = EINVAL; - break; - } - - return e; -} - -int -ksched_getscheduler(struct ksched *ksched, struct thread *td, int *policy) -{ - return getscheduler(ksched, td, policy); -} - -/* ksched_yield: Yield the CPU. - */ -int -ksched_yield(struct ksched *ksched) -{ - sched_relinquish(curthread); - return 0; -} - -int -ksched_get_priority_max(struct ksched *ksched, int policy, int *prio) -{ - int e = 0; - - switch (policy) - { - case SCHED_FIFO: - case SCHED_RR: - *prio = RTP_PRIO_MAX; - break; - - case SCHED_OTHER: - *prio = PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE; - break; - - default: - e = EINVAL; - } - - return e; -} - -int -ksched_get_priority_min(struct ksched *ksched, int policy, int *prio) -{ - int e = 0; - - switch (policy) - { - case SCHED_FIFO: - case SCHED_RR: - *prio = P1B_PRIO_MIN; - break; - - case SCHED_OTHER: - *prio = 0; - break; - - default: - e = EINVAL; - } - - return e; -} - -int -ksched_rr_get_interval(struct ksched *ksched, - struct thread *td, struct timespec *timespec) -{ - *timespec = ksched->rr_interval; - - return 0; -} diff --git a/sys/posix4/ksem.h b/sys/posix4/ksem.h deleted file mode 100644 index 71979da328bb..000000000000 --- a/sys/posix4/ksem.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2002 Alfred Perlstein - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _POSIX4_KSEM_H_ -#define _POSIX4_KSEM_H_ - -#ifndef _KERNEL -#error "no user-servicable parts inside" -#endif - -#include -#include - -struct kuser { - pid_t ku_pid; - LIST_ENTRY(kuser) ku_next; -}; - -struct ksem { - LIST_ENTRY(ksem) ks_entry; /* global list entry */ - int ks_onlist; /* boolean if on a list (ks_entry) */ - char *ks_name; /* if named, this is the name */ - int ks_ref; /* number of references */ - mode_t ks_mode; /* protection bits */ - uid_t ks_uid; /* creator uid */ - gid_t ks_gid; /* creator gid */ - unsigned int ks_value; /* current value */ - struct cv ks_cv; /* waiters sleep here */ - int ks_waiters; /* number of waiters */ - LIST_HEAD(, kuser) ks_users; /* pids using this sem */ - struct label *ks_label; /* MAC label */ -}; - -#endif /* !_POSIX4_KSEM_H_ */ diff --git a/sys/posix4/p1003_1b.c b/sys/posix4/p1003_1b.c deleted file mode 100644 index 8ed0de53af10..000000000000 --- a/sys/posix4/p1003_1b.c +++ /dev/null @@ -1,345 +0,0 @@ -/*- - * Copyright (c) 1996, 1997, 1998 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* p1003_1b: Real Time common code. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_posix.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B"); - -/* The system calls return ENOSYS if an entry is called that is - * not run-time supported. I am also logging since some programs - * start to use this when they shouldn't. That will be removed if annoying. - */ -int -syscall_not_present(struct thread *td, const char *s, struct nosys_args *uap) -{ - log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n", - td->td_proc->p_comm, td->td_proc->p_pid, s); - - /* a " return nosys(p, uap); " here causes a core dump. - */ - - return ENOSYS; -} - -#if !defined(_KPOSIX_PRIORITY_SCHEDULING) - -/* Not configured but loadable via a module: - */ - -static int -sched_attach(void) -{ - return 0; -} - -SYSCALL_NOT_PRESENT_GEN(sched_setparam) -SYSCALL_NOT_PRESENT_GEN(sched_getparam) -SYSCALL_NOT_PRESENT_GEN(sched_setscheduler) -SYSCALL_NOT_PRESENT_GEN(sched_getscheduler) -SYSCALL_NOT_PRESENT_GEN(sched_yield) -SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max) -SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min) -SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval) -#else - -/* Configured in kernel version: - */ -static struct ksched *ksched; - -static int -sched_attach(void) -{ - int ret = ksched_attach(&ksched); - - if (ret == 0) - p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 1); - - return ret; -} - -/* - * MPSAFE - */ -int -sched_setparam(struct thread *td, struct sched_setparam_args *uap) -{ - struct thread *targettd; - struct proc *targetp; - int e; - struct sched_param sched_param; - - e = copyin(uap->param, &sched_param, sizeof(sched_param)); - if (e) - return (e); - - if (uap->pid == 0) { - targetp = td->td_proc; - targettd = td; - PROC_LOCK(targetp); - } else { - targetp = pfind(uap->pid); - if (targetp == NULL) - return (ESRCH); - targettd = FIRST_THREAD_IN_PROC(targetp); - } - - e = p_cansched(td, targetp); - if (e == 0) { - e = ksched_setparam(ksched, targettd, - (const struct sched_param *)&sched_param); - } - PROC_UNLOCK(targetp); - return (e); -} - -/* - * MPSAFE - */ -int -sched_getparam(struct thread *td, struct sched_getparam_args *uap) -{ - int e; - struct sched_param sched_param; - struct thread *targettd; - struct proc *targetp; - - if (uap->pid == 0) { - targetp = td->td_proc; - targettd = td; - PROC_LOCK(targetp); - } else { - targetp = pfind(uap->pid); - if (targetp == NULL) { - return (ESRCH); - } - targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */ - } - - e = p_cansee(td, targetp); - if (e == 0) { - e = ksched_getparam(ksched, targettd, &sched_param); - } - PROC_UNLOCK(targetp); - if (e == 0) - e = copyout(&sched_param, uap->param, sizeof(sched_param)); - return (e); -} - -/* - * MPSAFE - */ -int -sched_setscheduler(struct thread *td, struct sched_setscheduler_args *uap) -{ - int e; - struct sched_param sched_param; - struct thread *targettd; - struct proc *targetp; - - /* Don't allow non root user to set a scheduler policy. */ - e = priv_check(td, PRIV_SCHED_SET); - if (e) - return (e); - - e = copyin(uap->param, &sched_param, sizeof(sched_param)); - if (e) - return (e); - - if (uap->pid == 0) { - targetp = td->td_proc; - targettd = td; - PROC_LOCK(targetp); - } else { - targetp = pfind(uap->pid); - if (targetp == NULL) - return (ESRCH); - targettd = FIRST_THREAD_IN_PROC(targetp); - } - - e = p_cansched(td, targetp); - if (e == 0) { - e = ksched_setscheduler(ksched, targettd, - uap->policy, (const struct sched_param *)&sched_param); - } - PROC_UNLOCK(targetp); - return (e); -} - -/* - * MPSAFE - */ -int -sched_getscheduler(struct thread *td, struct sched_getscheduler_args *uap) -{ - int e, policy; - struct thread *targettd; - struct proc *targetp; - - if (uap->pid == 0) { - targetp = td->td_proc; - targettd = td; - PROC_LOCK(targetp); - } else { - targetp = pfind(uap->pid); - if (targetp == NULL) { - e = ESRCH; - goto done2; - } - targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */ - } - - e = p_cansee(td, targetp); - if (e == 0) { - e = ksched_getscheduler(ksched, targettd, &policy); - td->td_retval[0] = policy; - } - PROC_UNLOCK(targetp); - -done2: - return (e); -} - -/* - * MPSAFE - */ -int -sched_yield(struct thread *td, struct sched_yield_args *uap) -{ - - return (ksched_yield(ksched)); -} - -/* - * MPSAFE - */ -int -sched_get_priority_max(struct thread *td, - struct sched_get_priority_max_args *uap) -{ - int error, prio; - - error = ksched_get_priority_max(ksched, uap->policy, &prio); - td->td_retval[0] = prio; - return (error); -} - -/* - * MPSAFE - */ -int -sched_get_priority_min(struct thread *td, - struct sched_get_priority_min_args *uap) -{ - int error, prio; - - error = ksched_get_priority_min(ksched, uap->policy, &prio); - td->td_retval[0] = prio; - return (error); -} - -/* - * MPSAFE - */ -int -sched_rr_get_interval(struct thread *td, - struct sched_rr_get_interval_args *uap) -{ - struct timespec timespec; - int error; - - error = kern_sched_rr_get_interval(td, uap->pid, ×pec); - if (error == 0) - error = copyout(×pec, uap->interval, sizeof(timespec)); - return (error); -} - -int -kern_sched_rr_get_interval(struct thread *td, pid_t pid, - struct timespec *ts) -{ - int e; - struct thread *targettd; - struct proc *targetp; - - if (pid == 0) { - targettd = td; - targetp = td->td_proc; - PROC_LOCK(targetp); - } else { - targetp = td->td_proc; - PROC_LOCK(targetp); - targettd = thread_find(targetp, pid); - if (targettd == NULL) { - PROC_UNLOCK(targetp); - return (ESRCH); - } - } - - e = p_cansee(td, targetp); - if (e == 0) - e = ksched_rr_get_interval(ksched, targettd, ts); - PROC_UNLOCK(targetp); - return (e); -} - -#endif - -static void -p31binit(void *notused) -{ - (void) sched_attach(); - p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE); -} - -SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL); diff --git a/sys/posix4/posix4.h b/sys/posix4/posix4.h deleted file mode 100644 index 779665d0628a..000000000000 --- a/sys/posix4/posix4.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef _P1003_1B_P1003_1B_H_ -#define _P1003_1B_P1003_1B_H_ -/*- - * Copyright (c) 1996, 1997, 1998 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include - -/* Generate syscall stubs for when something is optionally - * loadable as a module. References "syscall_not_present". - * XXX Good candidate for sys/syscall.h - */ -struct proc; -struct nosys_args; -extern int syscall_not_present(struct thread *, const char *, struct nosys_args *); - -#define SYSCALL_NOT_PRESENT_GEN(SC) \ -int SC (struct thread *td, struct SC##_args *uap) \ -{ \ - return syscall_not_present(td, #SC , (struct nosys_args *)uap); \ -} - - -MALLOC_DECLARE(M_P31B); - -#define p31b_malloc(SIZE) malloc((SIZE), M_P31B, M_WAITOK) -#define p31b_free(P) free((P), M_P31B) - -int p31b_proc(struct proc *, pid_t, struct proc **); - -void p31b_setcfg(int, int); -int p31b_getcfg(int); -int p31b_iscfg(int); - -#ifdef _KPOSIX_PRIORITY_SCHEDULING - -/* - * KSCHED_OP_RW is a vector of read/write flags for each entry indexed - * by the enum ksched_op. - * - * 1 means you need write access, 0 means read is sufficient. - */ - -enum ksched_op { - -#define KSCHED_OP_RW { 1, 0, 1, 0, 0, 0, 0, 0 } - - SCHED_SETPARAM, - SCHED_GETPARAM, - SCHED_SETSCHEDULER, - SCHED_GETSCHEDULER, - SCHED_YIELD, - SCHED_GET_PRIORITY_MAX, - SCHED_GET_PRIORITY_MIN, - SCHED_RR_GET_INTERVAL, - SCHED_OP_MAX -}; - -struct ksched; - -int ksched_attach(struct ksched **); -int ksched_detach(struct ksched *); - -int ksched_setparam(struct ksched *, - struct thread *, const struct sched_param *); -int ksched_getparam(struct ksched *, - struct thread *, struct sched_param *); - -int ksched_setscheduler(struct ksched *, - struct thread *, int, const struct sched_param *); -int ksched_getscheduler(struct ksched *, struct thread *, int *); - -int ksched_yield(struct ksched *); - -int ksched_get_priority_max(struct ksched *, int, int *); -int ksched_get_priority_min(struct ksched *, int, int *); - -int ksched_rr_get_interval(struct ksched *, - struct thread *, struct timespec *); - -#endif /* _KPOSIX_PRIORITY_SCHEDULING */ - -#endif /* _P1003_1B_P1003_1B_H_ */ diff --git a/sys/posix4/posix4_mib.c b/sys/posix4/posix4_mib.c deleted file mode 100644 index 19092164a9ec..000000000000 --- a/sys/posix4/posix4_mib.c +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * Copyright (c) 1998 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -static int facility[CTL_P1003_1B_MAXID - 1]; -static int facility_initialized[CTL_P1003_1B_MAXID - 1]; - -/* OID_AUTO isn't working with sysconf(3). I guess I'd have to - * modify it to do a lookup by name from the index. - * For now I've left it a top-level sysctl. - */ - -#if 1 - -SYSCTL_DECL(_p1003_1b); - -#define P1B_SYSCTL(num, name) \ -SYSCTL_INT(_p1003_1b, num, \ - name, CTLFLAG_RD, facility + num - 1, 0, ""); - -#else - -SYSCTL_DECL(_kern_p1003_1b); - -#define P1B_SYSCTL(num, name) \ -SYSCTL_INT(_kern_p1003_1b, OID_AUTO, \ - name, CTLFLAG_RD, facility + num - 1, 0, ""); -SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B"); - -#endif - -SYSCTL_INT(_p1003_1b, CTL_P1003_1B_ASYNCHRONOUS_IO, \ - asynchronous_io, CTLFLAG_RD, &async_io_version, 0, ""); -P1B_SYSCTL(CTL_P1003_1B_MAPPED_FILES, mapped_files); -P1B_SYSCTL(CTL_P1003_1B_MEMLOCK, memlock); -P1B_SYSCTL(CTL_P1003_1B_MEMLOCK_RANGE, memlock_range); -P1B_SYSCTL(CTL_P1003_1B_MEMORY_PROTECTION, memory_protection); -P1B_SYSCTL(CTL_P1003_1B_MESSAGE_PASSING, message_passing); -P1B_SYSCTL(CTL_P1003_1B_PRIORITIZED_IO, prioritized_io); -P1B_SYSCTL(CTL_P1003_1B_PRIORITY_SCHEDULING, priority_scheduling); -P1B_SYSCTL(CTL_P1003_1B_REALTIME_SIGNALS, realtime_signals); -P1B_SYSCTL(CTL_P1003_1B_SEMAPHORES, semaphores); -P1B_SYSCTL(CTL_P1003_1B_FSYNC, fsync); -P1B_SYSCTL(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, shared_memory_objects); -P1B_SYSCTL(CTL_P1003_1B_SYNCHRONIZED_IO, synchronized_io); -P1B_SYSCTL(CTL_P1003_1B_TIMERS, timers); -P1B_SYSCTL(CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max); -P1B_SYSCTL(CTL_P1003_1B_AIO_MAX, aio_max); -P1B_SYSCTL(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, aio_prio_delta_max); -P1B_SYSCTL(CTL_P1003_1B_DELAYTIMER_MAX, delaytimer_max); -P1B_SYSCTL(CTL_P1003_1B_MQ_OPEN_MAX, mq_open_max); -P1B_SYSCTL(CTL_P1003_1B_PAGESIZE, pagesize); -P1B_SYSCTL(CTL_P1003_1B_RTSIG_MAX, rtsig_max); -P1B_SYSCTL(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max); -P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max); -P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max); -P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max); - -#define P31B_VALID(num) ((num) >= 1 && (num) < CTL_P1003_1B_MAXID) - -/* p31b_setcfg: Set the configuration - */ -void -p31b_setcfg(int num, int value) -{ - - if (P31B_VALID(num)) { - facility[num - 1] = value; - facility_initialized[num - 1] = 1; - } -} - -int -p31b_getcfg(int num) -{ - - if (P31B_VALID(num)) - return (facility[num - 1]); - return (0); -} - -int -p31b_iscfg(int num) -{ - - if (P31B_VALID(num)) - return (facility_initialized[num - 1]); - return (0); -} - -/* - * Turn on indications for standard (non-configurable) kernel features. - */ -static void -p31b_set_standard(void *dummy) -{ - /* ??? p31b_setcfg(CTL_P1003_1B_FSYNC, 1); */ - p31b_setcfg(CTL_P1003_1B_MAPPED_FILES, 1); - p31b_setcfg(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, 1); - p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE); - if (!p31b_iscfg(CTL_P1003_1B_AIO_LISTIO_MAX)) - p31b_setcfg(CTL_P1003_1B_AIO_LISTIO_MAX, -1); - if (!p31b_iscfg(CTL_P1003_1B_AIO_MAX)) - p31b_setcfg(CTL_P1003_1B_AIO_MAX, -1); - if (!p31b_iscfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX)) - p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, -1); -} - -SYSINIT(p31b_set_standard, SI_SUB_P1003_1B, SI_ORDER_ANY, p31b_set_standard, - 0); - diff --git a/sys/posix4/sched.h b/sys/posix4/sched.h deleted file mode 100644 index 92fad6da914d..000000000000 --- a/sys/posix4/sched.h +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * Copyright (c) 1996, 1997 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * and Jukka Antero Ukkonen. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* sched.h: POSIX 1003.1b Process Scheduling header */ - -#ifndef _SCHED_H_ -#define _SCHED_H_ - -#include - -#ifndef _PID_T_DECLARED -typedef __pid_t pid_t; -#define _PID_T_DECLARED -#endif - -/* - * Scheduling policies - */ -#define SCHED_FIFO 1 -#define SCHED_OTHER 2 -#define SCHED_RR 3 - -struct sched_param { - int sched_priority; -}; - -#ifndef _KERNEL -#include - -struct timespec; - -__BEGIN_DECLS -int sched_get_priority_max(int); -int sched_get_priority_min(int); -int sched_getparam(pid_t, struct sched_param *); -int sched_getscheduler(pid_t); -int sched_rr_get_interval(pid_t, struct timespec *); -int sched_setparam(pid_t, const struct sched_param *); -int sched_setscheduler(pid_t, int, const struct sched_param *); -int sched_yield(void); -__END_DECLS - -#endif - -#endif /* !_SCHED_H_ */ diff --git a/sys/posix4/semaphore.h b/sys/posix4/semaphore.h deleted file mode 100644 index 180625221f2e..000000000000 --- a/sys/posix4/semaphore.h +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1996, 1997 - * HD Associates, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by HD Associates, Inc - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL HD ASSOCIATES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* semaphore.h: POSIX 1003.1b semaphores */ - -#ifndef _SEMAPHORE_H_ -#define _SEMAPHORE_H_ - -/* Opaque type definition. */ -struct sem; -typedef struct sem * sem_t; - -#define SEM_FAILED ((sem_t *)0) -#define SEM_VALUE_MAX (~0U) /* Equivalent to UINT_MAX. */ - -#ifndef _KERNEL -#include - -struct timespec; - -__BEGIN_DECLS -int sem_close(sem_t *); -int sem_destroy(sem_t *); -int sem_getvalue(sem_t * __restrict, int * __restrict); -int sem_init(sem_t *, int, unsigned int); -sem_t *sem_open(const char *, int, ...); -int sem_post(sem_t *); -int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict); -int sem_trywait(sem_t *); -int sem_unlink(const char *); -int sem_wait(sem_t *); -__END_DECLS - -#endif - -#endif /* !_SEMAPHORE_H_ */