<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        > <span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">I still don't see the point. Are you saying that the current project or it's UI process could change during a VM suspension point?</span><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">If that code runs at 39 and the user switches projects at 40, yes, this can happen.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">> </span><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Then, what about something like "Project current evaluateUIMessage: [...]", which will unpreemptedly (using the new primitive solution) check the UI process and either evaluate the message directly or defer it? :-)</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Even the implementation of #evaluateUIMessage: would need something like <noContextSwitch> :-) So, one could directly add this pragma to, for example, #endEntry, without adding such a new indirection. And at lower levels or more concise scopes, access should be controlled with a mutex.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">I suppose that the "trick" with <noContextSwitch> only works in a green-threading model where exactly 1 thread (or Squeak process) is actually running at a time.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Best,</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Marcel</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">P.S.: Is every fallback code for failing primitives evaluated without preemption? </span></div><div class="mb_sig"></div>
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 28.01.2021 11:28:24 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style="font-family:Arial,Helvetica,sans-serif">

<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>I still don't see the point. Are you saying that the current project or it's UI process could change during a VM suspension point?</p>
<p><br>
</p>
<p>Then, what about something like "Project current evaluateUIMessage: [...]", which will unpreemptedly (using the new primitive solution) check the UI process and either evaluate the message directly or defer it? :-)</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;color: rgb(0, 0, 0);font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols">
<div name="divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif;font-size: ;margin: 0">
<div>
<div class="_rp_T4" id="Item.MessagePartBody">
<div class="_rp_U4 ms-font-weight-regular ms-font-color-neutralDark rpHighlightAllClass rpHighlightBodyClass" id="Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="divtagdefaultwrapper"><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="Signature">
<div style="margin:0px"><span style="">
<div><font size="3" color="black"><span style="font-size: 12pt"><a href="http://www.hpi.de/" target="_blank" rel="noopener noreferrer" id="LPNoLP"><font size="2"><span id="LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</span></div>
</div>
</span></div>
</div>
</div>
</div>
</div>
<div><span style="font-size: 10pt;color: #808080"></span></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Donnerstag, 28. Januar 2021 11:13:55<br>
<b>An:</b> squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] Transcript error when forceUpdate: false (?)</span>
<div> </div>
</div>
<div>
<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
Hi Christoph.
<div><br>
</div>
<div>> <span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"> </span><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">What is that dangerous thing that could happen during a suspension point in the VM? What am I
 missing here? :-)</span></div>
<div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br>
</span></div>
<div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">It's only part of the problem. There could be a disconnect between the former "Project current uiProcess" comparison and how "addDeferredUIMessage" is processed later in the code.
 It would be better to no preempt this call as a whole.</span></div>
<div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br>
</span></div>
<div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Best,</span></div>
<div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Marcel</span></div>
<div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 28.01.2021 10:59:50 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi all,</p>
<p><br>
</p>
<p>this is an interesting discussion, two thoughts from my side:</p>
<p><span style="font-size: 12pt"><br>
</span></p>
<p><span style="font-size: 12pt">1.</span><span style="font-size: 12pt"> What is the problem with "<span>Processor activeProcess == Project current uiProcess" not being a thread-safe expression? I see that it could be possible at many points that the VM interrupts
 the current process and resumes another one first; but still, activeProcess will always hold the same Process instance when the same process is active, independently of any interruptions, won't it? What is that dangerous thing that could happen during a suspension
 point in the VM? What am I missing here? :-)</span></span></p>
<p><span style="font-size: 12pt"><span><br>
</span></span></p>
<p><span style="font-size: 12pt"><span>2. To Levente's proposal of making Transcript calls thread-safe:</span></span></p>
<p><span style="font-size: 12pt"><span><br>
</span></span></p>
<p><span style="font-size: 12pt"><span>> </span></span><span style="font-size: 12pt">safelyNextPutAll: aString</span><span style="font-size: 12pt"><span></span></span></p>
<div>> </div>
<div>>          mutex critical: [</div>
<div>>                  stream nextPutAll: aString ]</div>
<div><br>
</div>
<div>So this would delay the execution of any process that uses the Transcript, wouldn't it? Hm ... I would rather have expected the Transcript calls to be deferred when the Transcript is locked ATM - *unless* #forceUpdate is enabled, maybe. Let's keep everyday Transcript
 clients blocking-free whenever possible. Or imagine several processes writing to the Transcript, but the transcript not being opened at this time. There should no need to block any of the calling processes?</div>
<div><br>
</div>
<div>Best,</div>
<div>Christoph</div>
<div></div>
<p></p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;color: rgb(0, 0, 0);font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols">
<div name="divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif;font-size: ;margin: 0">
<div><span style="font-size: 10pt;color: #808080"></span></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Donnerstag, 28. Januar 2021 10:41:03<br>
<b>An:</b> squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] Transcript error when forceUpdate: false (?)</span>
<div> </div>
</div>
<div>
<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
Hi Tobias
<div><br>
</div>
<div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">A separate kind of log (that optionally could output to the transcript)</span></div>
<div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br>
</span></div>
<div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Transcript can use stdout already. Not sure we want to shift the problem to the user again ... :-/ "Every time you provide an option, you expect users to make a decision." :-)</span></div>
<div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br>
</span></div>
<div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Best,</span></div>
<div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Marcel</span></div>
<div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 28.01.2021 10:32:27 schrieb Tobias Pape <das.linux@gmx.de>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">Hi<br>
<br>
apart from the debuggers, why bother making Transcript thread-safe in the first place?<br>
<br>
The Transcript is a mere output stream for debugging/logging etc., our stdout or stderr.<br>
<br>
A separate kind of log (that optionally could output to the transcript) would be more apt IMHO.<br>
Thread safety could be addressed there without complicating Transcript more…<br>
<br>
my 2ct<br>
-tobias<br>
<br>
<br>
> On 28. Jan 2021, at 09:05, Marcel Taeumel <marcel.taeumel@hpi.de>wrote:<br>
> <br>
> Hi Levente.<br>
> <br>
> Thanks für clarification. We are talking about more than one problem here. :-) I did just address the issue with errors/debuggers happening due to UI process disruptions. You are also concerned about the order of contents in the Transcript's contents. Both
 are very important and required for claiming that it would be thread-safe.<br>
