From: Chas Williams (CONTRACTOR) Date: Tue, 23 Dec 2014 15:39:10 +0000 (-0500) Subject: lwp: remove preemption support X-Git-Tag: upstream/1.8.0_pre1^2~95 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=8c6bfb61922241b06f5c1467f3df0cf70d08e376;p=packages%2Fo%2Fopenafs.git lwp: remove preemption support This feature of lwp is basically unused and inconsistently implemented. Change-Id: Icf5c04b3bbd71af2c3d1b22dc4bfbe051952d80b Reviewed-on: https://gerrit.openafs.org/11649 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- diff --git a/doc/protocol/rx-spec.h b/doc/protocol/rx-spec.h index 9a243b8a1..f8e42c150 100644 --- a/doc/protocol/rx-spec.h +++ b/doc/protocol/rx-spec.h @@ -582,42 +582,6 @@ * 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 - * #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 diff --git a/src/WINNT/install/wix/files.wxi b/src/WINNT/install/wix/files.wxi index f2fb2d1bb..fa3ac11be 100644 --- a/src/WINNT/install/wix/files.wxi +++ b/src/WINNT/install/wix/files.wxi @@ -1482,7 +1482,6 @@ - diff --git a/src/lwp/Makefile.in b/src/lwp/Makefile.in index d65ac5a24..dc585749b 100644 --- a/src/lwp/Makefile.in +++ b/src/lwp/Makefile.in @@ -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 diff --git a/src/lwp/NTMakefile b/src/lwp/NTMakefile index ab6ddf61e..816089eea 100644 --- a/src/lwp/NTMakefile +++ b/src/lwp/NTMakefile @@ -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) diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c index 50228b4c2..9cf84b9a6 100644 --- a/src/lwp/lwp.c +++ b/src/lwp/lwp.c @@ -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 index d9e9ec072..000000000 --- a/src/lwp/preempt.c +++ /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 -#include - -#include - - -#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 -#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 index 3703f761f..000000000 --- a/src/lwp/preempt.h +++ /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 diff --git a/src/lwp/rw.c b/src/lwp/rw.c index 0e69765b5..36325fd4e 100644 --- a/src/lwp/rw.c +++ b/src/lwp/rw.c @@ -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(); diff --git a/src/packaging/RedHat/openafs.spec.in b/src/packaging/RedHat/openafs.spec.in index 2b0bebfb8..d3261f6e7 100644 --- a/src/packaging/RedHat/openafs.spec.in +++ b/src/packaging/RedHat/openafs.spec.in @@ -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