Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nathanw_sa]: src User-level support for LWPs and scheduler activations.
details: https://anonhg.NetBSD.org/src/rev/2b096c07e8e0
branches: nathanw_sa
changeset: 504563:2b096c07e8e0
user: nathanw <nathanw%NetBSD.org@localhost>
date: Mon Mar 05 23:33:26 2001 +0000
description:
User-level support for LWPs and scheduler activations.
SVR4-style ucontext code by Klaus Klein.
diffstat:
include/Makefile | 7 +-
include/lwp.h | 57 +++++++++++++
include/sa.h | 58 +++++++++++++
include/ucontext.h | 56 ++++++++++++
lib/libc/arch/i386/gen/Makefile.inc | 15 ++-
lib/libc/arch/i386/gen/_context_u.S | 89 ++++++++++++++++++++
lib/libc/arch/i386/gen/_lwp.c | 31 +++++++
lib/libc/arch/i386/gen/makecontext.c | 96 ++++++++++++++++++++++
lib/libc/arch/i386/gen/resumecontext.S | 71 ++++++++++++++++
lib/libc/arch/i386/gen/swapcontext.S | 79 ++++++++++++++++++
lib/libc/arch/i386/sys/getcontext.S | 57 +++++++++++++
lib/libc/gen/Lint_resumecontext.c | 14 +++
lib/libc/gen/Lint_swapcontext.c | 18 ++++
lib/libc/include/extern.h | 3 +-
lib/libc/include/namespace.h | 3 +-
lib/libc/sys/Lint_getcontext.c | 17 +++
lib/libc/sys/Makefile.inc | 26 ++++-
lib/libc/sys/_getcontext.c | 47 ++++++++++
lib/libc/sys/getcontext.2 | 144 +++++++++++++++++++++++++++++++++
19 files changed, 871 insertions(+), 17 deletions(-)
diffs (truncated from 1079 to 300 lines):
diff -r e9ecca3edc0d -r 2b096c07e8e0 include/Makefile
--- a/include/Makefile Mon Mar 05 23:06:16 2001 +0000
+++ b/include/Makefile Mon Mar 05 23:33:26 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.95 2001/02/17 12:29:45 ragge Exp $
+# $NetBSD: Makefile,v 1.95.2.1 2001/03/05 23:33:26 nathanw Exp $
# @(#)Makefile 8.2 (Berkeley) 1/4/94
# Doing a make includes builds /usr/include
@@ -10,13 +10,14 @@
getopt.h glob.h grp.h hesiod.h ifaddrs.h \
iso646.h kvm.h langinfo.h libgen.h \
limits.h link.h link_aout.h link_elf.h locale.h \
- login_cap.h malloc.h math.h md4.h md5.h \
+ login_cap.h lwp.h malloc.h math.h md4.h md5.h \
memory.h mpool.h ndbm.h netconfig.h netdb.h netgroup.h nlist.h \
nl_types.h \
nsswitch.h paths.h pwd.h ranlib.h re_comp.h regex.h regexp.h \
resolv.h rmd160.h rmt.h search.h setjmp.h sgtty.h signal.h stab.h \
+ sa.h \
stddef.h stdio.h stdlib.h string.h strings.h stringlist.h struct.h \
- sysexits.h tar.h time.h ttyent.h tzfile.h ulimit.h unistd.h util.h \
+ sysexits.h tar.h time.h ttyent.h tzfile.h ucontext.h ulimit.h unistd.h util.h \
utime.h utmp.h vis.h wchar.h wctype.h
INCS+= arpa/ftp.h arpa/inet.h arpa/nameser.h arpa/telnet.h arpa/tftp.h
INCS+= protocols/dumprestore.h protocols/routed.h protocols/rwhod.h \
diff -r e9ecca3edc0d -r 2b096c07e8e0 include/lwp.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/lwp.h Mon Mar 05 23:33:26 2001 +0000
@@ -0,0 +1,57 @@
+/* $NetBSD: lwp.h,v 1.1.2.1 2001/03/05 23:33:26 nathanw Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan Williams.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _LWP_H_
+#define _LWP_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/ucontext.h>
+
+__BEGIN_DECLS
+int _lwp_self(void);
+int _lwp_create(const ucontext_t *, unsigned long, lwpid_t *);
+int _lwp_exit(void);
+int _lwp_wait(lwpid_t, lwpid_t *);
+int _lwp_suspend(lwpid_t);
+int _lwp_continue(lwpid_t);
+void _lwp_makecontext(ucontext_t *, void (*)(void *), void *, void *,
+ caddr_t, size_t);
+__END_DECLS
+
+#endif /* !_LWP_H_ */
diff -r e9ecca3edc0d -r 2b096c07e8e0 include/sa.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/sa.h Mon Mar 05 23:33:26 2001 +0000
@@ -0,0 +1,58 @@
+/* $NetBSD: sa.h,v 1.1.2.1 2001/03/05 23:33:26 nathanw Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan Williams.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _SA_H_
+#define _SA_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <sys/sa.h>
+
+
+__BEGIN_DECLS
+int sa_register(sa_upcall_t, sa_upcall_t *);
+int sa_stacks(int, stack_t *);
+size_t sa_getstacksize(void);
+int sa_enable(void);
+int sa_setconcurrency(int);
+int sa_yield(void);
+int sa_preempt(int);
+__END_DECLS
+
+#endif /* !_LWP_H_ */
diff -r e9ecca3edc0d -r 2b096c07e8e0 include/ucontext.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/ucontext.h Mon Mar 05 23:33:26 2001 +0000
@@ -0,0 +1,56 @@
+/* $NetBSD: ucontext.h,v 1.1.2.1 2001/03/05 23:33:27 nathanw Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _UCONTEXT_H_
+#define _UCONTEXT_H_
+
+#include <sys/cdefs.h>
+#include <sys/ucontext.h>
+
+__BEGIN_DECLS
+int getcontext(ucontext_t *);
+int setcontext(const ucontext_t *);
+void makecontext(ucontext_t *, void (*)(), int, ...);
+int swapcontext(ucontext_t *, const ucontext_t *);
+int _getcontext_u(ucontext_t *);
+int _setcontext_u(const ucontext_t *);
+int _swapcontext_u(ucontext_t *, const ucontext_t *);
+
+__END_DECLS
+
+#endif /* !_UCONTEXT_H_ */
diff -r e9ecca3edc0d -r 2b096c07e8e0 lib/libc/arch/i386/gen/Makefile.inc
--- a/lib/libc/arch/i386/gen/Makefile.inc Mon Mar 05 23:06:16 2001 +0000
+++ b/lib/libc/arch/i386/gen/Makefile.inc Mon Mar 05 23:33:26 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.11 2000/12/13 07:42:48 matt Exp $
+# $NetBSD: Makefile.inc,v 1.11.2.1 2001/03/05 23:34:36 nathanw Exp $
# objects built from assembler sources (need lint stubs)
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S modf.S \
@@ -9,8 +9,13 @@
SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
+SRCS+= resumecontext.S swapcontext.S
+SRCS+= _context_u.S
+
# objects built from C sources
-SRCS+= bswap64.c frexp.c infinity.c isinf.c isnan.c ldexp.c nanf.c
+SRCS+= bswap64.c frexp.c infinity.c isinf.c isnan.c ldexp.c nanf.c _lwp.c
+
+SRCS+= makecontext.c
# "internal" objects (don't provide part of the user-visible API)
SRCS+= divsi3.S fixdfsi.S fixunsdfsi.S udivsi3.S
@@ -19,9 +24,11 @@
Lint_fabs.c Lint_modf.c \
Lint___setjmp14.c Lint___sigsetjmp14.c Lint_flt_rounds.c \
Lint_fpgetmask.c Lint_fpgetround.c Lint_fpgetsticky.c \
- Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c
+ Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c \
+ Lint_resumecontext.c Lint_swapcontext.c
DPSRCS+= Lint__setjmp.c Lint_alloca.c Lint_bswap16.c Lint_bswap32.c \
Lint_fabs.c Lint_modf.c \
Lint___setjmp14.c Lint___sigsetjmp14.c Lint_flt_rounds.c \
Lint_fpgetmask.c Lint_fpgetround.c Lint_fpgetsticky.c \
- Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c
+ Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c \
+ Lint_resumecontext.c Lint_swapcontext.c
diff -r e9ecca3edc0d -r 2b096c07e8e0 lib/libc/arch/i386/gen/_context_u.S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/arch/i386/gen/_context_u.S Mon Mar 05 23:33:26 2001 +0000
@@ -0,0 +1,89 @@
+/* $NetBSD: _context_u.S,v 1.1.2.1 2001/03/05 23:34:36 nathanw Exp $ */
+
+/*
+ * Copyright
+ */
+
+#include <machine/asm.h>
+
+#if defined(SYSLIBC_SCCS) && !defined(lint)
+ RCSID("$NetBSD: _context_u.S,v 1.1.2.1 2001/03/05 23:34:36 nathanw Exp $")
+#endif /* SYSLIBC_SCCS && !lint */
+
+#define GETC \
+ movl %gs, %eax ; \
+ movl %eax, 36(%ecx) ; \
+ movl %fs, %eax ; \
+ movl %eax, 40(%ecx) ; \
+ movl %es, %eax ; \
+ movl %eax, 44(%ecx) ; \
+ movl %ds, %eax ; \
+ movl %eax, 48(%ecx) ; \
+ movl %edi, 52(%ecx) ; \
+ movl %esi, 56(%ecx) ; \
+ movl %ebp, 60(%ecx) ; \
+ movl $0, 64(%ecx) ; \
+ movl %ebx, 68(%ecx) ; \
+ movl $0, 72(%ecx) ; \
+ movl $0, 76(%ecx) ; \
+ movl $0, 80(%ecx) ; \
+ movl $0, 84(%ecx) ; \
+ movl $0, 88(%ecx) ; \
+ movl %edx, 92(%ecx) ; \
+ movl %cs, %eax ; \
+ movl %eax, 96(%ecx) ; \
+ pushfl ; \
+ popl %eax ; \
+ movl %eax, 100(%ecx) ; \
+ movl %ss, %eax ; \
+ movl %eax, 108(%ecx) ; \
+ movl $4, %eax ; \
+ movl %eax, 0(%ecx)
+
+#define SETC \
+ movl 36(%ecx), %gs ; \
+ movl 40(%ecx), %fs ; \
+ movl 44(%ecx), %es ; \
+ movl 52(%ecx), %edi ; \
+ movl 56(%ecx), %esi ; \
+ movl 60(%ecx), %ebp ; \
Home |
Main Index |
Thread Index |
Old Index