The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/serialize.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Provides a fast serialization facility that will serialize across blocking
    3  * conditions.  This facility is very similar to a lock but much faster for
    4  * the common case.  It utilizes the atomic_intr_*() functions to acquire
    5  * and release the serializer and token functions to block.
    6  *
    7  * This API is designed to be used whenever low level serialization is
    8  * required.  Unlike tokens this serialization is not safe from deadlocks
    9  * nor is it recursive, and care must be taken when using it. 
   10  */
   11 
   12 #ifndef _SYS_SERIALIZE_H_
   13 #define _SYS_SERIALIZE_H_
   14 
   15 #include <machine/stdint.h>
   16 
   17 struct thread;
   18 
   19 struct lwkt_serialize {
   20     __atomic_intr_t     interlock;
   21     struct thread       *last_td;
   22 };
   23 
   24 #define LWKT_SERIALIZE_INITIALIZER      { 0, NULL }
   25 
   26 #ifdef INVARIANTS
   27 /*
   28  * Note that last_td is only maintained when INVARIANTS is turned on,
   29  * so this check is only useful as part of a [K]KASSERT.
   30  */
   31 #define IS_SERIALIZED(ss)               ((ss)->last_td == curthread)
   32 #endif
   33 
   34 #define ASSERT_SERIALIZED(ss)           KKASSERT(IS_SERIALIZED((ss)))
   35 #define ASSERT_NOT_SERIALIZED(ss)       KKASSERT(!IS_SERIALIZED((ss)))
   36 
   37 typedef struct lwkt_serialize *lwkt_serialize_t;
   38 
   39 void lwkt_serialize_init(lwkt_serialize_t);
   40 void lwkt_serialize_enter(lwkt_serialize_t);
   41 void lwkt_serialize_adaptive_enter(lwkt_serialize_t);
   42 int lwkt_serialize_try(lwkt_serialize_t);
   43 void lwkt_serialize_exit(lwkt_serialize_t);
   44 void lwkt_serialize_handler_disable(lwkt_serialize_t);
   45 void lwkt_serialize_handler_enable(lwkt_serialize_t);
   46 void lwkt_serialize_handler_call(lwkt_serialize_t, void (*)(void *, void *), void *, void *);
   47 int lwkt_serialize_handler_try(lwkt_serialize_t, void (*)(void *, void *), void *, void *);
   48 
   49 #endif  /* !_SYS_SERIALIZE_H_ */

Cache object: 72af034ea0ff19c461078d680c671a64


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.