source: rtems/c/src/lib/libbsp/unix/posix/shmsupp/lock.c @ 49c8f45

4.104.115
Last change on this file since 49c8f45 was 40d6543, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 05:19:16

2004-03-31 Ralf Corsepius <ralf_corsepius@…>

  • clock/clock.c, include/bsp.h, shmsupp/cause_intr.c, shmsupp/getcfg.c, shmsupp/lock.c, startup/bspstart.c: Convert to using c99 fixed size types.
  • 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-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <bsp.h>
20#include <shm_driver.h>
21
22/*
23 *  Shm_Initialize_lock
24 *
25 *  Initialize the lock for the specified locked queue.
26 */
27
28void Shm_Initialize_lock(
29  Shm_Locked_queue_Control *lq_cb
30)
31{
32  lq_cb->lock = lq_cb - Shm_Locked_queues;
33}
34
35/*  Shm_Lock( &lq_cb )
36 *
37 *  This shared memory locked queue support routine locks the
38 *  specified locked queue.  It disables interrupts to prevent
39 *  a deadlock condition.
40 */
41
42void Shm_Lock(
43  Shm_Locked_queue_Control *lq_cb
44)
45{
46  uint32_t           isr_level;
47
48  rtems_interrupt_disable( isr_level );
49
50  Shm_isrstat = isr_level;
51
52  _CPU_SHM_Lock( lq_cb->lock );
53}
54
55/*
56 *  Shm_Unlock
57 *
58 *  Unlock the lock for the specified locked queue.
59 */
60
61void Shm_Unlock(
62  Shm_Locked_queue_Control *lq_cb
63)
64{
65  uint32_t           isr_level;
66
67  _CPU_SHM_Unlock( lq_cb->lock );
68
69  isr_level = Shm_isrstat;
70  rtems_interrupt_enable( isr_level );
71}
Note: See TracBrowser for help on using the repository browser.