[gambit-list] Threads blocking and IO

Bob McIsaac bobmc at fcibroadband.com
Tue Jan 29 23:13:00 EST 2008


François Magnan wrote:
> ``A thread is blocked if it is waiting for a mutex to become unlocked,
> an I/O operation to become possible, the end of a “sleep” period, etc. ''
Hi:
A threaded system has a state change model which typically includes the
above items.  When any task/thread becomes blocked, the cpu chooses
another from it's list of waiting tasks such that it is always doing
something.

A mutex is a simple mechanism for managing shared memory.  But priority
inversion or deadly embrace can happen if A blocks on a mutex set by B
but B needs some I/O to be done by A.

It's possible that your app may run ok on one of Linux, Windows, or
SunOs but not on all because each has it's own threading model.

Make your design as simple as possible. Perhaps run 2 Gambit sessions,
with the slow stuff such as network connects in one, and the fast stuff
in another, with a pipe or ring buffer in between.  Consider the QNX
message passing model. All transactions are atomic.  Blocking tasks and
data manger tasks are separated in a hierarchy.

It's a complex topic that may require some determined research.

Cheers,
-Bob-

http://en.wikipedia.org/wiki/Native_POSIX_Thread_Library




More information about the Gambit-list mailing list