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

4.10
Last change on this file since e3f6d35 was b3836ce, checked in by Joel Sherrill <joel.sherrill@…>, on 09/05/08 at 21:54:20

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • score/src/corebarrier.c, score/src/corebarrierrelease.c, score/src/corebarrierwait.c, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgflushwait.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/corerwlock.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coresemseize.c, score/src/coresemsurrender.c, score/src/corespinlock.c, score/src/threadblockingoperationcancel.c, score/src/threadqenqueue.c: Remove unnecessary include of mpci.h.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  CORE Semaphore Handler
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the CORE Semaphore Handler.
7 *  This core object utilizes standard Dijkstra counting semaphores to provide
8 *  synchronization and mutual exclusion capabilities.
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 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/system.h>
25#include <rtems/score/isr.h>
26#include <rtems/score/coresem.h>
27#include <rtems/score/states.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/threadq.h>
30
31/*PAGE
32 *
33 *  _CORE_semaphore_Surrender
34 *
35 *  Input parameters:
36 *    the_semaphore            - the semaphore to be flushed
37 *    id                       - id of parent semaphore
38 *    api_semaphore_mp_support - api dependent MP support actions
39 *
40 *  Output parameters:
41 *    CORE_SEMAPHORE_STATUS_SUCCESSFUL - if successful
42 *    core error code                  - if unsuccessful
43 *
44 *  Output parameters:
45 */
46
47CORE_semaphore_Status _CORE_semaphore_Surrender(
48  CORE_semaphore_Control                *the_semaphore,
49  Objects_Id                             id,
50  CORE_semaphore_API_mp_support_callout  api_semaphore_mp_support
51)
52{
53  Thread_Control *the_thread;
54  ISR_Level       level;
55  CORE_semaphore_Status status;
56
57  status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
58
59  if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
60
61#if defined(RTEMS_MULTIPROCESSING)
62    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
63      (*api_semaphore_mp_support) ( the_thread, id );
64#endif
65
66  } else {
67    _ISR_Disable( level );
68      if ( the_semaphore->count < the_semaphore->Attributes.maximum_count )
69        the_semaphore->count += 1;
70      else
71        status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
72    _ISR_Enable( level );
73  }
74
75  return status;
76}
Note: See TracBrowser for help on using the repository browser.