Re: mutli instances test (was Re: Multi-threaded)
Re: mutli instances test (was Re: Multi-threaded)
- Subject: Re: mutli instances test (was Re: Multi-threaded)
- From: Graff <email@hidden>
- Date: Mon, 10 Nov 2003 00:30:47 -0500
A few intresting things to note on this topic. I did some testing and
saw this:
This spawns two instances side by side in the Terminal:
~/Desktop/ClearComment.app &
~/Desktop/ClearComment.app &
This spawns one instance in AppleScript then waits for it to quit and
spawns another:
do shell script "nohup ~/Desktop/ClearComment.app &
do shell script "nohup ~/Desktop/ClearComment.app &
This spawns two instances side by side in AppleScript: (all on one line)
do shell script "/bin/tcsh -c 'nohup ~/Desktop/ClearComment.app
&;nohup ~/Desktop/ClearComment.app &'"
It looks like the AppleScript environment can only have 1 shell going
at a time. If you stuff multiple commands into that shell they run
just fine, but if you try to get them to run commands sequentially they
fail.
I even tried a workaround by having a shell script wrapper called
ScriptWrapper. I saved the following as a text file on the Desktop and
did "chmod -X" on it:
#! /bin/csh
~/Desktop/ClearComment.app &
I called it like:
do shell script "~/Desktop/ScriptWrapper"
do shell script "~/Desktop/ScriptWrapper"
Still no good.
Here's Apple's details on the "do shell script command". Tons of good
stuff in there but nothing that helps me to solve this particular
problem.
<
http://developer.apple.com/technotes/tn2002/tn2065.html>
On Nov 9, 2003, at 10:37 PM, leo wrote:
i'm very interested in this topic because, i want to run one script
(saved
as an application!) in multiple instances. did some experiments with
this. -- with strange results.
here the test scenario. on os x 10.3 first release no updates, i have
the
following script:
beep 1
delay 5
beep 2
and i save it as application under the name "again" in my home dir.
test 1: invoking by a key (via iKey tool)
-----
i bind the script as application to the key f13. then i press f13 once
and
immediately again.
result: just on instance in the dock. second key stroke isn't
recognised. (i
try it several times with slightly different key press delays without
success.)
test 2: invoking from terminal
------
after getting the hint about background invocation (thanks Jon! thanks
Ken!)
i start terminal, switch to my home directory and type
./again.app &
just after this, the same again:
./again.app &
result: fine! in the dock i get two instances of the script "again"
running
with overlap: so, before the first instance does its second beeps, the
second instance starts with its first beep. %-)
test 3: invoking trough a applescript-shell-wrapper
-----
i write a little wrapper script
do shell script "nohup ~/again.app &"
(note: the "nohup" command might be necessary because the shell should
finish before its process again finishes.) i save his wrapper as
application, bind it to a key and repeat the mentioned key experiment
result: again, only one instance at a time. :-((((((((
so, why? i just do not understand it! does anybody has a clue?
cheers, leo
----- Original Message -----
From: "Christopher Nebel" <email@hidden>
To: "AppleScript List" <email@hidden>
Sent: Saturday, November 08, 2003 9:22 AM
Subject: Re: Multi-threaded - thanks
On Nov 7, 2003, at 7:59 AM, Bill Briggs wrote:
I think what you're seeing is the (documented) change from LIFO to
FIFO processing. Nice, but not really multi-threading.
I haven't read the release notes - yet - but from an OS perspective
as
far as I understand it, the difference between LIFO and FIFO is
precisely the difference between non-preemptive thread scheduling and
preemptive thread scheduling. In the case of FIFO you are able to run
simultaneous threads. LIFO blocks pending thread execution because it
can't pre-empt the running thread, effectively rendering it a single
thread system.
Sorry, but you're confusing two completely unrelated concepts.
Preemptive vs. non-preemptive (aka "cooperative") scheduling is simply
a matter of how you decide which threads get time when. LIFO vs. FIFO
have to do with what order you handle requests coming into a queue.
(Essentially, requests come into one end; which end do you draw from?)
Realize that "threading" implies pseudo-simultaneous execution of
multiple tasks, and applets still don't do this.
Before you couldn't even click in a second Script Editor window to
run
a script. The system just beeped at you. Now you can actually run a
second thread at the same time as the first.
I had thought you were referring to applets, but this bit means you're
actually talking about Script Editor. Yes, Script Editor 2.0 will run
multiple scripts at once. It can do this because AppleScript has (and
has always had) sufficient infrastructure to do cooperative threading.
Of course, trying to thread two executions of the same script may or
may not work well, since AppleScript lacks any concept of
synchronization or critical sections.
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.