On Tuesday 15 October 2002 23:09, Thomas Sauter wrote:
> Hi RTL-Folks,
>
> Does somebody have some answers for the following question?
>
> You have two RTL threads and a global integer variable which is initial
> set to zero.
>
> Thread one will change the global integer variable without the use of
> any synchronisation mechanism to a new value. After that, thread one
> will wakeup thread two and suspend himself.
>
> Now the question:
>
> What value will thread two see in the global integer variable after the
> wakeup - zero or the new value set by thread one?
the new value

> - Where is the integer value physically stored?
somewhere in the kernel memory - so take care about not writing off-shore!

> - will processor caches and memory management have influence for the
> visibillity of the integer value in the second thread?
Shouldn't, if the caches work correctly (which they do 99.999% of the time)

> With other words can i assume that the change of an integer variable is
> an atomic instruction, or is it necessary to use a mutex for write and
> read operations off integers to be shure that global interger data is
> recent in all threads?
Hmm, depends a bit on what you want to do... if you can be assured of the 
correct run-time order, you don't need to protect this memory. Protection is 
only needed when you're not sure who will be accessing this memory-location 
next...

> What about the use of memory barriers in RTL-Threads?
????

> In the moment i use a single processor Athlon XP 2GHz, but i like to
> keep code portable to other processors and multiprocessor environments
That's a very good thing. Although, going from a multi-threaded to a 
multi-processor environment shouldn't be different. Shouldn't...

> sorry for cunfusing you,
Sorry to clean things up ;-)

Linus

-- 
-------------------------------------------------------------
Linus Gasser
EPFL                             Phone:       +41 21 693 5635
Mobile Communications Lab.       FAX  :       +41 21 693 4312
CH-1015 Lausanne                 email:  [EMAIL PROTECTED]
SWITZERLAND                      WEB  : http://lcmwww.epfl.ch
-------------------------------------------------------------
_______________________________________________
Rtl mailing list
[EMAIL PROTECTED]
http://www2.fsmlabs.com/mailman/listinfo.cgi/rtl

Reply via email to