source: rtems/cpukit/posix/src/pthreadkill.c @ 2d2352b

4.115
Last change on this file since 2d2352b was 2d2352b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57

score: Add and use _Objects_Put()

Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Sends a signal Asynchronously directed to a thread
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  3.3.10 Send a Signal to a Thread, P1003.1c/D10, p. 43
10 *
11 *  COPYRIGHT (c) 1989-2007.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <pthread.h>
24#include <signal.h>
25#include <errno.h>
26
27#include <rtems/system.h>
28#include <rtems/posix/pthread.h>
29#include <rtems/posix/psignalimpl.h>
30#include <rtems/score/isr.h>
31#include <rtems/seterr.h>
32
33int pthread_kill(
34  pthread_t   thread,
35  int         sig
36)
37{
38  POSIX_API_Control  *api;
39  Thread_Control     *the_thread;
40  Objects_Locations  location;
41
42  if ( !sig )
43    rtems_set_errno_and_return_minus_one( EINVAL );
44
45  if ( !is_valid_signo(sig) )
46    rtems_set_errno_and_return_minus_one( EINVAL );
47
48  the_thread = _Thread_Get( thread, &location );
49  switch ( location ) {
50
51    case OBJECTS_LOCAL:
52      /*
53       *  If sig == 0 then just validate arguments
54       */
55
56      _POSIX_signals_Add_post_switch_extension();
57
58      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
59
60      if ( sig ) {
61
62        if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
63          _Objects_Put( &the_thread->Object );
64          return 0;
65        }
66
67        /* XXX critical section */
68
69        api->signals_pending |= signo_to_mask( sig );
70
71        (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
72
73        if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
74          _Thread_Dispatch_necessary = true;
75      }
76      _Objects_Put( &the_thread->Object );
77      return 0;
78
79#if defined(RTEMS_MULTIPROCESSING)
80    case OBJECTS_REMOTE:
81#endif
82    case OBJECTS_ERROR:
83      break;
84  }
85
86  rtems_set_errno_and_return_minus_one( ESRCH );
87}
Note: See TracBrowser for help on using the repository browser.