File: sge_lock_fifo.h

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (105 lines) | stat: -rw-r--r-- 2,048 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef _SGE_LOCK_FIFO_H_
#define _SGE_LOCK_FIFO_H_

#include <pthread.h>

#include "basis_types.h"

#include "uti/sge_lock.h"

typedef struct sge_fifo_elem_t__ {
   /*
    * is the waiting thread a reader or writer
    */
   bool is_reader;

   /*
    * has this thread already been signaled
    */
   bool is_signaled;

   /*
    * condition to wakeup a waiting thread
    */
   pthread_cond_t cond;
} sge_fifo_elem_t;

typedef struct sge_fifo_rw_lock_t__ {
   /* 
    * mutex to guard this structure
    */
   pthread_mutex_t mutex;

   /*
    * condition to wakeup a waiting thread which got not
    * no position in the queue of waiting threads
    */
   pthread_cond_t cond;

   /*
    * fifo array where information about waiting threads is stored.
    */
   sge_fifo_elem_t *array;

   /* 
    * position of the next thread which gets the lock 
    */
   int head;            

   /* 
    * position in the array where the next thread will be placed which has to wait 
    */
   int tail;          

   /* 
    * maximum array size 
    */ 
   int size;            

   /* 
    * number of reader threads currently active 
    */
   int reader_active;   

   /* 
    * number of waiting threads in the queue which try to get a read lock 
    */
   int reader_waiting;  
   
   /*
    * number of writer threads currently active (maximum is 1)
    */
   int writer_active;

   /*
    * number of waiting threads in the queue which try to get the write lock
    */
   int writer_waiting;  

   /*
    * number of threads which do neither get a lock nor get a free position in the array
    */
   int waiting;       

   /*
    * number of waiting threads which have been signaled so that they wake up (maximum is 1)
    */
   int signaled;
} sge_fifo_rw_lock_t;

bool 
sge_fifo_lock_init(sge_fifo_rw_lock_t *lock);

bool 
sge_fifo_lock(sge_fifo_rw_lock_t *lock, bool is_reader);

bool 
sge_fifo_ulock(sge_fifo_rw_lock_t *lock, bool is_reader);

void 
sge_fifo_debug(sge_locktype_t aType);

void 
sge_debug_time(sge_locktype_t aType);

#endif