source: soft/giet_vm/giet_libs/user_lock.h @ 795

Last change on this file since 795 was 795, checked in by alain, 8 years ago

Remove dependencies on the hard_config.h file.

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : user_lock.h         
3// Date     : 01/12/2014
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The file_lock.c and file_lock.h files are part of the GIET-VM nano-kernel.
8///////////////////////////////////////////////////////////////////////////////////
9
10#ifndef _USER_LOCK_H_
11#define _USER_LOCK_H_
12
13///////////////////////////////////////////////////////////////////////////////////
14//  simple lock structure
15///////////////////////////////////////////////////////////////////////////////////
16
17typedef struct user_lock_s
18{
19    unsigned int current;        // current slot index
20    unsigned int free;           // next free slot index
21    unsigned int padding[14];    // for 64 bytes alignment
22} user_lock_t;
23
24///////////////////////////////////////////////////////////////////////////////////
25//  simple lock access functions
26///////////////////////////////////////////////////////////////////////////////////
27
28extern unsigned int atomic_increment( unsigned int* ptr,
29                                      unsigned int  increment );
30
31extern void lock_acquire( user_lock_t * lock );
32
33extern void lock_release( user_lock_t * lock );
34
35extern void lock_init( user_lock_t * lock );
36
37///////////////////////////////////////////////////////////////////////////////////
38//      SQT lock structures
39///////////////////////////////////////////////////////////////////////////////////
40
41typedef struct sqt_lock_node_s
42{
43    unsigned int            current;         // current ticket index
44    unsigned int            free;            // next free ticket index
45    unsigned int            level;           // hierarchical level (0 is bottom)
46    struct sqt_lock_node_s* parent;          // parent node (NULL for root)
47    struct sqt_lock_node_s* child[4];        // children node
48    unsigned int            padding[8];      // for 64 bytes alignment         
49} sqt_lock_node_t;
50
51typedef struct sqt_lock_s
52{
53    sqt_lock_node_t* node[16][16][5];        // array of pointers on SBT nodes (max size)
54} sqt_lock_t;
55
56//////////////////////////////////////////////////////////////////////////////////
57//      SQT lock access functions
58//////////////////////////////////////////////////////////////////////////////////
59
60
61extern void sqt_lock_init( sqt_lock_t*  lock,
62                       unsigned int         x_size,
63                       unsigned int         y_size,
64                       unsigned int         ntasks );
65
66extern void sqt_lock_acquire( sqt_lock_t*  lock );
67
68extern void sqt_lock_release( sqt_lock_t*  lock );
69
70#endif
71
72// Local Variables:
73// tab-width: 4
74// c-basic-offset: 4
75// c-file-offsets:((innamespace . 0)(inline-open . 0))
76// indent-tabs-mode: nil
77// End:
78// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
79
Note: See TracBrowser for help on using the repository browser.