process priority

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

process priority

t olschewski
I've some more questions:

1. is there a way to run "do-it"s and other user activity at a priority of 40, say, by default ?

I know I can say "p := [ ... lenghty ...] forkAt: 40" and "p terminate" anytime in order to prevent user interface from freezing.

2. are my "forkAt:" processes supposed to appear in the Process Browser and if yes: where do I find them ?

3.
If I open a workspace and a Transcript in a new (1.3-13315) image and run:
    p := [ 1 to: 10 do: [ :n | Transcript show: n; cr; cr; show: n factorial; cr; cr ]] forkAt: 40.
then everything works fine. If I replace 10 by 1000 (don't do this yourself) then sometimes after a while the Transcript window turns red with two yellow lines and a debug window pops up with varying errors (mostly "subscript out of bounds"). Then again, in some cases it runs with no error. I have seen this in squeak 4.2, too.
Reply | Threaded
Open this post in threaded view
|

add.

t olschewski
I've found a shorter method to reproduce a red Transcript window with two dancing lines in yellow on my system:
I start a fresh (1.3-13315) image, open workspace and Transcript, then
p := [Transcript show: xxx factorial] forkAt: 40. (don't try this yourself)
where xxx is a 2 followed by 4 zeroes.
Reply | Threaded
Open this post in threaded view
|

Re: add.

Lukas Renggli
The transcript is not intended to be written to from outside of the GUI thread.

You can fix your code by writing:

    [ WorldState addDeferredUIMessage: [ Transcript show: 2000
factorial ] ] forkAt: 40.

Now the Transcript could possibly do that itself in case it is called
outside of the UI thread ...

Lukas

On 21 November 2011 21:51, t olschewski <[hidden email]> wrote:

> I've found a shorter method to reproduce a red Transcript window with two
> dancing lines in yellow on my system:
> I start a fresh (1.3-13315) image, open workspace and Transcript, then
> p := [Transcript show: xxx factorial] forkAt: 40. (don't try this yourself)
> where xxx is a 2 followed by 4 zeroes.
>
> --
> View this message in context: http://forum.world.st/process-priority-tp4092574p4093274.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>



--
Lukas Renggli
www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: process priority

Sean P. DeNigris
Administrator
In reply to this post by t olschewski
t olschewski wrote
1. is there a way to run "do-it"s and other user activity at a priority of 40, say, by default ?
The beauty of a live, open, dynamic system is that there's a way to do anything :) For instance, to have your desired behavior in Workspaces, you could do something like override SmalltalkEditor>>doIt to read:
    ^ [ self evaluateSelection ] forkAt: 40.
n.b. the above will work for the doIt shortcut, as the menu item calls a different method.

t olschewski wrote
2. are my "forkAt:" processes supposed to appear in the Process Browser and if yes: where do I find them ?
It will be listed along with the usual processes. If you didn't see it, it could be because your process completed to quickly, or you didn't have auto-update turned on in the Process Browser.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: add.

t olschewski
In reply to this post by Lukas Renggli
hello. your suggestion

[ WorldState addDeferredUIMessage: [ ... ] ] forkAt: 40.

solves the problem of Transcript turning red, but now I can't suspend or terminate this process (>20000 factorial<, say) again, because the user interface seems to freeze while waiting for the result (or the Transcript output, more precisely).
Reply | Threaded
Open this post in threaded view
|

Re: process priority

t olschewski
In reply to this post by Sean P. DeNigris
> If you didn't see it, it could be because your process completed to quickly, or
> you didn't have auto-update turned on in the Process Browser.

true, "auto update" was turned off. Wouldn't "auto update on" be a better default?

> you could do something like override SmalltalkEditor>>doIt to read: ^ [ self evaluateSelection ] forkAt: 40.

thanks for pointing me there. I've thought about doing something like this yesterday, but I did not figure out where to look.
Reply | Threaded
Open this post in threaded view
|

Re: add.

Lukas Renggli
In reply to this post by t olschewski
Easy enough to fix:

  [ string := 2000 factorial asString.
  WorldState addDeferredUIMessage: [ Transcript show: string ] ] forkAt: 40.

You can't avoid that some large number is printed at some point. And
that probably takes a while.
On 22 November 2011 09:37, t olschewski <[hidden email]> wrote:

> hello. your suggestion
>
> [ WorldState addDeferredUIMessage: [ ... ] ] forkAt: 40.
>
> solves the problem of Transcript turning red, but now I can't suspend or
> terminate this process (>20000 factorial<, say) again, because the user
> interface seems to freeze while waiting for the result (or the Transcript
> output, more precisely).
>
>
> --
> View this message in context: http://forum.world.st/process-priority-tp4092574p4094886.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>



--
Lukas Renggli
www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: process priority

Sean P. DeNigris
Administrator
In reply to this post by t olschewski
t olschewski wrote
true, "auto update" was turned off. Wouldn't "auto update on" be a better default?
I think so.

t olschewski wrote
thanks for pointing me there. I've thought about doing something like this yesterday, but I did not figure out where to look.
I actually just guessed and searched for #doIt in the Finder. I found two methods, put a breakpoint in both, and pressed Cmd-D in a Workspace.

Another way would be to bring up halos on a Workspace. The frontmost Morph is a TextMorphForEditView. Exploring it in the browser, and then working through it's instance variables, you could get to the same place.

These are my two main tools to start figuring out how things work: the Finder and the halos (bringing them up on a menu item can be very useful).

HTH,
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: add.

t olschewski
In reply to this post by Lukas Renggli
Easy enough to fix:
  [ string := 2000 factorial asString.
  WorldState addDeferredUIMessage: [ Transcript show: string ] ] forkAt: 40.
That does the job. Thank you.