2 cogs running the same object
william chan
Posts: 1,326
Hi,
1. If 2 cogs runs different methods of one object, and both cogs actively changes values of global variables in that object,
would we need semaphores to prevent program crashes?
2. What is the safest stack size value that you would recommend to beginners?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
1. If 2 cogs runs different methods of one object, and both cogs actively changes values of global variables in that object,
would we need semaphores to prevent program crashes?
2. What is the safest stack size value that you would recommend to beginners?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Comments
2. As big as you can make it This really depends on the complexity or your program. Try starting at 20 to 30. This is really the minimum. If weird things start happening than make this bigger. It wouldn't be anything unusual to need a stack of at least 50 to 100 longs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
There a special case of multiprocessor operation where only one processor writes to a shared value, but multiple processors can read it. A FIFO buffer is one case of this where one processor is a producer of values and another processor is a consumer of values. This can be implemented as two single producer / single consumer variables, the buffer pointer used for writing to the buffer and the pointer used for reading from the buffer. A lock is not necessary for this mechanism.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/