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

Diff of /hurd/libpthread/pthread/pt-exit.c

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

revision 1.1 by neal, Thu Oct 10 23:05:06 2002 UTC revision 1.2 by neal, Wed May 4 16:04:06 2005 UTC
# Line 1  Line 1 
1  /* Thread termination.  /* Thread termination.
2     Copyright (C) 2000,02 Free Software Foundation, Inc.     Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
3     This file is part of the GNU C Library.     This file is part of the GNU C Library.
4    
5     The GNU C Library is free software; you can redistribute it and/or     The GNU C Library is free software; you can redistribute it and/or
# Line 35  pthread_exit (void *status) Line 35  pthread_exit (void *status)
35    struct __pthread *self = _pthread_self ();    struct __pthread *self = _pthread_self ();
36    struct __pthread_cancelation_handler **handlers;    struct __pthread_cancelation_handler **handlers;
37    int oldstate;    int oldstate;
38      int need_dealloc;
39    
40    /* Run any cancelation handlers.  According to POSIX, the    /* Run any cancelation handlers.  According to POSIX, the
41       cancellation cleanup handlers should be called with cancellation       cancellation cleanup handlers should be called with cancellation
# Line 69  pthread_exit (void *status) Line 70  pthread_exit (void *status)
70    if (self->cancel_state == PTHREAD_CANCEL_ENABLE && self->cancel_pending)    if (self->cancel_state == PTHREAD_CANCEL_ENABLE && self->cancel_pending)
71      status = PTHREAD_CANCELED;      status = PTHREAD_CANCELED;
72    
73      __pthread_thread_dealloc (self);
74    
75    switch (self->state)    switch (self->state)
76      {      {
77      default:      default:
78        assert (! "This cannot happen!");        assert (! "Consistency error: unexpected self->state");
79          abort ();
80        break;        break;
81    
82      case PTHREAD_DETACHED:      case PTHREAD_DETACHED:
# Line 82  pthread_exit (void *status) Line 86  pthread_exit (void *status)
86           deallocate our own stack.  However, it will eventually be           deallocate our own stack.  However, it will eventually be
87           reused when this thread structure is recycled.  */           reused when this thread structure is recycled.  */
88        __pthread_mutex_unlock (&self->state_lock);        __pthread_mutex_unlock (&self->state_lock);
89        __pthread_dealloc (self);        need_dealloc = 1;
90    
91        break;        break;
92    
# Line 99  pthread_exit (void *status) Line 103  pthread_exit (void *status)
103           waiting to join us.  */           waiting to join us.  */
104        pthread_cond_broadcast (&self->state_cond);        pthread_cond_broadcast (&self->state_cond);
105        __pthread_mutex_unlock (&self->state_lock);        __pthread_mutex_unlock (&self->state_lock);
106          need_dealloc = 0;
107    
108        break;        break;
109      }      }
# Line 108  pthread_exit (void *status) Line 113  pthread_exit (void *status)
113       This means that before freeing any resources, such a thread       This means that before freeing any resources, such a thread
114       should make sure that this thread is really halted.  */       should make sure that this thread is really halted.  */
115        
116    __pthread_thread_halt (self);    __pthread_thread_halt (self, need_dealloc);
117    
118    /* NOTREACHED */    /* NOTREACHED */
119    abort ();    abort ();

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

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