[Robotgroup] First round of Spin code :)

Robo Al sp-18561884 at ggsys.net
Thu Jan 10 00:29:12 PST 2008


Thanks, that's a fast response considering the time. I guess I'm 
not the only night owl around here :-)

The round robin sounds like an interesting implementation. Certainly
something quite livable. 

Although I'm still not sure how I would implement my own semaphores
as it normally requires multiple operations (ie. read to make sure
is not set, then set) which if I understand your description will
happen after all the other cogs accessed the shared memory in between.

Alberto

On Thu, 2008-01-10 at 01:49 -0600, Andre Lamothe wrote:
> Sure,
> 
> 1. Are all built in memory operations atomic in the
> propeller chip?
> 
> ANS: First, we have to be talking about ASM code running on a particular 
> COG, if we are talking about SPIN code then each instruction takes about 50 
> ASM instructions to implement thus someone could format the hard drive in 
> one SPIN instruction :) That said, there are two type of memory access 
> instruction in ASM: local memory and shared memory. When talking to a COGs 
> local memory, no one else can talk to it, thus its absolutely atomic by 
> definition and takes 4 cycles in most cases, there is little pipelining in 
> the prop, so 4 clocks per instruction. The second case is when you access 
> shared memory which is the 32K static ram, now this gets interesting. Since 
> there are 8 cogs and each cog can access the shared ram at the same time, it 
> was decided to arbitrate access with a round robin "hub" that rotates around 
> and gives each cog a shot at memory, thus only one cog can talk to global 
> memory at once and all operations are 32-bit. However, the downside is when 
> you access global memory you must wait up to 7 rotations of the hub for it 
> to come around, or 16 clocks. Thus, for optimal performance you will access 
> memory then do work on it taking up 16 clocks then access it again, so you 
> are just in time each access and dont have to wait. However, the wait is 
> automatic and the cog simply blocks and holds while it waits for  the hub to 
> rotate around when you access main memory.
> 
> 2. Does spin/asm provide locks/semaphores or some type of syncing
> across the cogs?
> 
> ANS: yes, there are 8 semaphores that you can check out and check it. SPIN 
> has access to them as well, but typically you would use them in ASM for 
> critical sections where you don't want other processors touching a large 
> data structure until you are done touching it. However, since all memory 
> operations are atomic in ASM, you can create semaphores, mutexes, etc. with 
> simple memory reads/writes to global memory, since there is no way you can 
> get interrupted ever (as long as the access is a single byte, word, or 
> long).
> 
> Andre'
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "Robo Al" <sp-18561884 at ggsys.net>
> To: "The Robot Group Mailing List" <robotgroup at puremagic.com>
> Sent: Thursday, January 10, 2008 1:11 AM
> Subject: Re: [Robotgroup] First round of Spin code :)
> 
> 
> Andre you probably know these,
> 
> Are all built in memory operations atomic in the
> propeller chip?
> 
> Does spin/asm provide locks/semaphores or some type of syncing
> across the cogs?
> 
> Thanks,
> 
> Alberto
> 
> 
> _______________________________________________
> Robotgroup mailing list
> Robotgroup at puremagic.com
> http://lists.puremagic.com/cgi-bin/mailman/listinfo/robotgroup 
> 
> _______________________________________________
> Robotgroup mailing list
> Robotgroup at puremagic.com
> http://lists.puremagic.com/cgi-bin/mailman/listinfo/robotgroup
-- 
Alberto Alonso                        Global Gate Systems LLC.
(512) 351-7233                        http://www.ggsys.net
Hardware, consulting, sysadmin, monitoring and remote backups



More information about the Robotgroup mailing list