Threads Question

Christian Schulte schulte at imit.kth.se
Wed Jan 29 17:00:44 CET 2003


Dear Mostafa,

Jorge is right. Just as an additional remark, threads do not guarantee any
form of "atomicity", their execution can be interrupted at any time.

In order to guarantee your desired behaviour, you have to make sure that the
two threads in question are handeled mutually exclusive (by a lock, for
example) so that while thread A can actually run thread B will be blocked.
Then you'll get the weaker guarantee that A will be at least not interrupted
by B!

Christian

"Jorge M. Pelizzoni" <jorgemp at icmc.usp.br> wrote in message
news:<000101c2c4a4$b0a94880$6100a8c0 at Cherokee>...
> Yes, it is possible that T takes control before Y is bound to 5. But, 
> if your concern is that T, at some point, needs Y bound, you are 
> actually not concerned, because it will (implicitly) block until Y 
> gets bound (that's why Oz is said to be dataflow-oriented). Now, if 
> you really have a race condition there, you won't be able to avoid 
> explicit synchronization constructs (locks and the like).
> 
> > -----Original Message-----
> > From: owner-oz-users at ps.uni-sb.de 
> > [mailto:owner-oz-users at ps.uni-sb.de]
> On
> > Behalf Of HALA MOSTAFA
> > Sent: Saturday, January 25, 2003 3:52 PM
> > To: users at mozart-oz.org
> > Subject: Threads Question
> > 
> > Hi all,
> > I have a question regarding threads. For the following piece of code
> > 	{Wait X}
> > 	Y = 5
> > Suppose there's another thread T in addition to the one waiting on 
> > X,
> and
> > that both threads have the same priority.
> > My question is: When X becomes bound, is it guaranteed that the
> binding
> > Y=5
> > will take place immediately after X is bound, or is it possible that
> the
> > other thread, T, takes control before Y is bound to 5, depending on
> the
> > scheduler?
> > 
> > In other words, is a suspended thread resumed as soon as the 
> > variable
> it's
> > waiting for is bound, or can another thread take control?
> > 
> > Thank you
> > 
> > 
> > 
> > 
> > 
> > _________________________________________________________________
> > 
> > 
> > -
> > Please send submissions to users at mozart-oz.org
> > and administriva mail to users-request at mozart-oz.org.
> > The Mozart Oz web site is at http://www.mozart-oz.org/. Please send 
> > bug reports to bugs at mozart-oz.org.
> 
> -
> Please send submissions to users at mozart-oz.org
> and administriva mail to users-request at mozart-oz.org.
> The Mozart Oz web site is at http://www.mozart-oz.org/. Please send 
> bug reports to bugs at mozart-oz.o 

-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
Please send bug reports to bugs at mozart-oz.org.





More information about the mozart-users mailing list