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?
What are hardware and software locks? Topic is solved
-
- Member
- Posts: 14
- Joined: Thu Oct 17, 2013 12:19 pm
-
- XCore Addict
- Posts: 230
- Joined: Wed Mar 10, 2010 12:46 pm
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.
Hardware locks should be used sparingly as there are only 4 per xCORE. But for performance-critical functions they are the right choice.