Re: [golang-dev] Whick lock

135 views
Skip to first unread message

Keith Randall

unread,
Jan 18, 2018, 1:33:58 PM1/18/18
to Filipe Varjão, golang-dev
Just lock(&x) for some lock x should work.
You can declare a lock global variable to use just for yourself.  You could reuse mheap_.lock or some other lock, but only if you know it won't already be acquired when you call it (they aren't reentrant).

acquirem is not a lock, but acquires exclusive access to an M.


On Thu, Jan 18, 2018 at 10:30 AM, Filipe Varjão <varjao...@gmail.com> wrote:
Hi guys, I'm doing some modifications inside the Go's runtime (for research), I need insert some locks.

I saw there is different locks inside go's runtime, like:
lock(&mheap_.lock)
mp := acquirem()
lock(&lock)

All this in different places, but probably for the same purpose (correctness). I saw in the comments justify why the lock is necessary, but not explain why acquirem instead of lock(...) or another one.

I would like some explanation to clarify, if is possible.
My modifications required locks for correctness if there are multiple threads running concurrently during the write barrier. Should I try some of them? or make a new one ?

Many thanks,

F.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Filipe Varjão

unread,
Jan 18, 2018, 1:45:04 PM1/18/18
to Keith Randall, golang-dev
The mheap_.lock is reused in several parts of go's runtime, but nowhere show how to check if they got the lock. How make sure of that ?

Keith Randall

unread,
Jan 18, 2018, 1:48:00 PM1/18/18
to Filipe Varjão, golang-dev
There is no way to check at runtime (or at least, we never do that).  You need to analyze the code to see whether it is safe to use the lock.
 
Reply all
Reply to author
Forward
0 new messages