Thread questions

E

Eric J.Hu

Hi,

I have a thread question.

Give an example:
resource_A <--> mutex_A
resource_B <--> mutex_B

I need do copy from resource A to resource B, so I do like following:

pthread_mutex_lock(mutex_B)
pthread_mutex_lock(mutex_A)
memcpy(resource_B, resource_A, sizeof(resource_A));
pthread_mutex_unlock(mutex_A)
/* Q: Can other thread do operation on resource_A now or after the following
unlock??? */

pthread_mutex_unlock(mutex_B)



Thanks,
Eric
 
K

Keith Thompson

Eric J.Hu said:
I have a thread question.

Then try comp.programming.threads. (Standard C, which is what we
discuss here, has no direct support for threads.)
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top