Computing.Net > Forums > Unix > how do you get pthread to wait for

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how do you get pthread to wait for

Reply to Message Icon

Name: nace33
Date: September 29, 2004 at 11:29:08 Pacific
OS: debian
CPU/Ram: p4
Comment:

I am trying to figure out how to have two pthreads interact with one another...I am using mutex to lock the threads out but, the other threads don't stop where they are. How do you get the other threads to suspend or wait for the the thread thats in the critical section. My problem is that i am reading in data from files and i need them read in a certain order...here is my locking code.


//mutex lock
pthread_mutex_lock(&mtx);

//messageWrite(temp2); message.append(temp2);

//mutex unlock pthread_mutex_unlock(&mtx);

i know it is locking out the other process but i need them to stop while the thread is in this area...any help pleeease, very frustrating.



Sponsored Link
Ads by Google

Response Number 1
Name: fpmurphy
Date: September 29, 2004 at 17:49:32 Pacific
Reply:

Its simple - a POSIX thread calling pthread_mutex_lock() to lock the mutex either gets exclusive access to the code starting from the successful locking until its call to unlock the mutex, or it waits until the mutex is unlocked by the thread that locked it.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: how do you get pthread to wait for

How do you get rid of Lilo Boot? www.computing.net/answers/unix/how-do-you-get-rid-of-lilo-boot/1129.html

getting awk to print name of file www.computing.net/answers/unix/getting-awk-to-print-name-of-file-/7206.html

How do you remote mount a cd? www.computing.net/answers/unix/how-do-you-remote-mount-a-cd/2197.html