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

Last change on this file since 748 was 709, checked in by alain, 9 years ago

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

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