Re: Safe way to write interrupt driven circular buffer tx rx?



<cs_posting@xxxxxxxxxxx> wrote in message
news:1188395695.412412.51620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 29, 8:21 am, "Sven" <S...@xxxxxxx> wrote:
Can someone point out source code for a safe circular buffer receiver
transmitter? It's for sending and receiving bytes via RS232.

What I do is let the interrupt process freely modify the buffer count
& head variables.

The interruptible process modifies the buffer variables in only one
small block of code, which is bracketed with interrupt disable &
enable instructions.

Just be aware that the critical section protocol depends on the "design
rules" for the entire embedded project.

The most common set of design rules is that for critical sections,
interrupts are disabled and enabled. The assumption is that the critical
sections will be short enough that they won't introduce any real-time
difficulties with the invocation of ISRs.

However, in some rare cases, someone may decide that a critical section
should block only interrupts of a certain type, but allow others. The
"design rules" might call for manipulating the only the SCI hardware to
implement the critical section, and only to prevent SCI interrupts.

The DI()/EI() protocol is not universally applicable, but it is nearly so.

Dave.
--
David T. Ashley (dta@xxxxxxxx)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)


.



Relevant Pages

  • Re: High lock spin time for zone->lru_lock under extreme conditions
    ... We noticed high interrupt hold off times while running some memory intensive ... that spin_lock_irq disables interrupts while spinning made matters very bad. ... By buffering the lru pages on a per cpu basis the flush of that buffer ... Streeamline all this by replacing the per cpu buffer with a per zone ...
    (Linux-Kernel)
  • Re: Interrupts disabled for too long in printk
    ... for 72 characters in 15 ms. So the console driver would be ... Why can't the serial console driver record the message in a buffer at ... the point where it is being called with interrupts off, ...
    (Linux-Kernel)
  • Re: Interrupts disabled for too long in printk
    ... >>> Why can't the serial console driver record the message in a buffer at ... >>> the point where it is being called with interrupts off, ... Does the serial console driver revert to a polling ... printk() from interrupt context anyway, so you will not find anybody ...
    (Linux-Kernel)
  • Re: [PATCH 3/3] ring-buffer: make cpu buffer entries counter atomic
    ... The entries counter in cpu buffer is not atomic. ... that's not really good as atomics can be rather expensive and ... As you know, between a lock_reserve and a discard, several interrupts ...
    (Linux-Kernel)
  • Re: [PATCH 3/3] ring-buffer: make cpu buffer entries counter atomic
    ... The entries counter in cpu buffer is not atomic. ... that's not really good as atomics can be rather expensive and ... As you know, between a lock_reserve and a discard, several interrupts ...
    (Linux-Kernel)