Changeset ef3640f7 in rtems


Ignore:
Timestamp:
Aug 26, 2013, 1:25:58 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
75f6d18
Parents:
4957272
git-author:
Sebastian Huber <sebastian.huber@…> (08/26/13 13:25:58)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/27/13 08:48:17)
Message:

ringbuf: Add SMP support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/ringbuf.h

    r4957272 ref3640f7  
    1111#define _RTEMS_RINGBUF_H
    1212
     13#include <rtems.h>
     14
    1315#ifndef RINGBUF_QUEUE_LENGTH
    1416#define RINGBUF_QUEUE_LENGTH 128
     
    1921  volatile int  head;
    2022  volatile int  tail;
     23  rtems_interrupt_lock lock;
    2124} Ring_buffer_t;
    2225
     
    3437#define Ring_buffer_Add_character( _buffer, _ch ) \
    3538  do { \
    36     uint32_t  isrlevel; \
     39    rtems_interrupt_level isrlevel; \
    3740    \
    38     rtems_interrupt_disable( isrlevel ); \
     41    rtems_interrupt_lock_acquire( &(_buffer)->lock, isrlevel ); \
    3942      (_buffer)->tail = ((_buffer)->tail+1) % RINGBUF_QUEUE_LENGTH; \
    4043      (_buffer)->buffer[ (_buffer)->tail ] = (_ch); \
    41     rtems_interrupt_enable( isrlevel ); \
     44    rtems_interrupt_lock_release( &(_buffer)->lock, isrlevel ); \
    4245  } while ( 0 )
    4346
    4447#define Ring_buffer_Remove_character( _buffer, _ch ) \
    4548  do { \
    46     uint32_t  isrlevel; \
     49    rtems_interrupt_level isrlevel; \
    4750    \
    48     rtems_interrupt_disable( isrlevel ); \
     51    rtems_interrupt_lock_acquire( &(_buffer)->lock, isrlevel ); \
    4952      (_buffer)->head = ((_buffer)->head+1) % RINGBUF_QUEUE_LENGTH; \
    5053      (_ch) = (_buffer)->buffer[ (_buffer)->head ]; \
    51     rtems_interrupt_enable( isrlevel ); \
     54    rtems_interrupt_lock_release( &(_buffer)->lock, isrlevel ); \
    5255  } while ( 0 )
    5356
Note: See TracChangeset for help on using the changeset viewer.