lwp: remove preemption support 49/11649/7
authorChas Williams (CONTRACTOR) <chas@cmf.nrl.navy.mil>
Tue, 23 Dec 2014 15:39:10 +0000 (10:39 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 5 May 2016 16:51:14 +0000 (12:51 -0400)
This feature of lwp is basically unused and inconsistently implemented.

Change-Id: Icf5c04b3bbd71af2c3d1b22dc4bfbe051952d80b
Reviewed-on: https://gerrit.openafs.org/11649
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

doc/protocol/rx-spec.h
src/WINNT/install/wix/files.wxi
src/lwp/Makefile.in
src/lwp/NTMakefile
src/lwp/lwp.c
src/lwp/preempt.c [deleted file]
src/lwp/preempt.h [deleted file]
src/lwp/rw.c
src/packaging/RedHat/openafs.spec.in

index 9a243b8..f8e42c1 100644 (file)
  * taking place. This is useful if you are using another package that uses the
  * fast time facility. 
  * 
- *     \subsection sec2-2-6 Section 2.2.6: Preemption 
- * 
- * \par
- * The preemption package provides a mechanism by which control can pass
- * between lightweight processes without the need for explicit calls to LWP
- * DispatchProcess(). This effect is achieved by periodically interrupting the
- * normal flow of control to check if other (higher priority) procesess are
- * ready to run. 
- * \par
- * The package makes use of the BSD interval timer facilities, and so will
- * cause programs that make their own use of these facilities to malfunction.
- * In particular, use of alarm(3) or explicit handling of SIGALRM is
- * disallowed. Also, calls to sleep(3) may return prematurely. 
- * \par
- * Care should be taken that routines are re-entrant where necessary. In
- * particular, note that stdio(3) is not re-entrant in general, and hence
- * multiple threads performing I/O on the same fiLE structure may function
- * incorrectly. 
- * \par
- * An example pseudocode routine illustrating the use of this preemption
- * facility appears below. 
- * 
- * \code
- * #include <sys/time.h> 
- * #include "preempt.h" 
- *     ...  struct timeval tv; 
- *     LWP_InitializeProcessSupport( ... ); 
- *     tv.tv_sec = 10; 
- *     tv.tv_usec = 0; 
- *     PRE_InitPreempt(&tv); 
- *     PRE_PreemptMe(); ... 
- *     PRE_BeginCritical(); ... 
- *     PRE_EndCritical(); ... 
- *     PRE_EndPreempt(); 
- * \endcode
- * 
  *     \section sec2-3 Section 2.3: Interface Specifications 
  * 
  *     \subsection sec2-3-1 Section 2.3.1: LWP 
index f2fb2d1..fa3ac11 100644 (file)
                             <File Id="fileosithrdnt_H" Name="osithrdn.h" LongName="osithrdnt.h" DiskId="1" src="$(var.IncDir)osithrdnt.h" />
                             <File Id="fileosiutils_H" Name="osiutils.h" LongName="osiutils.h" DiskId="1" src="$(var.IncDir)osiutils.h" /> 
                             <File Id="fileperf_H" Name="perf.h" LongName="perf.h" DiskId="1" src="$(var.IncDir)perf.h" /> 
-                            <File Id="filepreempt_H" Name="preempt.h" LongName="preempt.h" DiskId="1" src="$(var.IncDir)preempt.h" /> 
                             <File Id="filepthread_H" Name="pthread.h" LongName="pthread.h" DiskId="1" src="$(var.IncDir)pthread.h" /> 
                             <File Id="fileroken_common_H" Name="rokencmn.h" LongName="roken-common.h" DiskId="1" src="$(var.IncDir)roken-common.h" />
                             <File Id="fileroken_H" Name="roken.h" LongName="roken.h" DiskId="1" src="$(var.IncDir)roken.h" />
index d65ac5a..dc58574 100644 (file)
@@ -15,7 +15,7 @@ include @TOP_OBJDIR@/src/config/Makefile.lwptool
 DBG=${LWP_DBG}
 OPTMZ=${LWP_OPTMZ}
 
-LIBOBJS=lwp.o process.o iomgr.o timer.o preempt.o \
+LIBOBJS=lwp.o process.o iomgr.o timer.o \
        threadname.o AFS_component_version_number.o
 
 LT_objs = waitkey.lo fasttime.lo lock.lo
@@ -25,7 +25,7 @@ LT_libs = $(MT_LIBS)
 all: liboafs_lwpcompat.la liblwpcompat_pic.la \
        ${TOP_LIBDIR}/liblwp.a depinstall
 
-depinstall: ${TOP_INCDIR}/lock.h ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/preempt.h ${TOP_INCDIR}/timer.h
+depinstall: ${TOP_INCDIR}/lock.h ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/timer.h
 
 ${TOP_LIBDIR}/liblwp.a: liblwp.a
        ${INSTALL_DATA} $? $@
@@ -36,9 +36,6 @@ ${TOP_INCDIR}/lock.h: lock.h
 ${TOP_INCDIR}/lwp.h: lwp.h
        ${INSTALL_DATA} $? $@
 
-${TOP_INCDIR}/preempt.h: preempt.h
-       ${INSTALL_DATA} $? $@
-
 ${TOP_INCDIR}/timer.h: timer.h
        ${INSTALL_DATA} $? $@
 
@@ -182,7 +179,6 @@ process.o   : process.default.s process.i386.s process.amd64.s process.c lwp.o
        esac
 
 iomgr.o                : iomgr.c lwp.h timer.h
-preempt.o      : preempt.c lwp.h preempt.h
 lwp.o          : lwp.c lwp.h
        case "$(SYS_NAME)" in \
                rs_aix*) \
