From: Lewis G. <mim...@ya...> - 2001-03-27 18:12:10
|
Hi Mitch, --- Mitch Davis <md...@po...> wrote: > Hi Lew, welcome to our project. > > > I have run into a problem using pthread_mutex. > When two threads try to lock > > the same mutex, one of them blocks, but never > wakes up when the other > > releases the lock. > > We don't use the pthread library where I work, so I > can't offer you anything > from experience. There was some mention of pthreads > on the mailing list > some time back. You might want to search the > archive: > > > http://www.geocrawler.com/search/?config=3076&words=pthread&SUBMIT=Search+linuxsh-dev I looked here, but didn't find anything relevant. We did find some old patches (June 2000) having to do with pthreads which have long since been merged into glibc. > > We are using glibc-2.2.2, having followed the > instructions for building the > > cross-development tools from this mailing list. > > Just a heads-up, Stuart Menefy's instructions are > now a little long in the > tooth. They should be read in conjunction with > Masahiro Abe's new instructions. > http://linuxsh.sourceforge.net/docs/abe/20010320-gcc2.97/README_E.php3 yes.. we were actually following the new ones from Masahiro Abe... > Could you post the source for a tiny program which > demonstrates the mutex problem? Yes.. the following program demonstrates the problem, although it works fine on an x86 system. It would be helpful to know if other people see this problem; it might very well be something wrong with our development environment.. //==================== // sh4-linux-gcc -Wall test.c -o test -lpthread -static #include <pthread.h> #include <stdio.h> #include <unistd.h> pthread_mutex_t m; void * func(void *arg) { printf("func locking\n"); pthread_mutex_lock(&m); printf("func got lock\n"); sleep(1); printf("func unlocking\n"); pthread_mutex_unlock(&m); printf("func unlocked\n"); return NULL; } void * func2(void *arg) { printf("func2 locking\n"); pthread_mutex_lock(&m); printf("func2 got lock\n"); sleep(1); printf("func2 unlocking\n"); pthread_mutex_unlock(&m); printf("func2 unlocked\n"); return NULL; } int main() { pthread_t t; pthread_mutex_init(&m, NULL); printf("starting\n"); pthread_create(&t, NULL, func, NULL); func2(NULL); sleep(2); return 0; } //================= THanks for your helpful response ! -Lew > > Regards, > > Mitch. > -- > mailto:mj...@al... > mailto:md...@po... > > _______________________________________________ > linuxsh-dev mailing list > lin...@li... > http://lists.sourceforge.net/lists/listinfo/linuxsh-dev > > > __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text |