inter cog communication
stravag
Posts: 4
hello
i have a quick question.
i have an application where one cog has a controller function, starting other cogs to do certain jobs. now it's important for the controller to know when the other cogs have finished their job.
at the moment i'm doing this by polling active methods of the objects running in other cogs to find out if the job is done. similar to the object explained in the "Propeller Manual" on page 118.
i dislike the idea of polling to find out if a cog has finished it's job. is there a way of having some sort if interrupt to trigger the controller?
i have a quick question.
i have an application where one cog has a controller function, starting other cogs to do certain jobs. now it's important for the controller to know when the other cogs have finished their job.
at the moment i'm doing this by polling active methods of the objects running in other cogs to find out if the job is done. similar to the object explained in the "Propeller Manual" on page 118.
i dislike the idea of polling to find out if a cog has finished it's job. is there a way of having some sort if interrupt to trigger the controller?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
I have a similar situation in my project. When a Cog completes a process, i simply set a flag (example __bCog1Completed := 1) that is specific to that Cog/process. This variable will be available and is accessible by other Cogs. The "main" Cog checks the value of this and other "status" flags and takes action.
hope that helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"any small object, accidentally dropped, goes and hides behind a larger object."
·
ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
- Setting and reading variables is really, really fine. Don't get confused with the problems the large guys have with assembly programming.
- There is absolutely no need to use a LOCK just because it has a fancy name and looks like a "flag",
whatever that may be...
@stravag: o.k. I see now what you want to say: As you cannot access variables in another object you use a "getter". This is quite all right.
Post Edited (deSilva) : 9/7/2007 10:04:34 PM GMT
so you'd advise me to use something like this "active" method and poll it in the controller process to see if the cog running the subroutine is finished. so i assume there really is no "nicer" way to do that than polling (whether i'm polling a method or flag ... it's still polling [noparse]:)[/noparse] )
i was hoping there is something like "wait for cogid" or something... but i can live with that. just wanted to make sure i'm not coding some sort of hack when there is something neat implemented in spin.
thanks for your help
Agreed. There's no real advantage to using a lock instead of just writing to bits in a piece of shared HUB memory, unless of course you are so short of hub memory that you don't have even a single byte free.
If you can spare the I/O lines, your best bet is to use eight lines (or however many you need) as flags. They can be set/cleared/read without the wait associated with hub instructions, and you can also use the WAITPEQ/WAITPNE instructions as a simple way of handling blocking.
I was looking in the manual for a function to check a cog to see if it's running and there apparently is no such function. Would be nice in some cases.
Ken
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
Even an interrupt is performed in that the processor - by the way! - checks some lines during each instruction cycle before deciding where from to fetch the next instruction...
The word "polling" is generally used for one of three basic software techniques to respond to asynchronious events:
- "waiting" (while sleeping in a power reduction mode)
- "polling" (and doing other things in case of a negative result)
- "serving interrupts" (forwarding the "polling" to the processor hardware)
There are pros and cons for each of the above techniques....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.