Black Lives Matter. Support the Equal Justice Initiative.

Source file src/runtime/os_openbsd_syscall.go

Documentation: runtime

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build openbsd && mips64
     6  // +build openbsd,mips64
     7  
     8  package runtime
     9  
    10  import (
    11  	"runtime/internal/sys"
    12  	"unsafe"
    13  )
    14  
    15  //go:noescape
    16  func tfork(param *tforkt, psize uintptr, mm *m, gg *g, fn uintptr) int32
    17  
    18  // May run with m.p==nil, so write barriers are not allowed.
    19  //go:nowritebarrier
    20  func newosproc(mp *m) {
    21  	stk := unsafe.Pointer(mp.g0.stack.hi)
    22  	if false {
    23  		print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " id=", mp.id, " ostk=", &mp, "\n")
    24  	}
    25  
    26  	// Stack pointer must point inside stack area (as marked with MAP_STACK),
    27  	// rather than at the top of it.
    28  	param := tforkt{
    29  		tf_tcb:   unsafe.Pointer(&mp.tls[0]),
    30  		tf_tid:   nil, // minit will record tid
    31  		tf_stack: uintptr(stk) - sys.PtrSize,
    32  	}
    33  
    34  	var oset sigset
    35  	sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
    36  	ret := tfork(&param, unsafe.Sizeof(param), mp, mp.g0, funcPC(mstart))
    37  	sigprocmask(_SIG_SETMASK, &oset, nil)
    38  
    39  	if ret < 0 {
    40  		print("runtime: failed to create new OS thread (have ", mcount()-1, " already; errno=", -ret, ")\n")
    41  		if ret == -_EAGAIN {
    42  			println("runtime: may need to increase max user processes (ulimit -p)")
    43  		}
    44  		throw("runtime.newosproc")
    45  	}
    46  }
    47  

View as plain text