> <br>
> (Which reminds me that I find it very strange that the UI components (e.g. PluggableTextMorph) do also check the Transcript's internal characterLimit. I would expect an append-only behavior when a Transcript window is open.)<br>
> <br>
> Anyway, your proposal about a safelyNextPut(All): looks good. :-) +1<br>
> <br>
> Best,<br>
> Marcel<br>
>> Am 27.01.2021 23:05:21 schrieb Levente Uzonyi <leves@caesar.elte.hu>:<br>
>> <br>
>> Hi Marcel,<br>
>> <br>
>> On Tue, 26 Jan 2021, Marcel Taeumel wrote:<br>
>> <br>
>> > Hi Jaromir,<br>
>> > please take a look at Collections-mt.923 (inbox). Maybe those changes would satisfy all your current needs in this regard. :-)<br>
>> > <br>
>> > @all: Would Transcript now be thread-safe? Did I miss something?<br>
>> <br>
>> Not at all. The problem is not #endEntry but all the other <br>
>> methods writing to the stream e.g.: #nextPutAll:.<br>
>> The real solution is to replace the stream-like API with one that provides <br>
>> an easy way to write messages in a thread-safe way. E.g.:<br>
>> <br>
>> Transcript showStream: [ :stream |<br>
>> stream nextPutAll: 'Hello'; space; nextPutAll: ' World!'; cr ]<br>
>> <br>
>> Which guarantees that 'Hello World!' appears on the Transcript without <br>
>> being mixed with other messages.<br>
>> <br>
>> or<br>
>> <br>
>> Transcript show: 'Hello {1}!{2}' format: { 'World'. String cr }.<br>
>> <br>
>> The implementations could be e.g.:<br>
>> <br>
>> showStream: aBlock<br>
>> <br>
>> | string |<br>
>> string := String streamContents: aBlock.<br>
>> self safelyNextPutAll: string<br>
>> <br>
>> show: aString format: arguments<br>
>> <br>
>> | string |<br>
>> string := aString format: arguments.<br>
>> self safelyNextPutAll: string<br>
>> <br>
>> The last challenge is to implement #safelyNextPutAll: which involves <br>
>> making Transcript not be a TranscriptStream.<br>
>> Transcript should encapsulate the stream and use a Mutex (not a global one <br>
>> because its pointless) to provide thread-safety while writing the <br>
>> characters on it or reading its contents. E.g.:<br>
>> <br>
>> safelyNextPutAll: aString<br>
>> <br>
>> mutex critical: [<br>
>> stream nextPutAll: aString ]<br>
>> <br>
>> For backwards compatibility, the stream-API methods must be provided for a <br>
>> while but those methods should be thread-safe on their own. E.g.:<br>
>> <br>
>> nextPutAll: aString<br>
>> <br>
>> self safelyNextPutAll: aString<br>
>> <br>
>> nextPut: aCharacter<br>
>> <br>
>> self safelyNextPutAll: aCharacter asString<br>
>> <br>
>> <br>
>> Levente<br>
>> <br>
>> > <br>
>> > Best,<br>
>> > Marcel<br>
>> ><br>
>> > Am 25.01.2021 21:38:36 schrieb jaromir :<br>
>> ><br>
>> > Well, I tried deferring the whole Transcript endEntry machinery to the UI<br>
>> > doOneCycle (bypassing the changed: #appendEntryLater mechanism) for<br>
>> > #forceUpdate = false only ... and it seems to avoid the problem!<br>
>> ><br>
>> > TranscriptStream >> endEntry<br>
>> ><br>
>> > deferredEntry ifNil: [ false ]. "this is a new instance variable"<br>
>> > self semaphore critical:[<br>
>> > self class forceUpdate<br>
>> > ifTrue: [self changed: #appendEntry; reset]<br>
>> > ifFalse: [deferredEntry := true].<br>
>> > <br>
>> ><br>
>> > TranscriptStream >> flushDeferredEntry<br>
>> > "This is run every UI cycle in doOneCycleNowFor:"<br>
>> ><br>
>> > deferredEntry ifTrue: [<br>
>> > self class forceUpdate: true.<br>
>> > self endEntry.<br>
>> > deferredEntry := false.<br>
>> > self class forceUpdate: false.<br>
>> > ]<br>
>> ><br>
>> > doOneCycleNowFor: aWorld<br>
>> ><br>
>> > "... the whole body remains unchanged except:"<br>
>> ><br>
>> > capturingGesture ifFalse:<br>
>> > [aWorld runStepMethods.<br>
>> > Transcript flushDeferredEntry. "this is printing for #forceUpdate =<br>
>> > false"<br>
>> > self displayWorldSafely: aWorld].<br>
>> > <br>
>> ><br>
>> > For #forceUpdate = true the endEntry mechanism remains unchanged and failing<br>
>> > as before...<br>
>> > <br>
>> > <br>
>> ><br>
>> > --<br>
>> > Sent from: http://forum.world.st/Squeak-Dev-f45488.html<br>
>> > <br>
>> > <br>
>> ><br>
>> <br>
> <br>
<br>
<br>
<br>
</leves@caesar.elte.hu></marcel.taeumel@hpi.de></div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div></blockquote></div>