OLD | NEW |
1 // Use of this source file is governed by a BSD-style | 1 // Use of this source file is governed by a BSD-style |
2 // license that can be found in the LICENSE file.` | 2 // license that can be found in the LICENSE file.` |
3 | 3 |
4 #include "runtime.h" | 4 #include "runtime.h" |
5 #include "defs.h" | 5 #include "defs.h" |
6 #include "signals.h" | 6 #include "signals.h" |
7 #include "os.h" | 7 #include "os.h" |
8 | 8 |
9 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and | 9 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and |
10 // thus the code is largely similar. See linux/thread.c for comments. | 10 // thus the code is largely similar. See linux/thread.c for comments. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 notewakeup(Note *n) | 118 notewakeup(Note *n) |
119 { | 119 { |
120 umtx_unlock(&n->lock); | 120 umtx_unlock(&n->lock); |
121 } | 121 } |
122 | 122 |
123 void thr_start(void*); | 123 void thr_start(void*); |
124 | 124 |
125 void | 125 void |
126 newosproc(M *m, G *g, void *stk, void (*fn)(void)) | 126 newosproc(M *m, G *g, void *stk, void (*fn)(void)) |
127 { | 127 { |
128 » struct thr_param param; | 128 » ThrParam param; |
129 | 129 |
130 USED(fn); // thr_start assumes fn == mstart | 130 USED(fn); // thr_start assumes fn == mstart |
131 USED(g); // thr_start assumes g == m->g0 | 131 USED(g); // thr_start assumes g == m->g0 |
132 | 132 |
133 if(0){ | 133 if(0){ |
134 printf("newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n", | 134 printf("newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n", |
135 stk, m, g, fn, m->id, m->tls[0], &m); | 135 stk, m, g, fn, m->id, m->tls[0], &m); |
136 } | 136 } |
137 | 137 |
138 runtime_memclr((byte*)¶m, sizeof param); | 138 runtime_memclr((byte*)¶m, sizeof param); |
139 | 139 |
140 param.start_func = thr_start; | 140 param.start_func = thr_start; |
141 param.arg = m; | 141 param.arg = m; |
142 param.stack_base = stk; | 142 param.stack_base = stk; |
143 param.stack_size = g->stackbase - g->stackguard + 256; | 143 param.stack_size = g->stackbase - g->stackguard + 256; |
144 » param.child_tid = (int64*)&m->procid; | 144 » param.child_tid = (int32*)&m->procid; |
145 param.parent_tid = nil; | 145 param.parent_tid = nil; |
| 146 param.tls_base = (int8*)&m->tls[0]; |
| 147 param.tls_size = sizeof m->tls; |
| 148 |
| 149 m->tls[0] = m->id; // so 386 asm can find it |
146 | 150 |
147 thr_new(¶m, sizeof param); | 151 thr_new(¶m, sizeof param); |
148 } | 152 } |
149 | 153 |
150 void | 154 void |
151 osinit(void) | 155 osinit(void) |
152 { | 156 { |
153 } | 157 } |
154 | 158 |
155 // Called to initialize a new m (including the bootstrap m). | 159 // Called to initialize a new m (including the bootstrap m). |
156 void | 160 void |
157 minit(void) | 161 minit(void) |
158 { | 162 { |
159 // Initialize signal handling | 163 // Initialize signal handling |
160 m->gsignal = malg(32*1024); | 164 m->gsignal = malg(32*1024); |
161 signalstack(m->gsignal->stackguard, 32*1024); | 165 signalstack(m->gsignal->stackguard, 32*1024); |
162 } | 166 } |
OLD | NEW |