[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Error message for the failure to create heartbeat thread is too specific. (#540)

Eliot Miranda notifications at github.com
Mon Dec 21 18:40:52 UTC 2020

Hi David, you say

"Another thing to consider is whether calling pthread_setschedparam()
should be the default ...

My impression is that if I just ignore the warning

"pthread_setschedparam failed: Not owner"

the programs still run fine.

So perhaps the default could be changed NOT to issue a pthread_setschedparam()
and make it optional."

This is not the right solution, but it's a little non-obvious.

What the setschedparam call does is raise the priority of the heartbeat thread relative to the main Smalltalk thread.  Leaving it out means that the heartbeat thread runs at the same priority as the main Smalltalk thread.  The effect of this is that if the main Smalltalk thread runs continuously, for example is in some compute-intensive loop, then the heartbeat thread will be prevented from running, and hence events such as Delay expiry will not be checked for, and the main thread will never be interrupted.  Try something like the following with a heartbeat thread running at the same priority as the main thread running on a single core machine and you'll manifest the issue:

```| p |
p := [| i | i := 0. [(i := i + 1) odd ifTrue: [i := i - 1]] repeat] newProcess.
p forkAt: Processor activePriority - 1.
(Delay forSeconds: 1) wait.
p terminate```

without the heartbeat thread running at a higher priority process p consumes all the processor and the heartbeat thread never gets to run, consequently the Delay forSeconds: 1) wait does not complete and p continues running.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20201221/0e58b1cf/attachment.html>

More information about the Vm-dev mailing list