gnu.gcc.help
[Top] [All Lists]

Re: How could pthread_mutex_lock/unlock affect compiler optimization an

Subject: Re: How could pthread_mutex_lock/unlock affect compiler optimization and / or caching??
From: Paul Pluzhnikov <ppluzhnikov-nsp@xxxxxxxxx>
Date: Fri, 18 Jul 2008 20:29:38 -0700
Newsgroups: gnu.gcc.help

mynickmynick <mynickmynick@xxxxxxxxx> writes:

> now I think I got it in my example
...
> as quit is a global variable
> and as pthread_mutex_lock(&mutex); is opaque to the compiler (so it
> might change quit value)
> the compiler thinks it cannot keep quit on a register so loads quit
> form memory at every while iteration

Yes, that's pretty much it.

> while without correction and if
> "{do things without using quit} "
> has no function call

 ... or only calls functions known to compiler not to modify gobals ...

> the compiler might decide to keep the quit value on a register, so
> deadlocking!

This situation is usually called infinite looping.
For a deadlock, you need to have something blocking on something else.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

<Prev in Thread] Current Thread [Next in Thread>