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

4.104.114.84.95
Last change on this file since 3127180 was dd687d97, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:56:05

2003-09-04 Joel Sherrill <joel@…>

  • include/rtems/debug.h, include/rtems/seterr.h, include/rtems/system.h, include/rtems/score/address.h, include/rtems/score/apiext.h, include/rtems/score/apimutex.h, include/rtems/score/bitfield.h, include/rtems/score/chain.h, include/rtems/score/context.h, include/rtems/score/copyrt.h, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/heap.h, include/rtems/score/interr.h, include/rtems/score/isr.h, include/rtems/score/mpci.h, include/rtems/score/mppkt.h, include/rtems/score/object.h, include/rtems/score/objectmp.h, include/rtems/score/priority.h, include/rtems/score/stack.h, include/rtems/score/states.h, include/rtems/score/sysstate.h, include/rtems/score/thread.h, include/rtems/score/threadmp.h, include/rtems/score/threadq.h, include/rtems/score/tod.h, include/rtems/score/tqdata.h, include/rtems/score/userext.h, include/rtems/score/watchdog.h, include/rtems/score/wkspace.h, inline/rtems/score/address.inl, inline/rtems/score/chain.inl, inline/rtems/score/coremsg.inl, inline/rtems/score/coremutex.inl, inline/rtems/score/coresem.inl, inline/rtems/score/heap.inl, inline/rtems/score/isr.inl, inline/rtems/score/mppkt.inl, inline/rtems/score/object.inl, inline/rtems/score/objectmp.inl, inline/rtems/score/priority.inl, inline/rtems/score/stack.inl, inline/rtems/score/states.inl, inline/rtems/score/sysstate.inl, inline/rtems/score/thread.inl, inline/rtems/score/threadmp.inl, inline/rtems/score/tod.inl, inline/rtems/score/tqdata.inl, inline/rtems/score/userext.inl, inline/rtems/score/watchdog.inl, inline/rtems/score/wkspace.inl, macros/rtems/score/address.inl, macros/rtems/score/chain.inl, macros/rtems/score/coremsg.inl, macros/rtems/score/coremutex.inl, macros/rtems/score/coresem.inl, macros/rtems/score/heap.inl, macros/rtems/score/isr.inl, macros/rtems/score/mppkt.inl, macros/rtems/score/object.inl, macros/rtems/score/objectmp.inl, macros/rtems/score/priority.inl, macros/rtems/score/stack.inl, macros/rtems/score/states.inl, macros/rtems/score/sysstate.inl, macros/rtems/score/thread.inl, macros/rtems/score/threadmp.inl, macros/rtems/score/tod.inl, macros/rtems/score/tqdata.inl, macros/rtems/score/userext.inl, macros/rtems/score/watchdog.inl, macros/rtems/score/wkspace.inl, src/apiext.c, src/chain.c, src/coremsg.c, src/coremsgbroadcast.c, src/coremsgclose.c, src/coremsgflush.c, src/coremsgflushsupp.c, src/coremsgflushwait.c, src/coremsginsert.c, src/coremsgseize.c, src/coremsgsubmit.c, src/coremutex.c, src/coremutexflush.c, src/coremutexseize.c, src/coremutexsurrender.c, src/coresem.c, src/coresemflush.c, src/coresemseize.c, src/coresemsurrender.c, src/coretod.c, src/coretodset.c, src/coretodtickle.c, src/coretodtoseconds.c, src/coretodvalidate.c, src/heap.c, src/heapallocate.c, src/heapextend.c, src/heapfree.c, src/heapgetinfo.c, src/heapsizeofuserarea.c, src/heapwalk.c, src/interr.c, src/isr.c, src/iterateoverthreads.c, src/mpci.c, src/object.c, src/objectallocate.c, src/objectallocatebyindex.c, src/objectclearname.c, src/objectcomparenameraw.c, src/objectcomparenamestring.c, src/objectcopynameraw.c, src/objectcopynamestring.c, src/objectextendinformation.c, src/objectfree.c, src/objectget.c, src/objectgetbyindex.c, src/objectgetisr.c, src/objectgetnext.c, src/objectgetnoprotection.c, src/objectidtoname.c, src/objectinitializeinformation.c, src/objectmp.c, src/objectnametoid.c, src/objectshrinkinformation.c, src/thread.c, src/threadchangepriority.c, src/threadclearstate.c, src/threadclose.c, src/threadcreateidle.c, src/threaddelayended.c, src/threaddispatch.c, src/threadevaluatemode.c, src/threadget.c, src/threadhandler.c, src/threadidlebody.c, src/threadinitialize.c, src/threadloadenv.c, src/threadmp.c, src/threadq.c, src/threadqdequeue.c, src/threadqdequeuefifo.c, src/threadqdequeuepriority.c, src/threadqenqueue.c, src/threadqenqueuefifo.c, src/threadqenqueuepriority.c, src/threadqextract.c, src/threadqextractfifo.c, src/threadqextractpriority.c, src/threadqextractwithproxy.c, src/threadqfirst.c, src/threadqfirstfifo.c, src/threadqfirstpriority.c, src/threadqflush.c, src/threadqtimeout.c, src/threadready.c, src/threadreset.c, src/threadresettimeslice.c, src/threadrestart.c, src/threadresume.c, src/threadrotatequeue.c, src/threadsetpriority.c, src/threadsetstate.c, src/threadsettransient.c, src/threadstackallocate.c, src/threadstackfree.c, src/threadstart.c, src/threadstartmultitasking.c, src/threadsuspend.c, src/threadtickletimeslice.c, src/threadyieldprocessor.c, src/userext.c, src/watchdog.c, src/watchdogadjust.c, src/watchdoginsert.c, src/watchdogremove.c, src/watchdogtickle.c, src/wkspace.c: URL for license changed.
  • 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#include <rtems/system.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/coresem.h>
23#include <rtems/score/states.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#if defined(RTEMS_MULTIPROCESSING)
27#include <rtems/score/mpci.h>
28#endif
29
30/*PAGE
31 *
32 *  _CORE_semaphore_Surrender
33 *
34 *  Input parameters:
35 *    the_semaphore            - the semaphore to be flushed
36 *    id                       - id of parent semaphore
37 *    api_semaphore_mp_support - api dependent MP support actions
38 *
39 *  Output parameters:
40 *    CORE_SEMAPHORE_STATUS_SUCCESSFUL - if successful
41 *    core error code                  - if unsuccessful
42 *
43 *  Output parameters:
44 */
45
46CORE_semaphore_Status _CORE_semaphore_Surrender(
47  CORE_semaphore_Control                *the_semaphore,
48  Objects_Id                             id,
49  CORE_semaphore_API_mp_support_callout  api_semaphore_mp_support
50)
51{
52  Thread_Control *the_thread;
53  ISR_Level       level;
54  CORE_semaphore_Status status;
55
56  status = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
57
58  if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) {
59
60    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
61      (*api_semaphore_mp_support) ( the_thread, id );
62
63  } else {
64    _ISR_Disable( level );
65      if ( the_semaphore->count < the_semaphore->Attributes.maximum_count )
66        the_semaphore->count += 1;
67      else
68        status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
69    _ISR_Enable( level );
70  }
71
72  return status;
73}
74
Note: See TracBrowser for help on using the repository browser.