/[hurd]/hurd-l4/libpthread/pthread/pt-alloc.c
ViewVC logotype

Diff of /hurd-l4/libpthread/pthread/pt-alloc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by marcus, Tue Mar 23 03:43:49 2004 UTC revision 1.3 by marcus, Mon Nov 1 17:04:00 2004 UTC
# Line 25  Line 25 
25    
26  #include <pt-internal.h>  #include <pt-internal.h>
27    
28  #include <bits/atomic.h>  #include <atomic.h>
29    
30  /* This braindamage is necessary because the standard says that some  /* This braindamage is necessary because the standard says that some
31     of the threads functions "shall fail" if "No thread could be found     of the threads functions "shall fail" if "No thread could be found
# Line 46  pthread_rwlock_t __pthread_threads_lock; Line 46  pthread_rwlock_t __pthread_threads_lock;
46    
47    
48  /* List of thread structures corresponding to free thread IDs.  */  /* List of thread structures corresponding to free thread IDs.  */
49  __atomicptr_t __pthread_free_threads;  uatomicptr_t __pthread_free_threads;
50    
51  static inline error_t  static inline error_t
52  initialize_pthread (struct __pthread *new, int recycling)  initialize_pthread (struct __pthread *new, int recycling)
# Line 97  __pthread_alloc (struct __pthread **pthr Line 97  __pthread_alloc (struct __pthread **pthr
97    /* Try to re-use a thread structure before creating a new one.  */    /* Try to re-use a thread structure before creating a new one.  */
98    while ((new = (struct __pthread *)__pthread_free_threads))    while ((new = (struct __pthread *)__pthread_free_threads))
99      {      {
100        if (__atomicptr_compare_and_swap (&__pthread_free_threads,        if (atomic_compare_and_exchange_val_acq (&__pthread_free_threads,
101                                          new, new->next))                                                 new, new->next))
102          {          {
103            /* Yes, we managed to get one.  The thread number in the            /* Yes, we managed to get one.  The thread number in the
104               thread structure still refers to the correct slot.  */               thread structure still refers to the correct slot.  */
# Line 110  __pthread_alloc (struct __pthread **pthr Line 110  __pthread_alloc (struct __pthread **pthr
110              while (1)              while (1)
111                {                {
112                  new->next = (struct __pthread *)__pthread_free_threads;                  new->next = (struct __pthread *)__pthread_free_threads;
113                  if (__atomicptr_compare_and_swap (&__pthread_free_threads,                  if (atomic_compare_and_exchange_val_acq
114                                                    new->next, new))                      (&__pthread_free_threads, new->next, new))
115                    break;                    break;
116                }                }
117    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26