@@ -206,22 +202,20 @@ rw: rw.o liblwp.a $(TOP_LIBDIR)/util.a $(TOP_LIBDIR)/libopr.a
 #
 # Install targets
 #
-install: liblwp.a lock.h lwp.h preempt.h timer.h
+install: liblwp.a lock.h lwp.h timer.h
        ${INSTALL} -d ${DESTDIR}${libdir}
        ${INSTALL} -d ${DESTDIR}${includedir}
        ${INSTALL_DATA} liblwp.a ${DESTDIR}${libdir}/liblwp.a
        ${INSTALL_DATA} ${srcdir}/lock.h ${DESTDIR}${includedir}/lock.h
        ${INSTALL_DATA} ${srcdir}/lwp.h ${DESTDIR}${includedir}/lwp.h
-       ${INSTALL_DATA} ${srcdir}/preempt.h ${DESTDIR}${includedir}/preempt.h
        ${INSTALL_DATA} ${srcdir}/timer.h ${DESTDIR}${includedir}/timer.h
 
-dest: liblwp.a lock.h lwp.h preempt.h timer.h
+dest: liblwp.a lock.h lwp.h timer.h
        ${INSTALL} -d ${DEST}/lib
        ${INSTALL} -d ${DEST}/include
        ${INSTALL_DATA} liblwp.a ${DEST}/lib/liblwp.a
        ${INSTALL_DATA} ${srcdir}/lock.h ${DEST}/include/lock.h
        ${INSTALL_DATA} ${srcdir}/lwp.h ${DEST}/include/lwp.h
-       ${INSTALL_DATA} ${srcdir}/preempt.h ${DEST}/include/preempt.h
        ${INSTALL_DATA} ${srcdir}/timer.h ${DEST}/include/timer.h
 
 buildtools: ${TOP_LIBDIR}/liblwp.a depinstall
index ab6ddf6..816089e 100644 (file)
@@ -28,7 +28,6 @@ LIBFILE = $(DESTDIR)\lib\afslwp.lib
 INCFILES = \
        $(DESTDIR)\include\lock.h \
        $(DESTDIR)\include\lwp.h \
-       $(DESTDIR)\include\preempt.h \
        $(DESTDIR)\include\timer.h
 
 install_headers: $(INCFILES)
index 50228b4..9cf84b9 100644 (file)
@@ -35,9 +35,9 @@ int setlim(int limcon, uchar_t hard, int limit);
 
 #ifndef AFS_ARM_LINUX20_ENV
 #if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
-extern int PRE_Block;          /* from preempt.c */
+int PRE_Block; /* Remnants of preemption support. */
 #else
