| Line | |
|---|
| 1 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // File : spin_lock.h |
|---|
| 3 | // Date : 01/04/2012 |
|---|
| 4 | // Author : alain greiner |
|---|
| 5 | // Copyright (c) UPMC-LIP6 |
|---|
| 6 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 7 | |
|---|
| 8 | #ifndef _GIET_SPIN_LOCK_H_ |
|---|
| 9 | #define _GIET_SPIN_LOCK_H_ |
|---|
| 10 | |
|---|
| 11 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 12 | // lock structure |
|---|
| 13 | // This is a simple binary lock (without waiting queue). |
|---|
| 14 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 15 | |
|---|
| 16 | typedef struct giet_lock_s { |
|---|
| 17 | char name[32]; // lock name |
|---|
| 18 | unsigned int value; // taken if value != 0 |
|---|
| 19 | } giet_lock_t; |
|---|
| 20 | |
|---|
| 21 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 22 | // access functions |
|---|
| 23 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 24 | |
|---|
| 25 | void lock_acquire( giet_lock_t* lock ); |
|---|
| 26 | |
|---|
| 27 | void lock_release( giet_lock_t* lock ); |
|---|
| 28 | |
|---|
| 29 | // return 0 if success |
|---|
| 30 | int lock_try_acquire( giet_lock_t* lock ); |
|---|
| 31 | |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.