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>
* 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
<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" />
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
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} $? $@
${TOP_INCDIR}/lwp.h: lwp.h
${INSTALL_DATA} $? $@
-${TOP_INCDIR}/preempt.h: preempt.h
- ${INSTALL_DATA} $? $@
-
${TOP_INCDIR}/timer.h: timer.h
${INSTALL_DATA} $? $@
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*) \
#
# 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
INCFILES = \
$(DESTDIR)\include\lock.h \
$(DESTDIR)\include\lwp.h \
- $(DESTDIR)\include\preempt.h \
$(DESTDIR)\include\timer.h
install_headers: $(INCFILES)
#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
+++ /dev/null
-/*
- * 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 */
+++ /dev/null
-/*
- * 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
#include "lwp.h"
#include "lock.h"
-#include "preempt.h"
#define DEFAULT_READERS 5
printf("\t[Reader %d]\n", *id);
LWP_DispatchProcess(); /* Just relinquish control for now */
- PRE_PreemptMe();
for (;;) {
int i;
}
asleep--;
for (i = 0; i < 10000; i++);
- PRE_BeginCritical();
printf("[%d: %s]\n", *id, Remove(q));
- PRE_EndCritical();
ReleaseReadLock(&q->lock);
LWP_DispatchProcess();
}
char **mesg;
printf("\t[Writer]\n");
- PRE_PreemptMe();
/* Now loop & write data */
for (mesg = messages; *mesg != 0; mesg++) {
{
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);
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();
%{_includedir}/afs
%{_includedir}/lock.h
%{_includedir}/lwp.h
-%{_includedir}/preempt.h
%{_includedir}/rx
%{_includedir}/timer.h
%{_includedir}/ubik.h