Shop OBEX P1 Docs P2 Docs Learn Events
CPU/RAM/EEPROM Usage — Parallax Forums

CPU/RAM/EEPROM Usage

John BoardJohn Board Posts: 371
edited 2012-05-03 07:11 in Propeller 1
Hi,

Is there any way I can get the:

CPU Usage
RAM Usage
EEPROM Usage

Of the propeller. I was able to code a way to get the current number of cogs being used - but I really want to find out how to program these other things.

Thanks,

John

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-05-02 23:47
    If you use the Prop tool or BST and hit F8 it will display the memory usage. Is that what you want?
  • John BoardJohn Board Posts: 371
    edited 2012-05-03 00:11
    Thanks for the reply, but I really want the robot to be able to do it real-time. The aim is for me to be able to monitor the system's resources while I'm programming it.

    -John

    [EDIT] While I'm programming it, and running the code.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-05-03 00:33
    Well EEPROM usage shouldn't be changing while it runs code, should it? As for RAM well isn't that simply using variables and DATA areas that you have already defined? The same goes for COGs used as it doesn't matter once a COG is used, it's running. What you are looking for is probably more application specific yet your question is rather general.
  • Heater.Heater. Posts: 21,230
    edited 2012-05-03 00:45
    John,

    What kind of processing are you doing?

    In most embedded application on micro-controllers like the Prop the resource usage is fixed.

    Memory is statically allocated when you write your variable declarations and the number of instances of objects in Spin is normally determined at compile time. Fixed at run time. Except for the fact that stack usage is a little woolly but even there you have control over the amount of stack each process gets and can make a good guess if it is sufficient.

    In the Prop COG usage is also normally know at compile time. It is not many applications were people are starting and stopping a random assortment of COG depending on incoming data or events. In fact I don't think I have heard of one yet. You write the code, you know what will be running.

    The actual execution rate of your COG code rather depends on things like waitpeq and waitcnt. Again hopefully you know what your inputs are and have written your code to handle those data rates.

    So apart from a slight question mark over stack usage I'm not sure what you are asking for, It's not as if we are dealing with a unix like OS juggling multiple threads and virtual memory where process monitoring almost becomes essential.

    P.S. There is somewhere here a tool to determine stack usage from your source code and another that attempts to monitor stacks at run time. I have not had the need to use these yet.
  • John BoardJohn Board Posts: 371
    edited 2012-05-03 01:06
    Well, more what I was after is some code that can figure out what variables I have filled up with data - but as you said, it's not really necisssary. Same with the CPU time - it would have been nice though :P I'm kind of in the state of wanting to write some code to find out how fast each cog is running - but I don't want to spare the cog in my code to find out :P Well anyway. Thanks for your help apat from that.

    I kind of wish the prop had more proccessors :P Maybe that can be something for Prop 3

    -John
  • John BoardJohn Board Posts: 371
    edited 2012-05-03 01:07
    Note: After you mentioned about JS in the webpage controling a robot thread, I looked into JS and found that JS would have been a better option over Python ;)

    -John
  • Heater.Heater. Posts: 21,230
    edited 2012-05-03 01:18
    John,

    As you add more processors to a shared memory architecture like the Prop you get decreasing returns in overall performance as the access to RAM becomes an increasing bottle neck. Imagine, in the extreme an infinite number of processors sharing RAM would have zero performance! Once one had accessed data in RAM it has to wait an infinite amount of time to get its chance again.

    A while back Chip did pose the question here "16 COGs or more RAM fro Prop II?". I think the forum convinced him that 16 COGs may be detrimental to performance and more RAM would be better. Tough call I think.

    If Python works for you on the server end of a Prop to WEB page connection then why not. It's a fine language even if I don't like the white space block delimiting.

    I just like the idea of using the same language at server and client end of a project. I'm sure JavaScript will start to annoy me with it's quirks soon enough:)
  • John BoardJohn Board Posts: 371
    edited 2012-05-03 01:24
    Ohh well, thanks for your help!

    I've been down in the shed (The place where all my father's and my "great" inventions have been made) programming the robot. The comp it is getting entered into is only a month away now! It's kind of odd going back to "primative" coding after programming in a language such as python and Java - Casting, Heaps of threads, Function address passing, Classes, and all the rest of it I've gotten too accustomed too!

    Well, I'll let you know how it goes ;)

    -John
  • jmgjmg Posts: 15,193
    edited 2012-05-03 01:25
    John Board wrote: »
    Well, more what I was after is some code that can figure out what variables I have filled up with data

    Do you mean Variables you may have declared, but never used ?

    Some tools will report that, at least in a simplistic ' not directly referenced' manner, (not sure if any do on the Prop ?) but it is small enough a Text editor can be used.
    John Board wrote: »
    I'm kind of in the state of wanting to write some code to find out how fast each cog is running - but I don't want to spare the cog in my code to find out

    The classic way to time something critical, is to toggle a pin. Or use a simulator.
    (A Cog always runs at full speed, unless you have a WAITxx opcodes.)
  • John BoardJohn Board Posts: 371
    edited 2012-05-03 01:46
    I sort of meant something as follows:

    Cog1(Timer Cog):
    var long temp
    pub main
      repeat
        Serial.out(cnt)
        repeat until temp
        Serial.out(cnt)
        temp := 0
    pub changeTemp
      temp := 1
    

    Cog2 (Cog to be timed)
    pub main
      repeat
        doStuff
        changeTemp
    

    I'm not sure if this code is 100% accurate... but I think you get the picture (If you can make head or tail of my code).

    >Do you mean Variables you may have declared, but never used ?

    Yes.

    -John
  • Heater.Heater. Posts: 21,230
    edited 2012-05-03 02:32
    I seem to remeber that the BST Propeller tool will issue warnings of unreferenced variables in Spin. It can also remove unused methods from the final binary. So that does not leave much to worry about.
    Of course you may still have referenced variables that are not actually used because the code that references them is never executed. But who would write code like that:)
  • g3cwig3cwi Posts: 262
    edited 2012-05-03 06:21
    Heater. wrote: »
    But who would write code like that:)

    Me - for one!
  • Mike GMike G Posts: 2,702
    edited 2012-05-03 07:11
    g3cwi, debugging is the only reason, I can think of, for monitoring variable use during run time. I believe there is a deeper question being asked. That is, how do I instrument my Prop code.

    One way is to write to information to a log file or a terminal session.

    I use the method below when unit testing. DisplayMemory writes hub memory to the PST given a hub starting address, length, and a flag for Hex or ASCII. There are other techniques like counting the number of times a method is invoked or counting loops. Regardless of the technique, implementation is up to the programmer. That means a little thought has to go into the process.
    OBJ
      pst           : "Parallax Serial Terminal"
    
    PUB Main
      pst.start(115200)
      'Code here
    
    PRI DisplayMemory(addr, len, isHex) | j
      pst.char(13)
      pst.str(string("Start: "))
      pst.dec(addr)
      pst.str(string(" Len: "))
      pst.dec(len)
      pst.char($0D)
      
      pst.str(string("-------- Buffer Dump -----------",13, "    "))
      repeat j from 0 to 9
        pst.dec(j)
        pst.char($20)
        pst.char($20)
      pst.char(13)
      repeat j from 0 to len
        if(j == 0)
          pst.dec(0)
          pst.char($20)
          pst.char($20)
          
        if(isHex)
          pst.hex(byte[addr + j], 2)
        else
          pst.char($20)
          if(byte[addr+j] == 0)
            pst.char($20)
          pst.char(byte[addr+j])
    
        pst.char($20) 
        if((j+1) // 10 == 0) 
          pst.char($0D)
          pst.dec((j+10)/10)
          pst.char($20)
          if((j+10)/10 < 10)
            pst.char($20)  
      pst.char(13)
      pst.char(13)
    
Sign In or Register to comment.