Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 — Parallax Forums

Spin2

rjo__rjo__ Posts: 2,114
edited 2014-04-11 18:40 in Propeller 2
I'm starting this thread as a place where suggestions, questions, answers and concerns about SPIN2 can be posted.

My personal opinion is that the multitasking capabilities in PASM2 is the single most important new feature. The reason is obvious: you don't have to stop doing everything else just because you using a wait function. This isn't really as critical with 16 Cogs as it was with 8, but it sure is nice.

I am hoping that SPIN2 has at least limited multitasking capabilities. I raise the issue now, because I have no idea if this feature would require anything in the hardware design.

Thanks

Rich
«1

Comments

  • eldonb46eldonb46 Posts: 70
    edited 2014-04-09 15:40
    rjo__ wrote: »
    . . .

    I am hoping that SPIN2 has at least limited multitasking capabilities. I raise the issue now, because I have no idea if this feature would require anything in the hardware design.

    Thanks

    Rich

    I am also anxiously awaiting an news of new capabilities of SPIN2, especially any implementation of Tasks within a single Object.

    In my minds eye, Tasks should be as simple as have multiple Program Execution Pointer, it would be up to the programmer to keep them coordinated and common resources locked.

    See: http://forums.parallax.com/showthread.php/141706-Propeller-II?p=1122712#post1122712
  • PublisonPublison Posts: 12,366
    edited 2014-04-09 15:51
    Are we talking about SPIN2 as it relates to P1+? If not, please don't get Chip sidetracked right now. You know he will be watching this thread. :)
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-09 15:52
    Eldon,

    Your memory is better than mine… I NOW remember seeing that thread. FWIW IMHO SPIN2 multitasking would be an essential upgrade for people that primarily code in SPIN2(new users).
    For the people that use SPIN to tie all of their PASM code together, I wouldn't imagine it would be quite as important
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-09 15:58
    Publison…

    Yes. I actually posted it because I know that Chip is up all night working on the hardware. So if there is anything there that he needs to massage to make SPIN2
    multitasking a reality in the future, now might be the time to do it. Chip has already made changes to how SPIN2 will be implemented, I suspect this is probably a no-brainer.

    He doesn't need to respond!!!


    Rich
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-09 16:26
    Rich,

    Is this thread directed toward Spin2 to run on the P2, which is on hold or is it for Spin1+ for the P16x64 (P1+) chip which is the current next chip? If it is really for the P2, then there are already two threads I started about features and implementation ideas a few weeka back. There is a bit of Spin discussion in the P2 BLOG that I haven't edited out yet.

    If it is about Spin+, then I think it is a bit premature since there are still a few hardware details that need to be firmed up that could impact Spin features.

    Chip will probably read it, so it could be a distraction too.
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-09 16:42
    Rick,

    I meant it for the chip currently under production, which I understand(and could be easily wrong) will have some multitasking at the hardware level. As it is right now, if a new user wants to use a wait instruction… that instruction stalls the code until it is satisfied. If there are other things going on in the loop, then those things have to wait. The way to get around this
    at the level of Spin is simply to start a cog and do what you want to do in an uninterrupted fashion there… I don't know what kind of multitasking Chip is thinking about at the
    machine level, but his previous version was really elegant from the user perspective.

    I don't care whether multi-tasking is in SPIN2 for personal reasons… I will be able to do everything I want to do without it. But for people who get stuck at the level of SPIN and haven't yet made it to PASM and objects, I think it might be very helpful… if it is simple and doesn't impact performance when it is not in use.

    It isn't worth slowing the current effort … just a matter of deciding if it belongs on the back burner.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-09 16:53
    I see issues like this opening more cans of worms. I think a lot of how/if Spin can multi-task within a cog wiil come down to the implementation models and what trade-offs want to be made. It should be fun! Argh! It's too hard to type on my tablet!
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 04:59
    My gut feeling is that you are correct, but I didn't know for sure. That's why I posted it. In my mind, it isn't worth half a can of worms:)
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 05:38
    In addition to everything else. (including my joke that didn't sound like a joke, except maybe to me), after looking around this morning… it turns out my basic understanding about wait instructions and multitasking was completely wrong:)
  • Heater.Heater. Posts: 21,230
    edited 2014-04-10 05:48
    Spin multi tasking in a COG?

    As far as I know Spin does not run in a COG.

    The Spin interpreter is run by a COG.

    So the question is can a Spin interpreter running in a COG run two or more threads of Spin code?

    Or do we have two or more instances of the Spin interpreter running as threads in a COG each running a chunk of Spin?

    What happens when one of those Spin threads want's to do a WAITPE or such? That stalls everything no matter which way you do the threading.

    I don't know, just thinking....about all the worms in that can...:)
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 05:50
    Heater,

    Far more more worms than I thought. I don't regret asking the question, but the answer seems pretty clear to me:)
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 05:54
    As far as I am concerned we can close this thread. If there is any other conversation needed I would direct everyone to mindrobots thread about a month back.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-10 06:23
    Heater. wrote: »
    What happens when one of those Spin threads want's to do a WAITPE or such? That stalls everything no matter which way you do the threading.

    I don't know, just thinking....about all the worms in that can...:)

    This was the BIG worm I wasn't sure about last night.

    Multi-tasking Spin will be a fun feature to have for the P2! :lol: Let's concentrate on other worms for now.
  • Heater.Heater. Posts: 21,230
    edited 2014-04-10 06:41
    I would not close this thread, not just yet. There are plenty of worms to untangle. We like worms. For example:


    The current P2 design has hubexec and threads. As far as I understand it's better to have only one thread doing HUB exec as there is no caching and things would get horrible slow.


    What does a Spin interpreter do: It fetches byte codes from HUB and runs some PASM to do whatever that byte code says to do. To do that it needs a pointer to the next byte code, the Spin program counter, and it needs a Spin stack pointer. Perhaps a few temporary registers in COG.


    This might leave a lot of free space in the COG. This free space could be used to run some user PASM code as a COG thread (or threads).


    We could therefore imagine a Spin interpreter that allows the loading of some PASM into that free space to be run as a thread in parallel with the interpreter itself.


    BINGO we have effectively got a COGSTART that loads PASM and runs it all in a single COG!
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 06:42
    AMENnnnnnnnnn(just to get it to 10 characters… the minimum for posting)
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 06:44
    I issued my AMEN to mind robots and then of course I see Heater's comments…. think… I must think...
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 06:57
    OK… I have thought about it. It sound like engineering porn to me. I love it when you guys talk dirty. (that's a joke) But the fact remains that when we talk about all of this from the perspective of a new user(which is what I was trying to do)… just coming in fresh, like I did. I erroneously thought that SPIN multitasking would be a useful way to show how much you could do without resorting to writing your own objects or starting a new cog… all of which take time for a new user to grasp. The use case that the new person comes to first is the wait stall(at least I did). When I got to this point… then I had to learn about starting cogs before I really wanted to… and it was more complicated than I really wanted to deal with. I didn't get lost at that point, but many others probably did.

    My basic error in starting this thread is that I thought that the multitasking already dealt with this issue and so, to get the biggest bang for the buck (since I thought it was already there... but it isn't)…would be to give it to the newbie in SPIN. Everything you say is true… but does it address the wait stalls? hmmmm

    In my mind, with the facts as they are… I think multitasking could be far later in a new person's experience.

    Not sure I said it right… but the idea is in there somewhere.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-10 07:02
    Heater. wrote: »
    I would not close this thread, not just yet. There are plenty of worms to untangle. We like worms. For example:


    The current P2 design has hubexec and threads. As far as I understand it's better to have only one thread doing HUB exec as there is no caching and things would get horrible slow.


    What does a Spin interpreter do: It fetches byte codes from HUB and runs some PASM to do whatever that byte code says to do. To do that it needs a pointer to the next byte code, the Spin program counter, and it needs a Spin stack pointer. Perhaps a few temporary registers in COG.


    This might leave a lot of free space in the COG. This free space could be used to run some user PASM code as a COG thread (or threads).


    We could therefore imagine a Spin interpreter that allows the loading of some PASM into that free space to be run as a thread in parallel with the interpreter itself.


    BINGO we have effectively got a COGSTART that loads PASM and runs it all in a single COG!

    Darn you!!! How am I supposed to get work done for my REAL job, when I have to think about things like this?? :lol:

    We do like worms, don't we!!


    @RICH, could you re-title this thread "SPIN+" or "SPIN 16x32" or some such.....since it will be different than Spin2?
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-10 07:08
    rjo__ wrote: »
    OK… I have thought about it. It sound like engineering porn to me. I love it when you guys talk dirty. (that's a joke) But the fact remains that when we talk about all of this from the perspective of a new user(which is what I was trying to do)… just coming in fresh, like I did. I erroneously thought that SPIN multitasking would be a useful way to show how much you could do without resorting to writing your own objects or starting a new cog… all of which take time for a new user to grasp. The use case that the new person comes to first is the wait stall(at least I did). When I got to this point… then I had to learn about starting cogs before I really wanted to… and it was more complicated than I really wanted to deal with. I didn't get lost at that point, but many others probably did.

    My basic error in starting this thread is that I thought that the multitasking already dealt with this issue and so, to get the biggest bang for the buck (since I thought it was already there... but it isn't)…would be to give it to the newbie in SPIN. Everything you say is true… but does it address the wait stalls? hmmmm

    In my mind, with the facts as they are… I think multitasking could be far later in a new person's experience.

    Not sure I said it right… but the idea is in there somewhere.

    I'm not sure it will be easier than starting a new COG (core, code execution engine, whatever), just point to some code and start the COG. Using the hardware multi-tasking from inside Spin will probably be more of a challenge (or at least more things to be aware of as far as what you should and shouldn't do).

    What seems tricky for a new user about starting a COG? (I'm curious for future tutorial purposes)
  • Heater.Heater. Posts: 21,230
    edited 2014-04-10 07:14
    rjo,

    I see Spin as a language for those who are new to programming and as such it should be as simple as possible.
    Threads and parallel processing are perhaps not topics to start beginners off with.
    But Spin does have threads, not just threads but parallel execution by virtue of it's COGs.
    That's OK though because the way Spin does it is about the simplest cleanest I have ever seen.

    Trying to get a COG to run multiple Spin threads may well not be so simple and have odd limitations, like the WAITPE thing, that just make Spin to confusing for beginners.
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 07:19
    The good news is that Spin is going to get a huge speed upgrade with the next chip. It will be possible to do things in Spin that now require PASM… so, the new user experience is going to be far richer and more rewarding. We don't want to bury that huge improvement under a new layer of complexity.
  • Heater.Heater. Posts: 21,230
    edited 2014-04-10 07:31
    mindrobots,
    What seems tricky for a new user about starting a COG?

    From reading hundreds of questions here over the years there are few things that have come up many, many, times:

    1) Setting up the stack. What's that about? No body has to worry about a stack for the main line Spin. What is stack anyway? And why do I need one for starting up a COG? And how the hell do I know how big it should be?

    2) DIRA. So many issues boil down to setting DIRA and then starting a COG and then wondering why OUTA does not work there.

    3) There have been many questions indicating that the poster correlates objects, one to one, with COGs. Not realizing that an object may never start another COG but just provide methods the run in the callers COG when called. Or that an object could in fact start up many COGS.

    4) Sharing data between COGs. How? Spin has no specific language features to do that. You have to kludge around with pointers.

    5) DAT and VAR, The idea that DAT is shared between objects, and hence running COGs in different objects, but VAR is private to an object instance.

    And so on..

    Put all that together and you have quite an advanced topic for a beginner who may only recently learned how to read/write a pin, write an expression, and what a conditional or loop is.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-10 07:37
    Thanks, Heater!

    Nicely summarized.
  • rjo__rjo__ Posts: 2,114
    edited 2014-04-10 10:55
    Heater, you left out calling conventions. In the beginning it was trial and error(and if I don't program for a while it becomes trial and error all over again)… starting a cog out of a single file, using SPIN only code in the main as well as the code you are putting in the cog is different than writing an object and starting a cog out of Spin in that object and then writing code for the cog in PASM. I am naturally weak with this sort of thing. I struggled with it every time I come across it…. I had that problem with PASCAL trying to talk to a 6800 and I have had it with other languages like python and hyper talk-->applescript where talking to the processor isn't really an issue. In my experience, the kinds of brains that don't have these kinds of issues are the exception rather than the rule.

    In other words… sometimes I think you guys forget just how talented you really are. But if Parallax tried to make money by only catering to that kind of talent…uhhhm.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-04-10 11:11
    @Heater
    It seems like you should be the Editor-in-Chief of the Propeller2 Manual with the additional possibility of authoring the first Propeller2 tutorial. You make a lot of excellent points.

    The majority of your issues on the Propeller that you mention didn't make much sense to me until I got into Forth on the Propeller (Yes, it took a stack language to make the reason for stacks obvious -- Spin has some Forth like qualities to it.)

    Also Forth cleared up just exactly what that pesky PAR register did and why it was so important. I guess I was just a late-bloomer with the Propeller1.

    Maybe we should disguise a version of Forth and call it the P2-Explorer. New users might understand a bit faster and sooner.
  • ctwardellctwardell Posts: 1,716
    edited 2014-04-10 11:22
    Maybe we should disguise a version of Forth and call it the P2-Explorer. New users might understand a bit faster and sooner.

    What's in a name?
    That which we call Forth by any other name would smell as <?>

    It is left as an exercise to the reader to fill in the <?> as needed based on their arguably incorrect opinion of Forth...

    C.W.
  • potatoheadpotatohead Posts: 10,261
    edited 2014-04-10 12:31
    I think most people should experience Forth. It is an environment, language, and more in one package. Forth makes you think about things a little differently. We might hate it, love it, use it, ignore it. Doesn't matter. The exposure does.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-10 12:47
    I just want it on the record that I have NOT mentioned a certain stack oriented, threaded, interpreted language in several weeks as it could/would relate to any new Propeller chips. The last mention I recall was when I have made changes to pfth to test P2 instructions and architecture.

    In DIDN'T do it!
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-10 12:49
    potatohead wrote: »
    I think most people should experience Forth. It is an environment, language, and more in one package. Forth makes you think about things a little differently. We might hate it, love it, use it, ignore it. Doesn't matter. The exposure does.

    I do agree with this. It should be experienced even to the point that you try and write a small application that is well suited for F
    .
  • ctwardellctwardell Posts: 1,716
    edited 2014-04-10 12:53
    potatohead wrote: »
    I think most people should experience Forth. It is an environment, language, and more in one package. Forth makes you think about things a little differently. We might hate it, love it, use it, ignore it. Doesn't matter. The exposure does.

    So are you espousing exposing malleable future programmers to Forth, sort of like taking a little kid to a Chicken Pox party? ;-)

    C.W.
Sign In or Register to comment.