-extern char PRE_Block;         /* from preempt.c */
+char PRE_Block;        /* Remnants of preemption support. */
 #endif
 #endif
 
diff --git a/src/lwp/preempt.c b/src/lwp/preempt.c
deleted file mode 100644 (file)
index d9e9ec0..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2000, International Business Machines Corporation and others.
- * All Rights Reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License.  For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- */
-
-/*******************************************************************\
-*                                                                  *
-*      Information Technology Center                               *
-*      Carnegie-Mellon University                                  *
-*                                                                  *
-\*******************************************************************/
-#include <afsconfig.h>
-#include <afs/param.h>
-
-#include <roken.h>
-
-
-#include "lwp.h"
-#include "preempt.h"
-
-#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-int PRE_Block = 0;
-
-
-int
-PRE_InitPreempt(struct timeval *slice)
-{
-    return LWP_SUCCESS;
-}
-
-int
-PRE_EndPreempt(void)
-{
-    return LWP_SUCCESS;
-}
-
-#else
-#ifdef HAVE_UCONTEXT_H
-#include <ucontext.h>
-#endif
-
-#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
-int PRE_Block = 0;             /* used in lwp.c and process.s */
-#else
-char PRE_Block = 0;            /* used in lwp.c and process.s */
-#endif
-
-#if HAVE_SIGACTION && defined(SA_SIGINFO)
-static void
-AlarmHandler(int sig, siginfo_t *st, ucontext_t *scp)
-#else
-static void
-AlarmHandler(int sig, int code, struct sigcontext *scp)
-#endif
-{
-    if (PRE_Block == 0 && lwp_cpptr->level == 0) {
-       PRE_BeginCritical();
-#if HAVE_SIGACTION && defined(SA_SIGINFO)
-       sigprocmask(SIG_SETMASK, &scp->uc_sigmask, NULL);
-#else
-       sigsetmask(scp->sc_mask);
-#endif
-       LWP_DispatchProcess();
-       PRE_EndCritical();
-    }
-
-}
-
-int
-PRE_InitPreempt(struct timeval *slice)
-{
-    struct itimerval itv;
-#if HAVE_SIGACTION && defined(SA_SIGINFO)
-    struct sigaction action;
-#else
-    struct sigvec vec;
-#endif
-
-    if (lwp_cpptr == 0)
-       return (LWP_EINIT);
-
-    if (slice == 0) {
-       itv.it_interval.tv_sec = itv.it_value.tv_sec = DEFAULTSLICE;
-       itv.it_interval.tv_usec = itv.it_value.tv_usec = 0;
-    } else {
-       itv.it_interval = itv.it_value = *slice;
-    }
-
-#if HAVE_SIGACTION && defined(SA_SIGINFO)
-    memset(&action, 0, sizeof(action));
-    action.sa_sigaction = AlarmHandler;
-    action.sa_flags = SA_SIGINFO;
-
-    if ((sigaction(SIGALRM, &action, NULL) == -1)
-       || (setitimer(ITIMER_REAL, &itv, NULL) == -1))
-       return (LWP_ESYSTEM);
-#else
-    memset(&vec, 0, sizeof(vec));
-    vec.sv_handler = AlarmHandler;
-    vec.sv_mask = vec.sv_onstack = 0;
-
-    if ((sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1)
-       || (setitimer(ITIMER_REAL, &itv, (struct itimerval *)0) == -1))
-       return (LWP_ESYSTEM);
-#endif
-
-    return (LWP_SUCCESS);
-}
-
-int
-PRE_EndPreempt()
-{
-    struct itimerval itv;
-#if HAVE_SIGACTION && defined(SA_SIGINFO)
-    struct sigaction action;
-#else
-    struct sigvec vec;
-#endif
-
-    if (lwp_cpptr == 0)
-       return (LWP_EINIT);
-
-    itv.it_value.tv_sec = itv.it_value.tv_usec = 0;
-
-#if HAVE_SIGACTION && defined(SA_SIGINFO)
-    memset(&action, 0, sizeof(action));
-    action.sa_handler = SIG_DFL;
-
-    if ((setitimer(ITIMER_REAL, &itv, NULL) == -1)
-       || (sigaction(SIGALRM, &action, NULL) == -1))
-       return (LWP_ESYSTEM);
-
-#else
-    memset(&vec, 0, sizeof(vec));
-    vec.sv_handler = SIG_DFL;
-    vec.sv_mask = vec.sv_onstack = 0;
-
-    if ((setitimer(ITIMER_REAL, &itv, (struct itimerval *)0) == -1)
-       || (sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1))
-       return (LWP_ESYSTEM);
-#endif
-    return (LWP_SUCCESS);
-}
-
-#endif /* AFS_LINUX20_ENV */
diff --git a/src/lwp/preempt.h b/src/lwp/preempt.h
deleted file mode 100644 (file)
index 3703f76..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2000, International Business Machines Corporation and others.
- * All Rights Reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License.  For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- */
-
-/*******************************************************************\
-*                                                                  *
-*      Information Technology Center                               *
-*      Carnegie-Mellon University                                  *
-*                                                                  *
-\*******************************************************************/
-
-#if defined( _WIN32)
-#define PRE_InitPreempt(A)
-#endif
-
-#if defined( _WIN32) || defined(AFS_LINUX20_ENV)
-/* preemption not implemented for win32. Use threads instead. */
-#define PRE_PreemptMe()
-#define PRE_BeginCritical()
-#define PRE_EndCritical()
-#else
-#define PRE_PreemptMe()                lwp_cpptr->level = 0
-#define PRE_BeginCritical()    lwp_cpptr->level++
-#define PRE_EndCritical()      lwp_cpptr->level--
-#endif
-
-#define DEFAULTSLICE   10
index 0e69765..36325fd 100644 (file)
@@ -21,7 +21,6 @@ Created: 11/1/83, J. Rosenberg
 
 #include "lwp.h"
 #include "lock.h"
