source: rtems/cpukit/score/src/corespinlockrelease.c @ da42259

4.104.115
Last change on this file since da42259 was 8a8f5b2, checked in by Glenn Humphrey <glenn.humphrey@…>, on 11/06/07 at 19:52:36

2007-11-06 Glenn Humphrey <glenn.humphrey@…>

Miscellaneous changes made after a review against the POSIX spec.

  • posix/src/pbarrierinit.c, posix/src/prwlockinit.c: If the caller passes a NULL in the attributes parameter, default attributes are used.
  • posix/src/prwlockdestroy.c: If there is at least one thread waiting, do not allow deletion.
  • posix/src/prwlockwrlock.c: Corrected parameter passed to the core operation used to obtain a RWLock for writing.
  • posix/src/pspinlocktranslatereturncode.c, score/include/rtems/score/corespinlock.h, score/src/corespinlockrelease.c: If the current thread is not the holder of the lock, do not allow an unlock and return EPERM.
  • score/src/corerwlockobtainwrite.c: Corrected to use the operation for queueing with a timeout handler.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  SuperCore Spinlock Handler -- Release a Spinlock
3 *
4 *  COPYRIGHT (c) 1989-2006.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/corespinlock.h>
20#include <rtems/score/states.h>
21#include <rtems/score/thread.h>
22#include <rtems/score/watchdog.h>
23
24/*PAGE
25 *
26 *  _CORE_spinlock_Release
27 *
28 *  This function releases the spinlock.
29 *
30 *  Input parameters:
31 *    the_spinlock    - the spinlock control block to initialize
32 *
33 *  Output parameters:
34 *    CORE_SPINLOCK_SUCCESSFUL - if successful
35 *    error code               - if unsuccessful
36 *
37 */
38
39CORE_spinlock_Status _CORE_spinlock_Release(
40  CORE_spinlock_Control  *the_spinlock
41)
42{
43  ISR_Level level;
44
45  _ISR_Disable( level );
46
47    /*
48     *  It must locked before it can be unlocked.
49     */
50    if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) {
51      _ISR_Enable( level );
52      return CORE_SPINLOCK_NOT_LOCKED;
53    }
54
55    /*
56     *  It must locked by the current thread before it can be unlocked.
57     */
58    if ( the_spinlock->holder != _Thread_Executing->Object.id ) {
59      _ISR_Enable( level );
60      return CORE_SPINLOCK_NOT_HOLDER;
61    }
62   
63    /*
64     *  Let it be unlocked.
65     */
66    the_spinlock->users -= 1;
67    the_spinlock->lock   = CORE_SPINLOCK_UNLOCKED;
68    the_spinlock->holder = 0;
69
70  _ISR_Enable( level );
71  return CORE_SPINLOCK_SUCCESSFUL;
72}
Note: See TracBrowser for help on using the repository browser.