source: rtems/cpukit/score/src/coresemsurrender.c @ eea7c937

4.115
Last change on this file since eea7c937 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.h contains now only the
application visible API.

  • 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.com/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.