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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [semflush.c] - Blame information for rev 587

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *  rtems_semaphore_flush
3
 *
4
 *  DESCRIPTION:
5
 *
6
 *  This package is the implementation of the flush directive
7
 *  of the Semaphore Manager.
8
 *
9
 *  COPYRIGHT (c) 1989-1999.
10
 *  On-Line Applications Research Corporation (OAR).
11
 *
12
 *  The license and distribution terms for this file may be
13
 *  found in the file LICENSE in this distribution or at
14
 *  http://www.OARcorp.com/rtems/license.html.
15
 *
16
 *  $Id: semflush.c,v 1.2 2001-09-27 11:59:19 chris Exp $
17
 */
18
 
19
#include <rtems/system.h>
20
#include <rtems/rtems/status.h>
21
#include <rtems/rtems/support.h>
22
#include <rtems/rtems/attr.h>
23
#include <rtems/score/isr.h>
24
#include <rtems/score/object.h>
25
#include <rtems/rtems/options.h>
26
#include <rtems/rtems/sem.h>
27
#include <rtems/score/coremutex.h>
28
#include <rtems/score/coresem.h>
29
#include <rtems/score/states.h>
30
#include <rtems/score/thread.h>
31
#include <rtems/score/threadq.h>
32
#if defined(RTEMS_MULTIPROCESSING)
33
#include <rtems/score/mpci.h>
34
#endif
35
#include <rtems/score/sysstate.h>
36
 
37
#include <rtems/score/interr.h>
38
 
39
/*PAGE
40
 *
41
 *  rtems_semaphore_flush
42
 *
43
 *  This directive allows a thread to flush the threads
44
 *  pending on the semaphore.
45
 *
46
 *  Input parameters:
47
 *    id         - semaphore id
48
 *
49
 *  Output parameters:
50
 *    RTEMS_SUCCESSFUL - if successful
51
 *    error code        - if unsuccessful
52
 */
53
 
54
#if defined(RTEMS_MULTIPROCESSING)
55
#define SEND_OBJECT_WAS_DELETED _Semaphore_MP_Send_object_was_deleted
56
#else
57
#define SEND_OBJECT_WAS_DELETED NULL
58
#endif
59
 
60
rtems_status_code rtems_semaphore_flush(
61
  Objects_Id      id
62
)
63
{
64
  register Semaphore_Control *the_semaphore;
65
  Objects_Locations           location;
66
 
67
  the_semaphore = _Semaphore_Get( id, &location );
68
  switch ( location ) {
69
 
70
    case OBJECTS_REMOTE:
71
#if defined(RTEMS_MULTIPROCESSING)
72
      _Thread_Dispatch();
73
      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
74
#endif
75
 
76
    case OBJECTS_ERROR:
77
      return RTEMS_INVALID_ID;
78
 
79
    case OBJECTS_LOCAL:
80
      if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
81
        _CORE_mutex_Flush(
82
          &the_semaphore->Core_control.mutex,
83
          SEND_OBJECT_WAS_DELETED,
84
          CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT
85
        );
86
      } else {
87
        _CORE_semaphore_Flush(
88
          &the_semaphore->Core_control.semaphore,
89
          SEND_OBJECT_WAS_DELETED,
90
          CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT
91
        );
92
      }
93
      _Thread_Enable_dispatch();
94
      return RTEMS_SUCCESSFUL;
95
  }
96
 
97
  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
98
}

powered by: WebSVN 2.1.0

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