aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/kse.h
blob: ac58a6c3b63f80a2e2acf508ad68657be80265a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (C) 2001 Julian Elischer <julian@freebsd.org>
 * for the FreeBSD Foundation.
 *
 *  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice(s), this list of conditions and the following disclaimer as
 *    the first lines of this file unmodified other than the possible 
 *    addition of one or more copyright notices.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice(s), this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 * $FreeBSD$
 */

#ifndef SYS_KSE_H
#define SYS_KSE_H
#include <machine/kse.h>
/* 
 * This file defines the structures needed for communication between
 * the userland and the kernel when running a KSE-based threading system.
 * The only programs that should see this file are the UTS and the kernel.
 */
struct kse_mailbox;
typedef void kse_fn_t(struct kse_mailbox *mbx);

/* 
 * Each userland thread has one of these buried in it's 
 * Thread control structure somewhere.
 */
struct thread_mailbox
{
	struct thread_mailbox *next_completed;
	unsigned int	flags;
	void		*UTS_handle;	/* The UTS can use this for anything */
	union kse_td_ctx ctx;		/* thread's saved context goes here. */
};

/* 
 * You need to supply one of these as the argument to the 
 * kse_new() system call.
 */
struct kse_mailbox 
{
	kse_fn_t	*kmbx_upcall;
	char *kmbx_stackbase;
	unsigned long int kmbx_stacksize;
	struct thread_mailbox *kmbx_current_thread;
	struct thread_mailbox *kmbx_completed_threads;
	unsigned int	kmbx_flags;
	void		*kmbx_UTS_handle; /* UTS can use this for anything */
};
#define KEMBXF_CRITICAL 0x00000001

struct kse_global_mailbox
{
	unsigned int	flags;
};
#define GMBXF_CRITICAL 0x00000001

#endif