A new version of KernelTests was added to project The Inbox: http://source.squeak.org/inbox/KernelTests-jar.407.mcz
==================== Summary ====================
Name: KernelTests-jar.407 Author: jar Time: 31 May 2021, 11:19:58.858017 pm UUID: 8bb4554a-971d-ea49-9396-6a0c1625fb5b Ancestors: KernelTests-nice.404
Add a test #testTerminateInEnsure presented by Martin McClure at 2019 Smalltalk conference. Test unwind when a process gets terminated inside the #ensure unwind block. Complement latest #terminate in the Inbox.
Supersede KernelTests-jar.405 - fix underscores from Cuis
=============== Diff against KernelTests-nice.404 ===============
Item was added: + ----- Method: ProcessTest>>testTerminateInEnsure (in category 'tests') ----- + testTerminateInEnsure + "As shown in + Martin McClure's 'Threads, Critical Sections, and Termination' (Smalltalks 2019 conference) + https://youtu.be/AvM5YrjK9AE + at 23:17 + self new testTerminateInEnsure + " + | process count random delay | + random := Random new. + 10 timesRepeat: [ + process := [ + count := 0. + [] ensure: [ + 10 timesRepeat: [ + count := count + 1. + 1000000 timesRepeat: [12 factorial]]. + count := count + 1] + ] forkAt: Processor activeProcess priority - 1. + delay := (random next * 100) asInteger + 10. "avoid 0-ms delay" + (Delay forMilliseconds: delay) wait. + self assert: process isTerminated not. + process terminate. + process priority: Processor activeProcess priority + 1. + self + assert: process isTerminated; + assert: count equals: 11 ]!
Hi Christoph,
From: christoph.thiede@student.hpi.uni-potsdam.de Date: 2021-05-28 23:05:43 [...] Also, there is no guarantee that in #testTerminateInEnsure, process will not have completed earlier, is it? This totally depends on the speed & implementation of the VM. We don't want this test to fail when running on a NSA machine or on your coffee machine in 2050, do we? ;P Did you consider using semaphores instead? :-)
yes, I agree, we don't need this test; it's too dependent on the performance of the physical hardware. Besides, the functionality tested here is covered in other tests in Tests-jar.466.
Thanks, Thanks,
Jaromir ~~~ ^[^ -- Sent from Squeak Inbox Talk
On 2021-05-31T21:20:01+00:00, commits@source.squeak.org wrote:
A new version of KernelTests was added to project The Inbox: http://source.squeak.org/inbox/KernelTests-jar.407.mcz
==================== Summary ====================
Name: KernelTests-jar.407 Author: jar Time: 31 May 2021, 11:19:58.858017 pm UUID: 8bb4554a-971d-ea49-9396-6a0c1625fb5b Ancestors: KernelTests-nice.404
Add a test #testTerminateInEnsure presented by Martin McClure at 2019 Smalltalk conference. Test unwind when a process gets terminated inside the #ensure unwind block. Complement latest #terminate in the Inbox.
Supersede KernelTests-jar.405 - fix underscores from Cuis
=============== Diff against KernelTests-nice.404 ===============
Item was added:
- ----- Method: ProcessTest>>testTerminateInEnsure (in category 'tests') -----
- testTerminateInEnsure
- "As shown in
- Martin McClure's 'Threads, Critical Sections, and Termination' (Smalltalks 2019 conference)
- https://youtu.be/AvM5YrjK9AE
- at 23:17
- self new testTerminateInEnsure
- "
- | process count random delay |
- random := Random new.
- 10 timesRepeat: [
process := [
count := 0.
[] ensure: [
10 timesRepeat: [
count := count + 1.
1000000 timesRepeat: [12 factorial]].
count := count + 1]
] forkAt: Processor activeProcess priority - 1.
delay := (random next * 100) asInteger + 10. "avoid 0-ms delay"
(Delay forMilliseconds: delay) wait.
self assert: process isTerminated not.
process terminate.
process priority: Processor activeProcess priority + 1.
self
assert: process isTerminated;
assert: count equals: 11 ]!
squeak-dev@lists.squeakfoundation.org