source: rtems/cpukit/score/src/coresemsurrender.c @ 439c494

4.115
Last change on this file since 439c494 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Surrenders a Unit to a Semaphore
5 *
6 * @ingroup ScoreSemaphore
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/coresemimpl.h>
23#include <rtems/score/objectimpl.h>
24
25CORE_semaphore_Status _CORE_semaphore_Surrender(
26  CORE_semaphore_Control                *the_semaphore,
27  Objects_Id                             id,
28  CORE_semaphore_API_mp_support_callout  api_semaphore_mp_support
29)
30{
31  Thread_Control *the_thread;
32  ISR_Level       level;
33  CORE_semaphore_Status status;
34
35  status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
36
37  if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
38
39#if defined(RTEMS_MULTIPROCESSING)
40    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
41      (*api_semaphore_mp_support) ( the_thread, id );
42#endif
43
44  } else {
45    _ISR_Disable( level );
46      if ( the_semaphore->count < the_semaphore->Attributes.maximum_count )
47        the_semaphore->count += 1;
48      else
49        status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
50    _ISR_Enable( level );
51  }
52
53  return status;
54}
Note: See TracBrowser for help on using the repository browser.