Shop OBEX P1 Docs P2 Docs Learn Events
Paradox - When does the Prop have time to run your Spin code? — Parallax Forums

Paradox - When does the Prop have time to run your Spin code?

Heater.Heater. Posts: 21,230
edited 2011-02-08 16:50 in Propeller 1
After a few beers it is often the case that we come up with some really odd thoughts. This was last nights:

When you run your Spin code on a Prop you have:

1) The Propeller hardware, a COG.
2) The COG is filled with and running an instance of the Spin interpreter.
3) The byte codes of your compiled Spin program in HUB.

Now, as we see the COG is using 100% of it's time to run the Spin interpreter.

So...When does your Spin program get run? Clearly there is no left time for it:)

Cheers.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-08 01:21
    It's after 1 a.m. and past my bedtime. My brain is fogged from drowsiness. Why, oh why, did I have to click on this thread just now? :)

    -Phil
  • BatangBatang Posts: 234
    edited 2011-02-08 01:32
    Once Zhuangzi dreamt he was a butterfly, a butterfly flitting and fluttering around, happy with himself and doing as he pleased. He didn't know he was Zhuangzi. Suddenly he woke up and there he was, solid and unmistakable Zhuangzi. But he didn't know if he was Zhuangzi who had dreamt he was a butterfly, or a butterfly dreaming he was Zhuangzi.
  • RossHRossH Posts: 5,519
    edited 2011-02-08 01:33
    Easy!

    Your Spin program is never run. What is happennig is that the Spin interpreter cog is simulating (in real time) what would happen if your Spin program was ever run!

    Ross,
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-02-08 01:44
    heater: Aha, then you can never have a bug in spin code because it never executes :)
  • Heater.Heater. Posts: 21,230
    edited 2011-02-08 02:01
    RossH,
    Your Spin program is never run. What is happennig is that the Spin interpreter cog is simulating (in real time) what would happen if your Spin program was ever run!

    Man, that is some serious Zen.

    Cluso,
    Aha, then you can never have a bug in spin code because it never executes

    Sadly, with the above in mind, all my bugs get faithfully simulated as well.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-02-08 02:43
    I don't know the answer but I think it has something to do with cats.

    Graham
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-08 06:09
    Sadly, with the above in mind, all my bugs get faithfully simulated as well.

    So, you have now two choices, either fix the bug itself or change the simulator to circumvent the bug.
  • Ray0665Ray0665 Posts: 231
    edited 2011-02-08 07:04
    Its kinda like this
    1. A = B
    2. A^2 = AB
    3. A^2-B^2 = AB - B^2
    4. (A+B)*(A-B) = B(A-B)
    5. (A+B)*(A-B)/(A-B) = B
    6. A+B = B
    BUT from line 1, A=B so let A=1 then 1+1=1
    So obviously the spin math interpreter is hosed!!!
  • RichKRichK Posts: 54
    edited 2011-02-08 07:19
    You have misinterpreted the spin executable attempting to interpret the simulation:

    It is not a bug, it is a feature that is simply missing the associated requirement. If your specs were complete you would have known that.

    Remember to always misinterpret the request for a quote.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-02-08 08:25
    Heater,

    I have thought about that paradox before, and I agree that the intepreter code running in the cog would have no time to actually execute the spin code. I have looked in detail at the spin interpreter source posted by Parallax, and there's no way that that code could actually be intepreting and executing the spin bytecodes in hub RAM. The actual PASM code that gets loaded is scrambled in the ROM, so there is no evidence that this matches the intepreter source code that was posted.

    I have studied the picture of the Prop die that shows the cogs, cog RAM and hub RAM. However, there seems to be areas in the picture that have no function. Collectively, I call these unidentified sections of the prop chip Area 51. My theory is the spin engine is actually implemented in the random logic in Area 51. Based on what I can piece together, the spin engine consists of a few thousand gates, has 8 16-bit registers and 8 32-bit registers, and it is clocked at 1/64th of the system clock rate, or 1.25 MHz.

    Dave

    Disclaimer: The above comments are not backed up by any facts. They are only random thoughts that would have been produced by drinking too many beers.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-02-08 08:29
    +1 Ross

    Chip discovered a rift in the fabric of existence where it's possible to harness computational power from the entropy of space.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-08 08:51
    Jonathan Swift noted:

    "So nat'ralists observe, a flea
    Hath smaller fleas that on him prey,
    And these have smaller fleas that bite 'em,
    And so proceed ad infinitum."
  • Heater.Heater. Posts: 21,230
    edited 2011-02-08 08:56
    Mike,

    Yes, I see it all now, it's turtles all the way down!

    http://en.wikipedia.org/wiki/Turtles_all_the_way_down
  • Ahle2Ahle2 Posts: 1,179
    edited 2011-02-08 09:07
    Parallax really should consider a name change.
    Wouldn't it be cool to execute some code on your "Paradox Impeller" ?
    Of course you should make use of all 8 clogs. :lol:

    /Ahle2
  • wmosscropwmosscrop Posts: 409
    edited 2011-02-08 09:12
    It's very simple. Everyone is assuming that the cog's spin is clockwise.

    In reality, it's counter-clockwise.

    Therefore, it has the results of the instructions first, so it doesn't have to do any decoding or executing or any other hard thing. It just sits there waiting for you to do something with the data. All the stuff on the chip is just decoration in case someone looks at it.

    Maybe I've had a tad too much cold medicine?

    Walter
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-08 09:14
    Assuming (as now seems to be the case) that running Spin code requires a suspension of disbelief, this thread is coming perilously close to rendering all Propeller chips inoperative. I suggest that we vow here and now to keep the faith so the magic keeps happening! Perhaps some sort of creed or mantra is called for that can be intoned before powering up -- you know, just in case...

    -Phil
  • cdecde Posts: 37
    edited 2011-02-08 09:57
    This thread does remind me of an excellent book I read some time ago, name "Permutation City". If you enjoy Sci-fi, simulations and mathematics, it's a great book.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-02-08 10:01
    Know the cog.
    Trust the cog.
    Use the cog.
  • BeanBean Posts: 8,129
    edited 2011-02-08 10:20
    wmosscrop wrote: »
    It's very simple. Everyone is assuming that the cog's spin is clockwise.

    In reality, it's counter-clockwise.

    Therefore, it has the results of the instructions first, so it doesn't have to do any decoding or executing or any other hard thing. It just sits there waiting for you to do something with the data. All the stuff on the chip is just decoration in case someone looks at it.

    Maybe I've had a tad too much cold medicine?

    Walter

    Walter, I believe the cog's spin is actually anti-counter-clockwise.
    The only way it can run code is to use post-predictive instruction execution.

    Bean
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-08 10:32
    potatohead,

    It needs to be in Latin for maximum effect:
    Cog novi.
    Cog crede.
    Cog uti.

    I'm sure there's a snappy Gregorian melody that it could be put to as well.

    -Phil
  • RichKRichK Posts: 54
    edited 2011-02-08 11:30
    Okay, after several hours of omphalopsychism, I realized that I earlier responded in haste. And I am not sure that chanting in Latin will help. You are asking questions way beyond what the definition of "is" is. You are asking what the loading on the processor is at a given time. The answer is 100%. To get beyond that you have to project your question from the real domain into the Complex. Add in a few M[cos(phi)+jsin(phi)] and you can almost take it imaginary.

    Simple answer. What Parallax has created here is beyond the comprehension of mere mortal man. It is consistent with the finite mind trying to comprehend the infinite wonder of the cosmos. Just believe.

    Or as I tell my wife, "Don't worry your pretty little head about it dahlin".
  • wmosscropwmosscrop Posts: 409
    edited 2011-02-08 12:08
    Bean wrote: »
    Walter, I believe the cog's spin is actually anti-counter-clockwise.
    The only way it can run code is to use post-predictive instruction execution.

    But it's a pro-peller. Therefore it must spin pro-counter-clockwise. If it was anti-counter-clockwise all the output data would get jammed into the input pins and cause a jam.

    Walter
  • potatoheadpotatohead Posts: 10,261
    edited 2011-02-08 12:11
    I could not agree more Phil. Perfect!!

    (that mantra is on my office wall now, BTW Latin version. Can't wait for the side discussions :)
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-02-08 14:05
    and the whole time I thought schrodinger's cat was handling my Spin code... Learn something new every day!

    OBC
  • BrowserBrowser Posts: 84
    edited 2011-02-08 14:23
    OBC wrote:
    the whole time I thought schrodinger's cat was handling my Spin code
    u, sir, r wize beyond ur yeerz. repeet aftur me:
    Felis novi.
    Felis crede.
    Felis uti.

    -browz
  • doggiedocdoggiedoc Posts: 2,246
    edited 2011-02-08 16:07
    I'm sorry. What was the question again?


    Paul
  • Kal_ZakkathKal_Zakkath Posts: 72
    edited 2011-02-08 16:50
    Paul: Until we read through this thread, we cannot know if it has been asked or answered, thus we can say it is both asked an answered simultaneously.

    But enough of that, the real answer is painfully obvious when you think about it:

    The "prop" is actually a standard 32-bit micro with 64k of flash, that simply "fakes" having 8 cores using an incredibly complex system of interrupts.

    Once you realise this, everything makes sense:

    Q1: Why no on-chip non-volatile storage? A: Because if the programmer could access the flash the ruse would be revealed.
    Q2: Why no native C? A: The prop runs C internally, but must run an interpreted language because of the answer to Q1.
    Q3: Why no interrupts? A: They are all used up to simulate "cogs" for us foolish simpletons who don't use "real" micros.


    Obviously the prop must run C natively and use interrupts internally - I've read enough threads around here to see that it is impossible to have a "real" micro without them... apparently ;)
Sign In or Register to comment.