]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/kse.h
Add a D_NOGIANT flag which can be set in a struct cdevsw to indicate
[FreeBSD/FreeBSD.git] / sys / sys / kse.h
1 /*
2  * Copyright (C) 2001 Julian Elischer <julian@freebsd.org>
3  * for the FreeBSD Foundation.
4  *
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(s), this list of conditions and the following disclaimer as
12  *    the first lines of this file unmodified other than the possible 
13  *    addition of one or more copyright notices.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice(s), this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28  * DAMAGE.
29  *
30  * $FreeBSD$
31  */
32
33 #ifndef _SYS_KSE_H_
34 #define _SYS_KSE_H_
35
36 #include <machine/kse.h>
37 #include <sys/ucontext.h>
38
39 /*
40  * This file defines the structures needed for communication between
41  * the userland and the kernel when running a KSE-based threading system.
42  * The only programs that should see this file are the UTS and the kernel.
43  */
44 struct kse_mailbox;
45
46 typedef void    kse_func_t(struct kse_mailbox *);
47
48 /*
49  * Thread mailbox.
50  *
51  * This describes a user thread to the kernel scheduler.
52  */
53 struct kse_thr_mailbox {
54         ucontext_t              tm_context;     /* User and machine context */
55         unsigned int            tm_flags;       /* Thread flags */
56         struct kse_thr_mailbox  *tm_next;       /* Next thread in list */
57         void                    *tm_udata;      /* For use by the UTS */
58         int                     tm_spare[8];
59 };
60
61 /*
62  * KSE mailbox.
63  *
64  * Cummunication path between the UTS and the kernel scheduler specific to
65  * a single KSE.
66  */
67 struct kse_mailbox {
68         struct kse_thr_mailbox  *km_curthread;  /* Currently running thread */
69         struct kse_thr_mailbox  *km_completed;  /* Threads back from kernel */
70         sigset_t                km_sigscaught;  /* Caught signals */
71         unsigned int            km_flags;       /* KSE flags */
72         kse_func_t              *km_func;       /* UTS function */
73         stack_t                 km_stack;       /* UTS context */
74         void                    *km_udata;      /* For use by the UTS */
75         int                     tm_spare[8];
76 };
77
78 #ifndef _KERNEL
79 int     kse_create(struct kse_mailbox *, int);
80 int     kse_exit(void);
81 int     kse_release(void);
82 int     kse_thr_interrupt(struct kse_thr_mailbox *);
83 int     kse_wakeup(void);
84 #endif  /* !_KERNEL */
85
86 #endif  /* !_SYS_KSE_H_ */