wangzhengquan
2021-01-21 4fd62552d8277f3d0ed20e66663cd219c36796df
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
#ifndef _SVSEM_UTIL_H
#define _SVSEM_UTIL_H  
 
#include "usg_common.h"
 
class SvsemUtil {
public:
  static int get(key_t key, int nsems, unsigned short * arr_val) ;
  /* Reserve semaphore (blocking), return 0 on success, or -1 with 'errno'
     set to EINTR if operation was interrupted by a signal handler */
 
  /* Reserve semaphore - decrement it by 1 */
  static int dec(int semId)  ;
 
  static int dec_nowait(int semId)  ;
 
  static int dec_timeout(const int semId, const struct timespec *timeout) ;
 
 
  /**
   * If sem_op equals 0, the value of the semaphore is checked to see whether it
   * currently equals 0. If it does, the operation completes immediately; otherwise,
   * semop() blocks until the semaphore value becomes 0.
   */
  static int zero(int semId) ; 
 
 
  static int zero_nowait(int semId) ;
 
  static int zero_timeout(const int semId, const struct timespec *timeout)  ;
 
 
  /* Release semaphore - increment it by 1 */
  static int inc(int semId) ;
 
 
  static int set(int semId, int val) ;
 
 
 
 
  static int cond_wait(int semid ) ;
  static int cond_signal(int semid ) ;
  static void remove(int semid) ;
};
 
#endif