| [258] | 1 | ////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 2 | // File     : spin_lock.h | 
|---|
|  | 3 | // Date     : 01/04/2012 | 
|---|
|  | 4 | // Author   : alain greiner | 
|---|
|  | 5 | // Copyright (c) UPMC-LIP6 | 
|---|
|  | 6 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| [368] | 7 | // The spin_lock.c and spin_lock.h files are part of the GIET-VM nano-kernel. | 
|---|
|  | 8 | // This  library implements a user-level lock. | 
|---|
|  | 9 | // It is a simple binary lock, without waiting queue. | 
|---|
|  | 10 | // The lock_acquire() and lock_release() functions do not require a system call. | 
|---|
|  | 11 | // If the platform does not provide hardware cache coherence, the lock must be | 
|---|
|  | 12 | // declared in a non cacheable segment, | 
|---|
|  | 13 | // | 
|---|
|  | 14 | // When a lock is defined in the mapping, it has not to be declared in the | 
|---|
|  | 15 | // application code: it will be initialised in the boot phase, | 
|---|
|  | 16 | // and the vobj_get_vbase() system call (defined in stdio.c and stdio.h files) | 
|---|
|  | 17 | // can be used to get the virtual base address of the lock from it's name. | 
|---|
|  | 18 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
| [258] | 19 |  | 
|---|
|  | 20 | #ifndef _GIET_SPIN_LOCK_H_ | 
|---|
|  | 21 | #define _GIET_SPIN_LOCK_H_ | 
|---|
|  | 22 |  | 
|---|
|  | 23 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 24 | //  lock structure | 
|---|
|  | 25 | /////////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 26 |  | 
|---|
| [368] | 27 | typedef struct giet_lock_s | 
|---|
|  | 28 | { | 
|---|
|  | 29 | char name[60];      // lock name | 
|---|
| [258] | 30 | unsigned int value; // taken if value != 0 | 
|---|
|  | 31 | } giet_lock_t; | 
|---|
|  | 32 |  | 
|---|
|  | 33 | ////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 34 | //  access functions | 
|---|
|  | 35 | ////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 36 |  | 
|---|
| [368] | 37 | extern void lock_acquire(giet_lock_t * lock); | 
|---|
|  | 38 | extern void lock_release(giet_lock_t * lock); | 
|---|
| [258] | 39 |  | 
|---|
|  | 40 | #endif | 
|---|
|  | 41 |  | 
|---|
|  | 42 | // Local Variables: | 
|---|
|  | 43 | // tab-width: 4 | 
|---|
|  | 44 | // c-basic-offset: 4 | 
|---|
|  | 45 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) | 
|---|
|  | 46 | // indent-tabs-mode: nil | 
|---|
|  | 47 | // End: | 
|---|
|  | 48 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 | 
|---|
|  | 49 |  | 
|---|