What are hardware and software locks? Topic is solved

If you have a simple question and just want an answer.
sudha
Member
Posts: 14
Joined: Thu Oct 17, 2013 12:19 pm

What are hardware and software locks?

Post by sudha »

Mutual exclusion between a number of threads can be performed using locks. When do we use locks? How can we decide on using hardware and software locks?



View Solution
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

Locks provide a way of sharing resources (e.g. memory buffers) safely between multiple cores. There are 4 hardware locks which are execute in less instructions and provide guarantees of ordering between multiple cores trying to share the same resource. It is also possible to perform locking in software. There is a library (git://github.com/xcore/sc_util/module_locks) which provides an interface to use both the hardware and the software locks (hwlock.h and swlock.h).

Hardware locks should be used sparingly as there are only 4 per xCORE. But for performance-critical functions they are the right choice.