MUTEX and BARRIER!!!!!

Hi,

I can’t undestand complete the “MUTEX” and “BARRIER” concepts, from the
functions pthread_mutex_lock and pthread_cond_barrier or something like
that, also the concept of “recurse”…

Is there anyone who can help me?

Sincerly

Armando

A good book can help you. OS documentation is not supposed to teach you - it
is a reference.

In few words, mutex is a mechanism that provides MUTual EXclusion, hence the
name. Only one thread can own a mutex at one time, so if another thread
attempts to get ownership (lock mutex) it will block until current owner
releases it. Barrier is a concept somewhat similar to a semaphore, that is
it’s a counting lock. Unlike POSIX semaphores that count down, barriers
count up. A thread that attempts to wait on a barrier will block until a
number of threads equal to the value of barrier will also do that. Common
usage is synchronization of several threads to a common ‘known’ point (none
of the threads can continue until they all have reached some common point).
Barrier can be emulated by a mutex coupled with condvar.

“Armando Garza” <el_titirrin@yahoo.com> wrote in message
news:bo3usl$3q8$1@inn.qnx.com

Hi,

I can’t undestand complete the “MUTEX” and “BARRIER” concepts, from the
functions pthread_mutex_lock and pthread_cond_barrier or something like
that, also the concept of “recurse”…

Is there anyone who can help me?

Sincerly

Armando

Igor Kovalenko <kovalenko@attbi.com> wrote:
IK > A good book can help you. OS documentation is not supposed to teach you - it
IK > is a reference.

IK > In few words, mutex is a mechanism that provides MUTual EXclusion, hence the
IK > name. Only one thread can own a mutex at one time, so if another thread
IK > attempts to get ownership (lock mutex) it will block until current owner
IK > releases it. Barrier is a concept somewhat similar to a semaphore, that is
IK > it’s a counting lock. Unlike POSIX semaphores that count down, barriers
IK > count up. A thread that attempts to wait on a barrier will block until a
IK > number of threads equal to the value of barrier will also do that. Common
IK > usage is synchronization of several threads to a common ‘known’ point (none
IK > of the threads can continue until they all have reached some common point).
IK > Barrier can be emulated by a mutex coupled with condvar.

As was pointed out in a different newsgroup, you should get Robert
Krten’s book, “Getting Started with QNX Neutrino”. His example is excellent.
Think of a school bus driver. The bus just doesn’t leave until there are X
number of kids on board.

How could I obtain the book?

–meph++


“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:bo5lkb$837$2@inn.qnx.com

Igor Kovalenko <> kovalenko@attbi.com> > wrote:
IK > A good book can help you. OS documentation is not supposed to teach
you - it
IK > is a reference.

IK > In few words, mutex is a mechanism that provides MUTual EXclusion,
hence the
IK > name. Only one thread can own a mutex at one time, so if another
thread
IK > attempts to get ownership (lock mutex) it will block until current
owner
IK > releases it. Barrier is a concept somewhat similar to a semaphore,
that is
IK > it’s a counting lock. Unlike POSIX semaphores that count down,
barriers
IK > count up. A thread that attempts to wait on a barrier will block
until a
IK > number of threads equal to the value of barrier will also do that.
Common
IK > usage is synchronization of several threads to a common ‘known’ point
(none
IK > of the threads can continue until they all have reached some common
point).
IK > Barrier can be emulated by a mutex coupled with condvar.

As was pointed out in a different newsgroup, you should get Robert
Krten’s book, “Getting Started with QNX Neutrino”. His example is
excellent.
Think of a school bus driver. The bus just doesn’t leave until there are
X
number of kids on board.

Look at “http://www.parse.com/products/books/index.html”. The book I
mentioned is the second one on that page. While there, check out the
first book too. It is due out by the end of the month (I think). I
liked it better than the first one.


Mephri <mephri@infolink.co.id> wrote:

M > How could I obtain the book?

M > --meph++


M > “Bill Caroselli” <qtps@earthlink.net> wrote in message
M > news:bo5lkb$837$2@inn.qnx.com

Igor Kovalenko <> kovalenko@attbi.com> > wrote:
IK > A good book can help you. OS documentation is not supposed to teach
M > you - it
IK > is a reference.

IK > In few words, mutex is a mechanism that provides MUTual EXclusion,
M > hence the
IK > name. Only one thread can own a mutex at one time, so if another
M > thread
IK > attempts to get ownership (lock mutex) it will block until current
M > owner
IK > releases it. Barrier is a concept somewhat similar to a semaphore,
M > that is
IK > it’s a counting lock. Unlike POSIX semaphores that count down,
M > barriers
IK > count up. A thread that attempts to wait on a barrier will block
M > until a
IK > number of threads equal to the value of barrier will also do that.
M > Common
IK > usage is synchronization of several threads to a common ‘known’ point
M > (none
IK > of the threads can continue until they all have reached some common
M > point).
IK > Barrier can be emulated by a mutex coupled with condvar.

As was pointed out in a different newsgroup, you should get Robert
Krten’s book, “Getting Started with QNX Neutrino”. His example is
M > excellent.
Think of a school bus driver. The bus just doesn’t leave until there are
M > X
number of kids on board.


Bill Caroselli – Q-TPS Consulting
1-(708) 308-4956 <== Note: New Number
qtps@earthlink.net

Mephri <mephri@infolink.co.id> wrote:

How could I obtain the book?

You can try a distributor listed on the webpage:

http://www.parse.com/products/ordering.html

Or you can fax me a VISA or Mastercard number to +1 613 599 8317,
including the card number, expiration date, name on card, and full
shipping address. The price is CAD$89.95 + CAD$25 airmail to Indonesia.

Cheers,
-RK


–meph++



“Bill Caroselli” <> qtps@earthlink.net> > wrote in message
news:bo5lkb$837$> 2@inn.qnx.com> …
Igor Kovalenko <> kovalenko@attbi.com> > wrote:
IK > A good book can help you. OS documentation is not supposed to teach
you - it
IK > is a reference.

IK > In few words, mutex is a mechanism that provides MUTual EXclusion,
hence the
IK > name. Only one thread can own a mutex at one time, so if another
thread
IK > attempts to get ownership (lock mutex) it will block until current
owner
IK > releases it. Barrier is a concept somewhat similar to a semaphore,
that is
IK > it’s a counting lock. Unlike POSIX semaphores that count down,
barriers
IK > count up. A thread that attempts to wait on a barrier will block
until a
IK > number of threads equal to the value of barrier will also do that.
Common
IK > usage is synchronization of several threads to a common ‘known’ point
(none
IK > of the threads can continue until they all have reached some common
point).
IK > Barrier can be emulated by a mutex coupled with condvar.

As was pointed out in a different newsgroup, you should get Robert
Krten’s book, “Getting Started with QNX Neutrino”. His example is
excellent.
Think of a school bus driver. The bus just doesn’t leave until there are
X
number of kids on board.


[If replying via email, you’ll need to click on the URL that’s emailed to you
afterwards to forward the email to me – spam filters and all that]
Robert Krten, PDP minicomputer collector http://www.parse.com/~pdp8/