...

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  
     7  package runtime
     8  
     9  import (
    10  	"internal/abi"
    11  	"internal/goarch"
    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  //
    20  //go:nowritebarrier
    21  func newosproc(mp *m) {
    22  	stk := unsafe.Pointer(mp.g0.stack.hi)
    23  	if false {
    24  		print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " id=", mp.id, " ostk=", &mp, "\n")
    25  	}
    26  
    27  	// Stack pointer must point inside stack area (as marked with MAP_STACK),
    28  	// rather than at the top of it.
    29  	param := tforkt{
    30  		tf_tcb:   unsafe.Pointer(&mp.tls[0]),
    31  		tf_tid:   nil, // minit will record tid
    32  		tf_stack: uintptr(stk) - goarch.PtrSize,
    33  	}
    34  
    35  	var oset sigset
    36  	sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
    37  	ret := retryOnEAGAIN(func() int32 {
    38  		errno := tfork(&param, unsafe.Sizeof(param), mp, mp.g0, abi.FuncPCABI0(mstart))
    39  		// tfork returns negative errno
    40  		return -errno
    41  	})
    42  	sigprocmask(_SIG_SETMASK, &oset, nil)
    43  
    44  	if ret != 0 {
    45  		print("runtime: failed to create new OS thread (have ", mcount()-1, " already; errno=", ret, ")\n")
    46  		if ret == _EAGAIN {
    47  			println("runtime: may need to increase max user processes (ulimit -p)")
    48  		}
    49  		throw("runtime.newosproc")
    50  	}
    51  }
    52  

View as plain text