-#include "preempt.h"
 
 #define DEFAULT_READERS        5
 
@@ -94,7 +93,6 @@ read_process(void *arg)
     printf("\t[Reader %d]\n", *id);
     LWP_DispatchProcess();     /* Just relinquish control for now */
 
-    PRE_PreemptMe();
     for (;;) {
        int i;
 
@@ -108,9 +106,7 @@ read_process(void *arg)
        }
        asleep--;
        for (i = 0; i < 10000; i++);
-       PRE_BeginCritical();
        printf("[%d: %s]\n", *id, Remove(q));
-       PRE_EndCritical();
        ReleaseReadLock(&q->lock);
        LWP_DispatchProcess();
     }
@@ -166,7 +162,6 @@ write_process(void *dummy)
     char **mesg;
 
     printf("\t[Writer]\n");
-    PRE_PreemptMe();
 
     /* Now loop & write data */
     for (mesg = messages; *mesg != 0; mesg++) {
@@ -195,11 +190,9 @@ main(int argc, char **argv)
 {
     int nreaders, i;
     PROCESS pid;
-    afs_int32 interval;                /* To satisfy Brad */
     PROCESS *readers;
     int *readerid;
     PROCESS writer;
-    struct timeval tv;
 
     printf("\n*Readers & Writers*\n\n");
     setbuf(stdout, 0);
@@ -211,15 +204,10 @@ main(int argc, char **argv)
        sscanf(*++argv, "%d", &nreaders);
     printf("[There will be %d readers]\n", nreaders);
 
-    interval = (argc >= 3 ? atoi(*++argv) * 1000 : 50000);
-
     if (argc == 4)
        lwp_debug = 1;
     LWP_InitializeProcessSupport(0, &pid);
     printf("[Support initialized]\n");
-    tv.tv_sec = 0;
-    tv.tv_usec = interval;
-    PRE_InitPreempt(&tv);
 
     /* Initialize queue */
     q = init();
index 2b0bebf..d3261f6 100644 (file)
@@ -1283,7 +1283,6 @@ dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
 %{_includedir}/afs
 %{_includedir}/lock.h
 %{_includedir}/lwp.h
-%{_includedir}/preempt.h
 %{_includedir}/rx
 %{_includedir}/timer.h
 %{_includedir}/ubik.h