freenode/#clasp - IRC Chatlog
Search
13:51:27
frgo
When readingf the logs I thought it would be good to have a macro AS-CRITICAL-SECTION() that wraps a piece of code into a safeguard thereby guaranteeing that whatever code is in this section is thread-safe. Is that doable at all? How?
13:54:02
Shinmera
There's multiple ways of going about it. One way would be to put up a barrier for all threads on entry, keep all other threads sleeping until you resume.
13:55:32
frgo
Ok, true - that's not what I wanted. I wanted to have a macro that walks code to ensure that every place is treated in an atomic way. Does that sound crazy?
14:20:22
drmeister
I'm switching the GF call-history and specializer-profile update to use 'copy-and-swap'.
15:16:36
drmeister
The question is: about memoizing a new call history entry - I'm using CAS to update the call history. I created a loop where I read the call-history, I generate a new call history and then I use CAS to install the new call history. If the call-history has been updated in the meantime I start from the beginning again.
15:17:29
drmeister
Once I have updated the call-history I recompile and install a new discriminating function.
15:18:43
drmeister
I think I should have a loop within a loop. The outer loop uses CAS to update the discriminating function and the inner loop uses CAS to update the call-history.
15:20:28
drmeister
Thinking that the point of using CAS is to ensure that when I leave this function that memoizes a new call that the discriminator function should be completely up to date.
15:22:11
drmeister
I'm worried about two threads T1 and T2 getting a dispatch-miss at the same time. T1 updates the call history and recompiles a discriminator function but in the meantime T2 updates the call history again and installs a new discriminator function - then T1 overwrites it.
15:23:29
beach
Are you sure you can't get an infinite sequence of first updating the call history and then the discriminating function this way?
15:25:41
drmeister
The inner loop would update the call-history. If the outer loop detects that the discriminator function has changed the outer loop starts again. This time the inner loop detects that the call history already includes the specializers and it returns to the outer loop.
15:28:33
beach
Before, did you mean "copy-and-swap" (A C++ idiom apparently) or "compare-and-swap" (an instruction to help with synchronization)?