FreeBSD/Linux Kernel Cross Reference
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: releng/5.0/sys/sys/kse.h 107034 2002-11-18 01:59:31Z davidxu $
31 */
32
33 #ifndef _SYS_KSE_H_
34 #define _SYS_KSE_H_
35
36 #include <machine/kse.h>
37 #include <sys/ucontext.h>
38 #include <sys/time.h>
39
40 /*
41 * This file defines the structures needed for communication between
42 * the userland and the kernel when running a KSE-based threading system.
43 * The only programs that should see this file are the user thread
44 * scheduler (UTS) and the kernel.
45 */
46 struct kse_mailbox;
47
48 typedef void kse_func_t(struct kse_mailbox *);
49
50 /*
51 * Thread mailbox.
52 *
53 * This describes a user thread to the kernel scheduler.
54 */
55 struct kse_thr_mailbox {
56 ucontext_t tm_context; /* User and machine context */
57 unsigned int tm_flags; /* Thread flags */
58 struct kse_thr_mailbox *tm_next; /* Next thread in list */
59 void *tm_udata; /* For use by the UTS */
60 unsigned int tm_uticks;
61 unsigned int tm_sticks;
62 int tm_spare[8];
63 };
64
65 /*
66 * KSE mailbox.
67 *
68 * Communication path between the UTS and the kernel scheduler specific to
69 * a single KSE.
70 */
71 struct kse_mailbox {
72 int km_version; /* Mailbox version */
73 struct kse_thr_mailbox *km_curthread; /* Currently running thread */
74 struct kse_thr_mailbox *km_completed; /* Threads back from kernel */
75 sigset_t km_sigscaught; /* Caught signals */
76 unsigned int km_flags; /* KSE flags */
77 kse_func_t *km_func; /* UTS function */
78 stack_t km_stack; /* UTS context */
79 void *km_udata; /* For use by the UTS */
80 struct timespec km_timeofday; /* Time of day */
81 int km_spare[8];
82 };
83
84 #define KSE_VER_0 0
85
86 #ifndef _KERNEL
87 int kse_create(struct kse_mailbox *, int);
88 int kse_exit(void);
89 int kse_release(void);
90 int kse_thr_interrupt(struct kse_thr_mailbox *);
91 int kse_wakeup(struct kse_mailbox *);
92 #endif /* !_KERNEL */
93
94 #endif /* !_SYS_KSE_H_ */
Cache object: 86870b6872250bc49faa8bdb6bad75c8
|