Question about mutexes

J

Jan Danielsson

In OS/2 C, I would do this:

main()
{
....
DosCreateMutexSem(NULL, &hmtx, 0UL, FALSE);
....
}

thread()
{
....
DosRequestMutexSem(hmtx);

Locked!

DosReleaseMutexSem(hmtx);
....
}

How would I go about doing that in Python?

I figured this part out:

lockobj = mutex()

lockobj.lock(foo, "bar")

Locked!

lockobj.unlock()


Now, what (and more importantly: WHY?!) - is foo and "bar" for?

I have written a dummyfunction for foo which does nothing when
called, but I fail to see the point of its existence. Could someone
provide an example when this would be useful?
 
R

Reinhold Birkenfeld

Jan said:
In OS/2 C, I would do this:

main()
{
...
DosCreateMutexSem(NULL, &hmtx, 0UL, FALSE);
...
}

thread()
{
...
DosRequestMutexSem(hmtx);

Locked!

DosReleaseMutexSem(hmtx);
...
}

How would I go about doing that in Python?

I think you will want to create a threading.Lock object.

Reinhold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top