Print this page
8115 parallel zfs mount
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libfakekernel/common/thread.c
+++ new/usr/src/lib/libfakekernel/common/thread.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
14 + * Copyright 2017 RackTop Systems.
14 15 */
15 16
16 17 #include <sys/cmn_err.h>
17 18 #include <sys/thread.h>
18 19 #include <sys/zone.h>
20 +#include <sys/proc.h>
19 21
20 22 #define _SYNCH_H /* keep out <synch.h> */
21 23 #include <thread.h>
22 24
23 25 /*
24 26 * Get the current kthread_t pointer.
25 27 */
26 28 kthread_t *
27 29 _curthread(void)
28 30 {
29 31 thread_t tid;
30 32
31 33 tid = thr_self();
32 34 return ((kthread_t *)(uintptr_t)tid);
33 35 }
34 36
35 37 /*
36 38 * Create a thread.
37 39 *
38 40 * thread_create() blocks for memory if necessary. It never fails.
39 41 */
40 42 /* ARGSUSED */
41 43 kthread_t *
42 44 thread_create(
43 45 caddr_t stk,
44 46 size_t stksize,
45 47 void (*func)(),
46 48 void *arg,
47 49 size_t len,
48 50 struct proc *pp,
49 51 int state,
50 52 pri_t pri)
51 53 {
52 54 void * (*thr_func)(void *);
53 55 thread_t newtid;
54 56 int thr_flags = 0;
55 57 int rc;
56 58
57 59 thr_flags = THR_BOUND;
58 60
59 61 switch (state) {
60 62 case TS_RUN:
61 63 case TS_ONPROC:
62 64 break;
63 65 case TS_STOPPED:
64 66 thr_flags |= THR_SUSPENDED;
65 67 break;
66 68 default:
67 69 cmn_err(CE_PANIC, "thread_create: invalid state");
68 70 break;
69 71 }
70 72
71 73 thr_func = (void *(*)(void *))func;
72 74 rc = thr_create(NULL, 0, thr_func, arg, thr_flags, &newtid);
73 75 if (rc != 0)
74 76 cmn_err(CE_PANIC, "thread_create failed, rc=%d", rc);
75 77
76 78 return ((void *)(uintptr_t)newtid);
77 79 }
78 80
79 81 void
80 82 thread_exit(void)
81 83 {
82 84 thr_exit(NULL);
83 85 }
84 86
85 87 void
86 88 thread_join(kt_did_t id)
87 89 {
88 90 thread_t thr_id;
89 91
90 92 thr_id = (thread_t)id;
91 93 (void) thr_join(thr_id, NULL, NULL);
92 94 }
93 95
94 96 void
95 97 tsignal(kthread_t *kt, int sig)
96 98 {
97 99 thread_t tid = (thread_t)(uintptr_t)kt;
98 100
99 101 (void) thr_kill(tid, sig);
100 102 }
101 103
102 104
103 105 /*ARGSUSED*/
104 106 kthread_t *
105 107 zthread_create(
106 108 caddr_t stk,
107 109 size_t stksize,
108 110 void (*func)(),
109 111 void *arg,
110 112 size_t len,
111 113 pri_t pri)
112 114 {
113 115 kthread_t *t;
114 116
↓ open down ↓ |
86 lines elided |
↑ open up ↑ |
115 117 t = thread_create(stk, stksize, func, arg, len, NULL, TS_RUN, pri);
116 118
117 119 return (t);
118 120 }
119 121
120 122 void
121 123 zthread_exit(void)
122 124 {
123 125 thread_exit();
124 126 /* NOTREACHED */
127 +}
128 +
129 +void
130 +tsd_create(uint_t *keyp, void (*destructor)(void *))
131 +{
132 + VERIFY0(thr_keycreate(keyp, destructor));
133 +}
134 +
135 +/*ARGSUSED*/
136 +void
137 +tsd_destroy(uint_t *keyp)
138 +{}
139 +
140 +void *
141 +tsd_get(uint_t key)
142 +{
143 + void *value;
144 +
145 + return (thr_getspecific(key, &value) ? NULL : value);
146 +}
147 +
148 +int
149 +tsd_set(uint_t key, void *value)
150 +{
151 + return (thr_setspecific(key, value));
125 152 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX