OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [src/] [pthreadkill.c] - Blame information for rev 1779

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  3.3.10 Send a Signal to a Thread, P1003.1c/D10, p. 43
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  pthreadkill.c,v 1.7 2002/01/04 18:28:24 joel Exp
12
 */
13
 
14
#if HAVE_CONFIG_H
15
#include "config.h"
16
#endif
17
 
18
#include <pthread.h>
19
#include <signal.h>
20
#include <errno.h>
21
 
22
#include <rtems/system.h>
23
#include <rtems/posix/pthread.h>
24
#include <rtems/posix/psignal.h>
25
#include <rtems/score/isr.h>
26
#include <rtems/seterr.h>
27
 
28
int pthread_kill(
29
  pthread_t   thread,
30
  int         sig
31
)
32
{
33
  POSIX_API_Control  *api;
34
  Thread_Control     *the_thread;
35
  Objects_Locations  location;
36
 
37
  if ( sig && !is_valid_signo(sig) )
38
    rtems_set_errno_and_return_minus_one( EINVAL );
39
 
40
/* commented out when posix timers added
41
  if ( _POSIX_signals_Vectors[ sig ].sa_flags == SA_SIGINFO )
42
    rtems_set_errno_and_return_minus_one( ENOSYS );
43
*/
44
 
45
  the_thread = _POSIX_Threads_Get( thread, &location );
46
  switch ( location ) {
47
    case OBJECTS_ERROR:
48
    case OBJECTS_REMOTE:
49
      rtems_set_errno_and_return_minus_one( ESRCH );
50
    case OBJECTS_LOCAL:
51
      /*
52
       *  If sig == 0 then just validate arguments
53
       */
54
 
55
      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
56
 
57
      if ( sig ) {
58
 
59
        if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
60
          _Thread_Enable_dispatch();
61
          return 0;
62
        }
63
 
64
        /* XXX critical section */
65
 
66
        api->signals_pending |= signo_to_mask( sig );
67
 
68
        (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
69
 
70
        the_thread->do_post_task_switch_extension = TRUE;
71
 
72
        if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
73
          _ISR_Signals_to_thread_executing = TRUE;
74
      }
75
      _Thread_Enable_dispatch();
76
      return 0;
77
  }
78
 
79
  return POSIX_BOTTOM_REACHED();
80
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.