Boost logo

Boost Users :

From: frederic.mayot_at_[hidden]
Date: 2007-08-30 15:28:25


>The code is totally and irrecoverably broken (from a threading
perspective).
>There is no way to fix it if it has to retain its current form.

Well... let's take the example of an interruptible task. We have a main
program which launches a thread.
Now, we want to stop this thread. We can use interruption or the following
code:

T1:
while(true)
{
        lock lk(mutex);
        if (end) break;
        /* dosomething */
}

T2:
interruptT1()
{
        lock lk(mutex);
        end = true;
}

>The basic idea when using threads is to create parallelism. Thread T1 is
>inherently non-parallel. It simply cannot operate in parallel with anyone

>else who also needs to access the shared state that is protected by the
>mutex.

That's what I call contention (when your threads work in a collaborative
way)...

*************************************************************************
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates
shall be liable for the message if altered, changed or falsified.

*************************************************************************



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net