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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [pthreadkill.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 *  $Id: pthreadkill.c,v 1.2 2001-09-27 11:59:17 chris Exp $
12
 */
13
 
14
 
15
#include <pthread.h>
16
#include <errno.h>
17
 
18
#include <rtems/system.h>
19
#include <rtems/posix/pthread.h>
20
#include <rtems/posix/psignal.h>
21
#include <rtems/score/isr.h>
22
#include <rtems/posix/seterr.h>
23
 
24
int pthread_kill(
25
  pthread_t   thread,
26
  int         sig
27
)
28
{
29
  POSIX_API_Control  *api;
30
  Thread_Control     *the_thread;
31
  Objects_Locations  location;
32
 
33
  if ( sig && !is_valid_signo(sig) )
34
    set_errno_and_return_minus_one( EINVAL );
35
 
36
/* commented out when posix timers added
37
  if ( _POSIX_signals_Vectors[ sig ].sa_flags == SA_SIGINFO )
38
    set_errno_and_return_minus_one( ENOSYS );
39
*/
40
 
41
  the_thread = _POSIX_Threads_Get( thread, &location );
42
  switch ( location ) {
43
    case OBJECTS_ERROR:
44
    case OBJECTS_REMOTE:
45
      set_errno_and_return_minus_one( ESRCH );
46
    case OBJECTS_LOCAL:
47
      /*
48
       *  If sig == 0 then just validate arguments
49
       */
50
 
51
      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
52
 
53
      if ( sig ) {
54
 
55
        if ( _POSIX_signals_Vectors[ sig ].sa_handler == SIG_IGN ) {
56
          _Thread_Enable_dispatch();
57
          return 0;
58
        }
59
 
60
        /* XXX critical section */
61
 
62
        api->signals_pending |= signo_to_mask( sig );
63
 
64
        (void) _POSIX_signals_Unblock_thread( the_thread, sig, NULL );
65
 
66
        the_thread->do_post_task_switch_extension = TRUE;
67
 
68
        if ( _ISR_Is_in_progress() && _Thread_Is_executing( the_thread ) )
69
          _ISR_Signals_to_thread_executing = TRUE;
70
      }
71
      _Thread_Enable_dispatch();
72
      return 0;
73
  }
74
 
75
  return POSIX_BOTTOM_REACHED();
76
}

powered by: WebSVN 2.1.0

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