source: rtems/c/src/lib/libbsp/powerpc/psim/shmsupp/lock.c @ 252dea2f

4.104.114.95
Last change on this file since 252dea2f was 252dea2f, checked in by Joel Sherrill <joel.sherrill@…>, on 09/05/08 at 21:33:41

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

  • shmsupp/lock.c: Disable CPU interrupts when we have the shared memory locked. This is necessary to prevent deadlock.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*  Shared Memory Lock Routines
2 *
3 *  This shared memory locked queue support routine need to be
4 *  able to lock the specified locked queue.  Interrupts are
5 *  disabled while the queue is locked to prevent preemption
6 *  and deadlock when two tasks poll for the same lock.
7 *  previous level.
8 *
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may in
13 *  the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <rtems.h>
20#include <bsp.h>
21#include <shm_driver.h>
22#include <psim.h>
23
24/*
25 *  Shm_Initialize_lock
26 *
27 *  Initialize the lock for the specified locked queue.
28 */
29
30void Shm_Initialize_lock(
31  Shm_Locked_queue_Control *lq_cb
32)
33{
34  /* nothing required -- done implicitly by device tree */
35}
36
37/*  void _Shm_Lock( &lq_cb )
38 *
39 *  This shared memory locked queue support routine locks the
40 *  specified locked queue.  It disables interrupts to prevent
41 *  a deadlock condition.
42 */
43
44static rtems_interrupt_level level;
45
46void Shm_Lock(
47  Shm_Locked_queue_Control *lq_cb
48)
49{
50  rtems_interrupt_disable( level );
51    (void) PSIM.Semaphore.lock;
52}
53
54/*
55 *  Shm_Unlock
56 *
57 *  Unlock the lock for the specified locked queue.
58 */
59
60void Shm_Unlock(
61  Shm_Locked_queue_Control *lq_cb
62)
63{
64    (void) PSIM.Semaphore.unlock;
65  rtems_interrupt_enable( level );
66}
Note: See TracBrowser for help on using the repository browser.