mirror of
https://github.com/golang/go
synced 2024-11-24 22:37:56 -07:00
runtime: openbsd thread tweaks
- Rename sys_sched_yield() to osyield() as this is now defined in asm.h. - Only print kern.rtheads message if rfork_thread() failed with ENOTSUP. - Remove unused variables. R=rsc CC=golang-dev https://golang.org/cl/4973043
This commit is contained in:
parent
45bd7b07e5
commit
8aa2591b13
@ -57,8 +57,8 @@ TEXT runtime·rfork_thread(SB),7,$0
|
|||||||
SYSCALL
|
SYSCALL
|
||||||
JMP -3(PC) // keep exiting
|
JMP -3(PC) // keep exiting
|
||||||
|
|
||||||
TEXT runtime·sys_sched_yield(SB),7,$0
|
TEXT runtime·osyield(SB),7,$0
|
||||||
MOVL $298, AX
|
MOVL $298, AX // sys_sched_yield
|
||||||
SYSCALL
|
SYSCALL
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
@ -9,19 +9,20 @@
|
|||||||
extern SigTab runtime·sigtab[];
|
extern SigTab runtime·sigtab[];
|
||||||
|
|
||||||
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
|
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
|
||||||
extern void runtime·sys_sched_yield(void);
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENOTSUP = 91,
|
||||||
|
};
|
||||||
|
|
||||||
// Basic spinlocks using CAS. We can improve on these later.
|
// Basic spinlocks using CAS. We can improve on these later.
|
||||||
static void
|
static void
|
||||||
lock(Lock *l)
|
lock(Lock *l)
|
||||||
{
|
{
|
||||||
uint32 v;
|
|
||||||
int32 ret;
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(runtime·cas(&l->key, 0, 1))
|
if(runtime·cas(&l->key, 0, 1))
|
||||||
return;
|
return;
|
||||||
runtime·sys_sched_yield();
|
runtime·osyield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ static void
|
|||||||
unlock(Lock *l)
|
unlock(Lock *l)
|
||||||
{
|
{
|
||||||
uint32 v;
|
uint32 v;
|
||||||
int32 ret;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
v = l->key;
|
v = l->key;
|
||||||
@ -103,8 +103,8 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
|
|||||||
|
|
||||||
if((ret = runtime·rfork_thread(flags, stk, m, g, fn)) < 0) {
|
if((ret = runtime·rfork_thread(flags, stk, m, g, fn)) < 0) {
|
||||||
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount() - 1, -ret);
|
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount() - 1, -ret);
|
||||||
|
if (ret == -ENOTSUP)
|
||||||
runtime·printf("runtime: is kern.rthreads disabled?\n");
|
runtime·printf("runtime: is kern.rthreads disabled?\n");
|
||||||
|
|
||||||
runtime·throw("runtime.newosproc");
|
runtime·throw("runtime.newosproc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user