On Sat, Mar 23, 2024 at 11:58 AM Wen Wei <ay1101140...@gmail.com> wrote: > > 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?
It does seem possible. Ian -- 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/CAOyqgcV7KUfBVDGOx4Rwu7qHaZgGcMOMMb_y7%2BoiDTAKo2f_eA%40mail.gmail.com.