1 // Copyright 2012 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.
17 // Record pid and tid of init thread for use during test.
18 // The call to LockOSThread is just to exercise it;
19 // we can't test that it does anything.
20 // Instead we're testing that the conditions are good
21 // for how it is used in init (must be on main thread).
22 pid
, tid
= syscall
.Getpid(), syscall
.Gettid()
25 sysNanosleep
= func(d time
.Duration
) {
26 // Invoke a blocking syscall directly; calling time.Sleep()
27 // would deschedule the goroutine instead.
28 ts
:= syscall
.NsecToTimespec(d
.Nanoseconds())
30 if err
:= syscall
.Nanosleep(&ts
, &ts
); err
!= syscall
.EINTR
{
37 func TestLockOSThread(t
*testing
.T
) {
39 t
.Fatalf("pid=%d but tid=%d", pid
, tid
)