Changeset f845e96 in rtems


Ignore:
Timestamp:
Jul 5, 2002, 6:13:18 PM (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
485c974
Parents:
4a2b4f0
Message:

2002-07-05 Joel Sherrill <joel@…>

  • include/rtems/posix/cancel.h, src/cancel.c, src/cancelrun.c, src/mqueue.c, src/pthread.c, src/semaphore.c, src/setcancelstate.c, src/setcanceltype.c, src/testcancel.c: Per PR164, corrected the behavior of thread cancellation and did some cleanup as a side-effect.
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/ChangeLog

    r4a2b4f0 rf845e96  
     12002-07-05      Joel Sherrill <joel@OARcorp.com>
     2
     3        * include/rtems/posix/cancel.h, src/cancel.c, src/cancelrun.c,
     4        src/mqueue.c, src/pthread.c, src/semaphore.c, src/setcancelstate.c,
     5        src/setcanceltype.c, src/testcancel.c:  Per PR164, corrected the
     6        behavior of thread cancellation and did some cleanup as a side-effect.
     7
    182002-07-05      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    29
  • c/src/exec/posix/include/rtems/posix/cancel.h

    r4a2b4f0 rf845e96  
    1414
    1515/*
    16  *  _POSIX_Thread_cancel_run
     16 *  _POSIX_Threads_cancel_run
    1717 *
    1818 *  DESCRIPTION:
     
    2222 */
    2323
    24 void _POSIX_Thread_cancel_run(
     24void _POSIX_Threads_cancel_run(
    2525  Thread_Control *the_thread
    2626);
  • c/src/exec/posix/src/cancel.c

    r4a2b4f0 rf845e96  
    3232  Objects_Locations                  location;
    3333
     34  /*
     35   *  Don't even think about deleting a resource from an ISR.
     36   */
     37
     38  if ( _ISR_Is_in_progress() )
     39    return EPROTO;
     40
    3441  the_thread = _POSIX_Threads_Get( thread, &location );
    3542  switch ( location ) {
     
    4350      thread_support->cancelation_requested = 1;
    4451
     52      if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     53           thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS ) {
     54        _POSIX_Threads_cancel_run( the_thread );
     55      }
     56
    4557      _Thread_Enable_dispatch();
    4658      return 0;
  • c/src/exec/posix/src/cancelrun.c

    r4a2b4f0 rf845e96  
    2121/*PAGE
    2222 *
    23  *  _POSIX_Thread_cancel_run
     23 *  _POSIX_Threads_cancel_run
    2424 *
    2525 */
    2626
    27 void _POSIX_Thread_cancel_run(
     27#if !defined(PTHREAD_CANCELED)
     28#warning "PTHREAD_CANCELED NOT DEFINED -- patch newlib"
     29#define PTHREAD_CANCELED ((void *) -1)
     30#endif
     31
     32void _POSIX_Threads_cancel_run(
    2833  Thread_Control *the_thread
    2934)
    3035{
    31   int                                old_cancel_state;
    3236  POSIX_Cancel_Handler_control      *handler;
    3337  Chain_Control                     *handler_stack;
     
    3943  handler_stack = &thread_support->Cancellation_Handlers;
    4044 
    41   old_cancel_state = thread_support->cancelability_state;
    42 
    4345  thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;
    4446
     
    5456  }
    5557
    56   thread_support->cancelation_requested = 0;
     58  /* Now we can delete the thread */
    5759
    58   thread_support->cancelability_state = old_cancel_state;
     60  the_thread->Wait.return_argument = (unsigned32 *)PTHREAD_CANCELED;
     61  _Thread_Close(
     62    _Objects_Get_information( the_thread->Object.id ),
     63    the_thread
     64  );
     65  _POSIX_Threads_Free( the_thread );
     66
    5967}
  • c/src/exec/posix/src/mqueue.c

    r4a2b4f0 rf845e96  
    5656    sizeof( POSIX_Message_queue_Control ),
    5757                                /* size of this object's control block */
    58     FALSE,                      /* TRUE if names for this object are strings */
     58    TRUE,                       /* TRUE if names for this object are strings */
    5959    _POSIX_PATH_MAX             /* maximum length of each object's name */
    6060#if defined(RTEMS_MULTIPROCESSING)
  • c/src/exec/posix/src/pthread.c

    r4a2b4f0 rf845e96  
    208208  api = deleted->API_Extensions[ THREAD_API_POSIX ];
    209209 
    210   /* XXX run cancellation handlers */
     210  /*
     211   *  Run the POSIX cancellation handlers
     212   */
    211213
    212214  _POSIX_Keys_Run_destructors( deleted );
     
    374376 
    375377  _User_extensions_Add_API_set( &_POSIX_Threads_User_extensions );
    376  
     378
    377379  _API_extensions_Add( &_POSIX_Threads_API_extensions );
     380
    378381 
    379382  /*
  • c/src/exec/posix/src/semaphore.c

    r4a2b4f0 rf845e96  
    4444    sizeof( POSIX_Semaphore_Control ),
    4545                                /* size of this object's control block */
    46     FALSE,                      /* TRUE if names for this object are strings */
     46    TRUE,                       /* TRUE if names for this object are strings */
    4747    _POSIX_PATH_MAX             /* maximum length of each object's name */
    4848#if defined(RTEMS_MULTIPROCESSING)
  • c/src/exec/posix/src/setcancelstate.c

    r4a2b4f0 rf845e96  
    3131  POSIX_API_Control                 *thread_support;
    3232
     33  /*
     34   *  Don't even think about deleting a resource from an ISR.
     35   *  Besides this request is supposed to be for _Thread_Executing
     36   *  and the ISR context is not a thread.
     37   */
     38
     39  if ( _ISR_Is_in_progress() )
     40    return EPROTO;
     41
    3342  if ( !oldstate )
    3443    return EINVAL;
     
    3948  thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
    4049 
    41   *oldstate = thread_support->cancelability_state;
    42   thread_support->cancelability_state = state;
     50  _Thread_Disable_dispatch();
     51    *oldstate = thread_support->cancelability_state;
     52    thread_support->cancelability_state = state;
    4353 
    44   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
    45        thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
    46        thread_support->cancelation_requested )
    47     _POSIX_Thread_cancel_run( _Thread_Executing );
     54    if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     55         thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
     56         thread_support->cancelation_requested )
     57      _POSIX_Threads_cancel_run( _Thread_Executing );
     58  _Thread_Enable_dispatch();
    4859 
    4960  return 0;
  • c/src/exec/posix/src/setcanceltype.c

    r4a2b4f0 rf845e96  
    3131  POSIX_API_Control                 *thread_support;
    3232 
     33  /*
     34   *  Don't even think about deleting a resource from an ISR.
     35   *  Besides this request is supposed to be for _Thread_Executing
     36   *  and the ISR context is not a thread.
     37   */
     38
     39  if ( _ISR_Is_in_progress() )
     40    return EPROTO;
     41
    3342  if ( !oldtype )
    3443    return EINVAL;
     
    3948  thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
    4049
    41   *oldtype = thread_support->cancelability_type;
    42   thread_support->cancelability_type = type;
     50  _Thread_Disable_dispatch();
     51    *oldtype = thread_support->cancelability_type;
     52    thread_support->cancelability_type = type;
    4353
    44   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
    45        thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
    46        thread_support->cancelation_requested )
    47     _POSIX_Thread_cancel_run( _Thread_Executing );
     54    if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     55         thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
     56         thread_support->cancelation_requested )
     57      _POSIX_Threads_cancel_run( _Thread_Executing );
     58  _Thread_Enable_dispatch();
    4859
    4960  return 0;
  • c/src/exec/posix/src/testcancel.c

    r4a2b4f0 rf845e96  
    2828  POSIX_API_Control                 *thread_support;
    2929
     30  /*
     31   *  Don't even think about deleting a resource from an ISR.
     32   *  Besides this request is supposed to be for _Thread_Executing
     33   *  and the ISR context is not a thread.
     34   */
     35
     36  if ( _ISR_Is_in_progress() )
     37    return;
     38
    3039  thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
    3140 
    32   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
    33        thread_support->cancelation_requested )
    34     _POSIX_Thread_cancel_run( _Thread_Executing );
     41  _Thread_Disable_dispatch();
     42    if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     43         thread_support->cancelation_requested )
     44      _POSIX_Threads_cancel_run( _Thread_Executing );
     45  _Thread_Enable_dispatch();
    3546}
  • cpukit/posix/ChangeLog

    r4a2b4f0 rf845e96  
     12002-07-05      Joel Sherrill <joel@OARcorp.com>
     2
     3        * include/rtems/posix/cancel.h, src/cancel.c, src/cancelrun.c,
     4        src/mqueue.c, src/pthread.c, src/semaphore.c, src/setcancelstate.c,
     5        src/setcanceltype.c, src/testcancel.c:  Per PR164, corrected the
     6        behavior of thread cancellation and did some cleanup as a side-effect.
     7
    182002-07-05      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    29
  • cpukit/posix/include/rtems/posix/cancel.h

    r4a2b4f0 rf845e96  
    1414
    1515/*
    16  *  _POSIX_Thread_cancel_run
     16 *  _POSIX_Threads_cancel_run
    1717 *
    1818 *  DESCRIPTION:
     
    2222 */
    2323
    24 void _POSIX_Thread_cancel_run(
     24void _POSIX_Threads_cancel_run(
    2525  Thread_Control *the_thread
    2626);
  • cpukit/posix/src/cancel.c

    r4a2b4f0 rf845e96  
    3232  Objects_Locations                  location;
    3333
     34  /*
     35   *  Don't even think about deleting a resource from an ISR.
     36   */
     37
     38  if ( _ISR_Is_in_progress() )
     39    return EPROTO;
     40
    3441  the_thread = _POSIX_Threads_Get( thread, &location );
    3542  switch ( location ) {
     
    4350      thread_support->cancelation_requested = 1;
    4451
     52      if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     53           thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS ) {
     54        _POSIX_Threads_cancel_run( the_thread );
     55      }
     56
    4557      _Thread_Enable_dispatch();
    4658      return 0;
  • cpukit/posix/src/cancelrun.c

    r4a2b4f0 rf845e96  
    2121/*PAGE
    2222 *
    23  *  _POSIX_Thread_cancel_run
     23 *  _POSIX_Threads_cancel_run
    2424 *
    2525 */
    2626
    27 void _POSIX_Thread_cancel_run(
     27#if !defined(PTHREAD_CANCELED)
     28#warning "PTHREAD_CANCELED NOT DEFINED -- patch newlib"
     29#define PTHREAD_CANCELED ((void *) -1)
     30#endif
     31
     32void _POSIX_Threads_cancel_run(
    2833  Thread_Control *the_thread
    2934)
    3035{
    31   int                                old_cancel_state;
    3236  POSIX_Cancel_Handler_control      *handler;
    3337  Chain_Control                     *handler_stack;
     
    3943  handler_stack = &thread_support->Cancellation_Handlers;
    4044 
    41   old_cancel_state = thread_support->cancelability_state;
    42 
    4345  thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;
    4446
     
    5456  }
    5557
    56   thread_support->cancelation_requested = 0;
     58  /* Now we can delete the thread */
    5759
    58   thread_support->cancelability_state = old_cancel_state;
     60  the_thread->Wait.return_argument = (unsigned32 *)PTHREAD_CANCELED;
     61  _Thread_Close(
     62    _Objects_Get_information( the_thread->Object.id ),
     63    the_thread
     64  );
     65  _POSIX_Threads_Free( the_thread );
     66
    5967}
  • cpukit/posix/src/mqueue.c

    r4a2b4f0 rf845e96  
    5656    sizeof( POSIX_Message_queue_Control ),
    5757                                /* size of this object's control block */
    58     FALSE,                      /* TRUE if names for this object are strings */
     58    TRUE,                       /* TRUE if names for this object are strings */
    5959    _POSIX_PATH_MAX             /* maximum length of each object's name */
    6060#if defined(RTEMS_MULTIPROCESSING)
  • cpukit/posix/src/pthread.c

    r4a2b4f0 rf845e96  
    208208  api = deleted->API_Extensions[ THREAD_API_POSIX ];
    209209 
    210   /* XXX run cancellation handlers */
     210  /*
     211   *  Run the POSIX cancellation handlers
     212   */
    211213
    212214  _POSIX_Keys_Run_destructors( deleted );
     
    374376 
    375377  _User_extensions_Add_API_set( &_POSIX_Threads_User_extensions );
    376  
     378
    377379  _API_extensions_Add( &_POSIX_Threads_API_extensions );
     380
    378381 
    379382  /*
  • cpukit/posix/src/semaphore.c

    r4a2b4f0 rf845e96  
    4444    sizeof( POSIX_Semaphore_Control ),
    4545                                /* size of this object's control block */
    46     FALSE,                      /* TRUE if names for this object are strings */
     46    TRUE,                       /* TRUE if names for this object are strings */
    4747    _POSIX_PATH_MAX             /* maximum length of each object's name */
    4848#if defined(RTEMS_MULTIPROCESSING)
  • cpukit/posix/src/setcancelstate.c

    r4a2b4f0 rf845e96  
    3131  POSIX_API_Control                 *thread_support;
    3232
     33  /*
     34   *  Don't even think about deleting a resource from an ISR.
     35   *  Besides this request is supposed to be for _Thread_Executing
     36   *  and the ISR context is not a thread.
     37   */
     38
     39  if ( _ISR_Is_in_progress() )
     40    return EPROTO;
     41
    3342  if ( !oldstate )
    3443    return EINVAL;
     
    3948  thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
    4049 
    41   *oldstate = thread_support->cancelability_state;
    42   thread_support->cancelability_state = state;
     50  _Thread_Disable_dispatch();
     51    *oldstate = thread_support->cancelability_state;
     52    thread_support->cancelability_state = state;
    4353 
    44   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
    45        thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
    46        thread_support->cancelation_requested )
    47     _POSIX_Thread_cancel_run( _Thread_Executing );
     54    if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     55         thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
     56         thread_support->cancelation_requested )
     57      _POSIX_Threads_cancel_run( _Thread_Executing );
     58  _Thread_Enable_dispatch();
    4859 
    4960  return 0;
  • cpukit/posix/src/setcanceltype.c

    r4a2b4f0 rf845e96  
    3131  POSIX_API_Control                 *thread_support;
    3232 
     33  /*
     34   *  Don't even think about deleting a resource from an ISR.
     35   *  Besides this request is supposed to be for _Thread_Executing
     36   *  and the ISR context is not a thread.
     37   */
     38
     39  if ( _ISR_Is_in_progress() )
     40    return EPROTO;
     41
    3342  if ( !oldtype )
    3443    return EINVAL;
     
    3948  thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
    4049
    41   *oldtype = thread_support->cancelability_type;
    42   thread_support->cancelability_type = type;
     50  _Thread_Disable_dispatch();
     51    *oldtype = thread_support->cancelability_type;
     52    thread_support->cancelability_type = type;
    4353
    44   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
    45        thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
    46        thread_support->cancelation_requested )
    47     _POSIX_Thread_cancel_run( _Thread_Executing );
     54    if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     55         thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
     56         thread_support->cancelation_requested )
     57      _POSIX_Threads_cancel_run( _Thread_Executing );
     58  _Thread_Enable_dispatch();
    4859
    4960  return 0;
  • cpukit/posix/src/testcancel.c

    r4a2b4f0 rf845e96  
    2828  POSIX_API_Control                 *thread_support;
    2929
     30  /*
     31   *  Don't even think about deleting a resource from an ISR.
     32   *  Besides this request is supposed to be for _Thread_Executing
     33   *  and the ISR context is not a thread.
     34   */
     35
     36  if ( _ISR_Is_in_progress() )
     37    return;
     38
    3039  thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
    3140 
    32   if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
    33        thread_support->cancelation_requested )
    34     _POSIX_Thread_cancel_run( _Thread_Executing );
     41  _Thread_Disable_dispatch();
     42    if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
     43         thread_support->cancelation_requested )
     44      _POSIX_Threads_cancel_run( _Thread_Executing );
     45  _Thread_Enable_dispatch();
    3546}
Note: See TracChangeset for help on using the changeset viewer.