/*
Copyright (c) 1993 Xerox Corporation.  All rights reserved.
*/
/*
$Id$

$Date$
 *
 * PCR Threads Critical Section support.
 *
 */


#ifndef	←←PCR←ThCrSec←h
#define ←←PCR←ThCrSec←h 1


#include <config/PCR←StdTypes.h>


#define PCR←ThCrSec←DEBUG 1

#if PCR←ThCrSec←DEBUG
    extern void PCR←ThCrSec←Oops();
#endif

/*
 * Lib critical sections (for calling async-unsafe procedures):
 *
 *   Sig handlers are not invoked.
 *   No preemption occurs.
 *   Voluntary thread switching is allowed.
 *   Multiple processors may be in lib critical sections
 *     concurrently.
 *   
 *
 * Sys critical sections (system implementation use only):
 *
 *   Sig handlers are not invoked.
 *   No preemption occurs.
 *   Voluntary thread switching is allowed.
 *   Mutual exclusion between processors.
 *
 */



/*
 * CrSec procs
 */


extern void
PCR←ThCrSec←EnterSys(void);
/*
    Enter a critical section.
*/




extern void
PCR←ThCrSec←ExitSys(void);
/*
    Leave a sys critical section, and if not nested do any
      deferred actions.
*/



extern PCR←Bool
PCR←ThCrSec←InSysCrSec(void);
/*
    Test whether currently in a critical section.
*/


extern PCR←Bool
PCR←ThCrSec←InSysCrSecs(void);
/*
    Test whether in a nested critical section.
*/


/*
 * Lib CrSec procs -- analogous to sys CrSec procs
 */


extern void
PCR←ThCrSec←EnterLib(void);

extern void
PCR←ThCrSec←ExitLib(void);

extern PCR←Bool
PCR←ThCrSec←InLibCrSec(void);

extern PCR←Bool
PCR←ThCrSec←InLibCrSecs(void);


/*
 * Common stuff to record arrival of signals
 *   in critical sections where preemption is disabled ...
 */

extern void
PCR←ThCrSec←MustCheckSigs(void);
/*
    Arrange to check for arrival of signals
      the next time we leave a sys or lib critical section.
*/



extern void
PCR←ThCrSec←MustYield(void);
/*
    Arrange for a reschedule (preemption)
      the next time we leave a sys critical section.
*/


/*
 * Inline all this stuff ...
 */

#if !defined(←←PCR←ThCrSecInlines←h) && !defined(PCR←ThCrSec←NINLINES)
#   include <th/PCR←ThCrSecInlines.h>
#endif

#endif /* ! ←←PCR←ThCrSec←h */

/*
$Log$
*/