Lock always calls runtime_SemacquireMutex(&m.sema, queueLifo, 1) -> 
semacquire1 when in starving mode.

```go
// src/runtime/sema.go
func semacquire1(addr *uint32, lifo bool, profile semaProfileFlags, 
skipframes int, reason waitReason) {
gp := getg()
if gp != gp.m.curg {
throw("semacquire not on the G stack")
}

// Easy case.
if cansemacquire(addr) {
return
}

// ...
}

func semrelease1(addr *uint32, handoff bool, skipframes int) {
root := semtable.rootFor(addr)
atomic.Xadd(addr, 1) // The semaphore released here may be immediately 
contended for by goroutines of other threads calling semacquire1.
}
```

Does a new goroutine immediately acquire the lock instead of queuing fairly 
when in starving mode?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/26c7eb2a-f1aa-44ec-9689-381bcd43e484n%40googlegroups.com.

Reply via email to