Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / lwpctl.h @ 13

History | View | Annotate | Download (3.11 KB)

1 13 up20180614
/*        $NetBSD: lwpctl.h,v 1.4 2008/04/28 20:24:10 martin Exp $        */
2
3
/*-
4
 * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
5
 * All rights reserved.
6
 *
7
 * This code is derived from software contributed to The NetBSD Foundation
8
 * by Andrew Doran.
9
 *
10
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions
12
 * are met:
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in the
17
 *    documentation and/or other materials provided with the distribution.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
 * POSSIBILITY OF SUCH DAMAGE.
30
 */
31
32
#if !defined(_SYS_LWPCTL_H_)
33
#define        _SYS_LWPCTL_H_
34
35
/*
36
 * Note on compatibility:
37
 *
38
 * This must be the same size for both 32 and 64-bit processes, since
39
 * the same format will be used by both.
40
 *
41
 * Removal of unused fields is OK, as long as the change in layout
42
 * does not affect supported fields.
43
 *
44
 * It is OK to add fields to this structure, since the kernel allocates
45
 * the space.  Re-use of fields is more complicated - see the feature
46
 * word passed to the system call.
47
 */
48
typedef struct lwpctl {
49
        volatile int        lc_curcpu;
50
        volatile int        lc_pctr;
51
} lwpctl_t;
52
53
#define        LWPCTL_CPU_NONE                (-1)
54
#define        LWPCTL_CPU_EXITED        (-2)
55
56
#define        LWPCTL_FEATURE_CURCPU        0x00000001
57
#define        LWPCTL_FEATURE_PCTR        0x00000002
58
59
#if defined(_KERNEL)
60
61
#include <sys/mutex.h>
62
63
#include <uvm/uvm_extern.h>
64
65
typedef struct lcpage {
66
        TAILQ_ENTRY(lcpage) lcp_chain;
67
        vaddr_t                lcp_uaddr;
68
        vaddr_t                lcp_kaddr;
69
        u_int                lcp_nfree;
70
        u_int                lcp_rotor;
71
        u_int                lcp_bitmap[1];
72
} lcpage_t;
73
74
typedef struct lcproc {
75
        kmutex_t        lp_lock;
76
        struct uvm_object *lp_uao;
77
        TAILQ_HEAD(,lcpage) lp_pages;
78
        vaddr_t                lp_cur;
79
        vaddr_t                lp_max;
80
        vaddr_t                lp_uva;
81
} lcproc_t;
82
83
#define        LWPCTL_PER_PAGE                ((PAGE_SIZE / sizeof(lwpctl_t)) & ~31)
84
#define        LWPCTL_BITMAP_ENTRIES        (LWPCTL_PER_PAGE >> 5)
85
#define        LWPCTL_BITMAP_SZ        (LWPCTL_BITMAP_ENTRIES * sizeof(u_int))
86
#define        LWPCTL_LCPAGE_SZ        \
87
    (sizeof(lcpage_t) - sizeof(u_int) + LWPCTL_BITMAP_SZ)
88
#define        LWPCTL_UAREA_SZ                \
89
    (round_page(MAX_LWP_PER_PROC * sizeof(lwpctl_t)))
90
91
int        lwp_ctl_alloc(vaddr_t *);
92
void        lwp_ctl_free(lwp_t *);
93
void        lwp_ctl_exit(void);
94
95
#endif /* defined(_KERNEL) */
96
97
#endif /* !_SYS_LWPCTL_H_ */