Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Semaphore inside an ISR?

Status
Not open for further replies.

webmegamaster

Newbie level 4
Newbie level 4
Joined
Nov 17, 2005
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,325
semaphore in isr

can we use semaphore inside an ISR? if so, how?
 

NO. Semaphores can not be used in ISRs

When a task attempts to acquire a semaphore that is already held, the semaphore places the task onto a wait queue and puts the task to sleep. but we are not allowed to sleep inside an ISR. so semaphores cannt be used in ISRs.

But we can use Spin Locks instead of semaphores.

A spin lock is a lock that can be held by at most one thread of execution. If a thread of execution attempts to acquire a spin lock while it is contended (already held), the thread busy loopsspinswaiting for the lock to become available. If the lock is not contended, the thread can immediately acquire the lock and continue. The spinning prevents more than one thread of execution from entering the critical region at any one time. Note that the same lock can be used in multiple locationsso all access to a given data structure, for example, can be protected and synchronized.

**Spin Locks are used for short term locks and semaphores for Long term locks**
 

Yes You Can .. the way control the P/V
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top