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/pipe.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 /* $NetBSD: pipe.h,v 1.13 2003/02/12 21:54:15 pk Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1996 John S. Dyson
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice immediately at the beginning of the file, without modification,
   12  *    this list of conditions, and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. Absolutely no warranty of function or purpose is made by the author
   17  *    John S. Dyson.
   18  * 4. This work was done expressly for inclusion into FreeBSD.  Other use
   19  *    is allowed if this notation is included.
   20  * 5. Modifications may be freely made to this file if the above conditions
   21  *    are met.
   22  *
   23  * $FreeBSD: src/sys/sys/pipe.h,v 1.18 2002/02/27 07:35:59 alfred Exp $
   24  */
   25 
   26 #ifndef _SYS_PIPE_H_
   27 #define _SYS_PIPE_H_
   28 
   29 #ifndef _KERNEL
   30 #include <sys/select.h>                 /* for struct selinfo */
   31 #endif
   32 
   33 /*
   34  * Pipe buffer size, keep moderate in value, pipes take kva space.
   35  */
   36 #ifndef PIPE_SIZE
   37 #define PIPE_SIZE       16384
   38 #endif
   39 
   40 #ifndef BIG_PIPE_SIZE
   41 #define BIG_PIPE_SIZE   (4*PIPE_SIZE)
   42 #endif
   43 
   44 /*
   45  * Maximum size of kva for direct write transfer. If the amount
   46  * of data in buffer is larger, it would be transferred in chunks of this
   47  * size. This kva memory is freed after use if amount of pipe kva memory
   48  * is bigger than limitpipekva.
   49  */
   50 #ifndef PIPE_DIRECT_CHUNK
   51 #define PIPE_DIRECT_CHUNK       (1*1024*1024)
   52 #endif
   53 
   54 /*
   55  * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger
   56  * than PIPE_BUF.
   57  */
   58 #ifndef PIPE_MINDIRECT
   59 #define PIPE_MINDIRECT  8192
   60 #endif
   61 
   62 /*
   63  * Pipe buffer information.
   64  * Separate in, out, cnt are used to simplify calculations.
   65  * Buffered write is active when the buffer.cnt field is set.
   66  */
   67 struct pipebuf {
   68         size_t  cnt;            /* number of chars currently in buffer */
   69         u_int   in;             /* in pointer */
   70         u_int   out;            /* out pointer */
   71         size_t  size;           /* size of buffer */
   72         caddr_t buffer;         /* kva of buffer */
   73 };
   74 
   75 /*
   76  * Information to support direct transfers between processes for pipes.
   77  */
   78 struct pipemapping {
   79         vaddr_t         kva;            /* kernel virtual address */
   80         vsize_t         cnt;            /* number of chars in buffer */
   81         voff_t          pos;            /* current position within page */
   82         int             npages;         /* how many pages allocated */
   83         struct vm_page  **pgs;          /* pointers to the pages */
   84 };
   85 
   86 /*
   87  * Bits in pipe_state.
   88  */
   89 #define PIPE_ASYNC      0x001   /* Async I/O */
   90 #define PIPE_WANTR      0x002   /* Reader wants some characters */
   91 #define PIPE_WANTW      0x004   /* Writer wants space to put characters */
   92 #define PIPE_WANTCLOSE  0x008   /* Pipe is wanted to be run-down */
   93 #define PIPE_EOF        0x010   /* Pipe is in EOF condition */
   94 #define PIPE_SIGNALR    0x020   /* Do selwakeup() on read(2) */
   95 #define PIPE_DIRECTW    0x040   /* Pipe in direct write mode setup */
   96 #define PIPE_DIRECTR    0x080   /* Pipe direct read request (setup complete) */
   97 
   98 /*
   99  * Per-pipe data structure.
  100  * Two of these are linked together to produce bi-directional pipes.
  101  */
  102 struct pipe {
  103         struct  simplelock pipe_slock;  /* pipe mutex */
  104         struct  lock pipe_lock;         /* long-term pipe lock */
  105         struct  pipebuf pipe_buffer;    /* data storage */
  106         struct  pipemapping pipe_map;   /* pipe mapping for direct I/O */
  107         struct  selinfo pipe_sel;       /* for compat with select */
  108         struct  timeval pipe_atime;     /* time of last access */
  109         struct  timeval pipe_mtime;     /* time of last modify */
  110         struct  timeval pipe_ctime;     /* time of status change */
  111         pid_t   pipe_pgid;              /* process group for sigio */
  112         struct  pipe *pipe_peer;        /* link with other direction */
  113         u_int   pipe_state;             /* pipe status info */
  114         int     pipe_busy;              /* busy flag, mostly to handle rundown sanely */
  115 };
  116 
  117 /*
  118  * KERN_PIPE subtypes
  119  */
  120 #define KERN_PIPE_MAXKVASZ              1       /* maximum kva size */
  121 #define KERN_PIPE_LIMITKVA              2       /* */
  122 #define KERN_PIPE_MAXBIGPIPES           3       /* maximum # of "big" pipes */
  123 #define KERN_PIPE_NBIGPIPES             4       /* current number of "big" p. */
  124 #define KERN_PIPE_KVASIZE               5       /* current pipe kva size */
  125 #define KERN_PIPE_MAXID                 6
  126 
  127 #define CTL_PIPE_NAMES { \
  128         { 0, 0 }, \
  129         { "maxkvasz", CTLTYPE_INT }, \
  130         { "maxloankvasz", CTLTYPE_INT }, \
  131         { "maxbigpipes", CTLTYPE_INT }, \
  132         { "nbigpipes", CTLTYPE_INT }, \
  133         { "kvasize", CTLTYPE_INT }, \
  134 }
  135 
  136 #ifdef _KERNEL
  137 void pipe_init __P((void));
  138 int sysctl_dopipe __P((int *, u_int, void *, size_t *, void *, size_t));
  139 
  140 #define PIPE_LOCK(pipe)         simple_lock(&(pipe)->pipe_slock);
  141 #define PIPE_UNLOCK(pipe)       simple_unlock(&(pipe)->pipe_slock);
  142 
  143 #endif /* _KERNEL */
  144 #endif /* !_SYS_PIPE_H_ */

Cache object: deff3c8329dcdbb8cc72ef68f0f60d00


[ 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.