Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pthread_* functionality currently in OS X



At Tue, 26 Mar 2002 17:12:01 -0800, Matt Watson <email@hidden> wrote:
> 
> Please post a small example. How are you using pthread_cond_wait()?

  pthread_cond_t condVar;
  pthread_mutex_t mutexVar;
  ...
  if (pthread_cond_init(&condVar, NULL) != 0) {
    CantHappen();
  }
  if (pthread_mutex_init(&mutexVar, NULL) != 0) {
    CantHappen();
  }
  if (pthread_mutex_lock(&mutexVar) != 0) {
    CantHappen();
  }
  if (pthread_cond_wait(&condVar, &mutexVar) != 0) {
    CantHappen();
  }


> How are the mutexes and conditions initialized? If you attach in gdb, 
> where is it spinning? This could be due to memory corruption, where one 
> of the internal pthread spin locks has been set and will never unlock.

When I attach with gdb and then interrupt, it is always in 
semaphore_wait_signal_trap() - from `bt`:

#0  0x7003f4c8 in semaphore_wait_signal_trap ()
#1  0x7003f2c8 in _pthread_cond_wait ()
#2  0x0048b734 in os_StartKernel (memoryAddres=0x5690a08 "", memorySize=104850936, systemStackSize=4096, interruptStackSize=0) at foo.c:744
#3  0x00489df4 in os_StartTheWorld () at bar.c:477
#4  0x00002a2c in main (argc=2, argv=0xbffff610) at main.c:388
#5  0x00002340 in _start ()
#6  0x00002170 in start ()


-Conrad
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.



References: 
 >Re: pthread_* functionality currently in OS X (From: Matt Watson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.