source: soft/giet_vm/giet_common/locks.h @ 456

Last change on this file since 456 was 455, checked in by alain, 10 years ago

Introducing the tty0.c/tty0.h files defining access function to TTY0 (including the _printf().
Introducing the locks.c/locks.h files defining two types of spin-lock (with and without a waiting queue).

  • Property svn:executable set to *
File size: 1.9 KB
RevLine 
[455]1///////////////////////////////////////////////////////////////////////////////////
2// File     : locks.h
3// Date     : 01/12/2014
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The locks.c and locks.h files are part of the GIET-VM nano-kernel.
8// They define both atomic increment operations and locks.
9// The locks used gy the GIET_VM are spin-locks with a waiting queue.
10///////////////////////////////////////////////////////////////////////////////////
11
12#ifndef GIET_LOCKS_H
13#define GIET_LOCKS_H
14
15///////////////////////////////////////////////////////////////////////////////////
16// This structure implements a spin-lock with waiting file.
17// There is at most one lock per cache line.
18///////////////////////////////////////////////////////////////////////////////////
19
20typedef struct spin_lock_s
21{
22    unsigned int current;        // current slot index
23    unsigned int free;           // next free slot index
24    unsigned int padding[14];    // for 64 bytes alignment
25} spin_lock_t;
26
27typedef struct simple_lock_s
28{
29    unsigned int value;
30    unsigned int padding[15];
31} simple_lock_t;
32
33///////////////////////////////////////////////////////////////////////////////////
34//      Locks access functions
35///////////////////////////////////////////////////////////////////////////////////
36
37extern unsigned int _atomic_increment( unsigned int* ptr,
38                                       unsigned int  increment );
39
40extern void _lock_init( spin_lock_t* lock );
41
42extern void _lock_acquire( spin_lock_t* lock );
43
44extern void _lock_release( spin_lock_t* lock );
45
46extern void _simple_lock_acquire( simple_lock_t* lock );
47
48extern void _simple_lock_release( simple_lock_t* lock );
49
50#endif
51
52// Local Variables:
53// tab-width: 4
54// c-basic-offset: 4
55// c-file-offsets:((innamespace . 0)(inline-open . 0))
56// indent-tabs-mode: nil
57// End:
58// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
59
Note: See TracBrowser for help on using the repository browser.