This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-05-29 11:02:09

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Getting a laggy bit of code faster

Is there anyway of getting 2 bits of Squeak running at the same time?
E.G
Online blocks are slow, so is there a way of programming them to:
Run 1 line of its Squeak..
While its doing that continue Squeak code...


You can now reach me on Twitter @johnnydean1_

Offline

 

#2 2011-05-29 11:28:59

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Getting a laggy bit of code faster

Preemptive multitasking?
Asynchronous server data fetching?
In Squeak?

I don't think so. You would need to be able to control processes and possibly initialize a new one, which I don't think is possible in Squeak. Notice how Scratch always freezes when saving a project or opening a dialog box? That's because it's a single thread action. I should think the Scratch team would have implemented multi-threading for such operations if they could have.

So, as far as I know, no.

Offline

 

#3 2011-05-29 12:12:52

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Getting a laggy bit of code faster

Yes.  big_smile  It is very very hard, you would have to make some extra codes, like BYOBs doFork, but modified for scratch, then you would have to make another special form code which would do fork or something, it is a bit confusing, I don't think you would be able to do it easily.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#4 2011-05-29 12:26:34

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Getting a laggy bit of code faster

LS97 wrote:

Preemptive multitasking?
Asynchronous server data fetching?
In Squeak?

I don't think so. You would need to be able to control processes and possibly initialize a new one, which I don't think is possible in Squeak. Notice how Scratch always freezes when saving a project or opening a dialog box? That's because it's a single thread action. I should think the Scratch team would have implemented multi-threading for such operations if they could have.

So, as far as I know, no.

*coughtheBYOBLAUNCHblockcough*

Last edited by scimonster (2011-05-29 13:50:02)

Offline

 

#5 2011-05-29 13:36:07

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Getting a laggy bit of code faster

Like this:

Code:

newThread _ [putHere theMethodYouWantToRun] newProcess.
newThread priority: Processor userInterruptPriority.
newThread resume.

EDIT: To make it clear, this doesn't affect Scratch's execution engine, but actually creates a new Squeak thread. The program does slow down slightly though.

Last edited by TheSuccessor (2011-05-29 13:38:26)


/* No comment */

Offline

 

#6 2011-05-29 13:42:48

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Getting a laggy bit of code faster

scimonster wrote:

LS97 wrote:

Preemptive multitasking?
Asynchronous server data fetching?
In Squeak?

I don't think so. You would need to be able to control processes and possibly initialize a new one, which I don't think is possible in Squeak. Notice how Scratch always freezes when saving a project or opening a dialog box? That's because it's a single thread action. I should think the Scratch team would have implemented multi-threading for such operations if they could have.

So, as far as I know, no.

*coughtheBYOBRUNblockcough*

You mean launch


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#7 2011-05-29 13:49:08

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Getting a laggy bit of code faster

Pecola1 wrote:

scimonster wrote:

LS97 wrote:

Preemptive multitasking?
Asynchronous server data fetching?
In Squeak?

I don't think so. You would need to be able to control processes and possibly initialize a new one, which I don't think is possible in Squeak. Notice how Scratch always freezes when saving a project or opening a dialog box? That's because it's a single thread action. I should think the Scratch team would have implemented multi-threading for such operations if they could have.

So, as far as I know, no.

*coughtheBYOBRUNblockcough*

You mean launch

Ooops.

Offline

 

#8 2011-05-29 14:05:16

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Getting a laggy bit of code faster

To all those that coughed the Launch block, it's not the same thing.
That block simply acts like the broadcast block which doesn't wait for the script to finish, but doesn't actually multi-task.

TheSuccessor's method seems like a valid one, on the other hand. Nice!

Offline

 

#9 2011-05-30 03:03:17

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Getting a laggy bit of code faster

TheSuccessor wrote:

Like this:

Code:

newThread _ [putHere theMethodYouWantToRun] newProcess.
newThread priority: Processor userInterruptPriority.
newThread resume.

EDIT: To make it clear, this doesn't affect Scratch's execution engine, but actually creates a new Squeak thread. The program does slow down slightly though.

Any way to get this done with a reporter?


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer