eCosTM Reference Manual
Prev | Chapter 13. Device Driver Interface to the Kernel | Next

# Synchronization

There are three levels of synchronization supported:

1. Synchronization with ISRs. This normally means disabling interrupts to prevent the ISR running during a critical section. On a multiprocessor this will also require a spinlock. This is implemented by the `cyg_drv_isr_lock()` and `cyg_drv_isr_unlock()` functions. This mechanism should be used sparingly and for short periods only.

2. Synchronization with DSRs. This will be implemented in the kernel by taking the scheduler lock to prevent DSRs running during critical sections. In non-kernel configurations it will be implemented by non-kernel code. This is implemented by the `cyg_drv_dsr_lock()` and `cyg_drv_dsr_unlock()` functions. As with ISR synchronization, this mechanism should be used sparingly.

3. Synchronization with threads. This is implemented with mutexes and condition variables. Only threads may lock the mutexes and wait on the condition variables, although DSRs may signal condition variables.

ISRs are run with interrupts disabled, so it is not necessary to call `cyg_drv_isr_lock()` in an ISR. Similarly DSRs are run with the scheduler lock taken, so it is not necessary to call `cyg_drv_dsr_lock()` in DSRs.

Prev | Home | Next
Device Driver Interface to the Kernel | Up | Device Driver Models