OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [include/] [linux/] [sem.h] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#ifndef _LINUX_SEM_H
2
#define _LINUX_SEM_H
3
#include <linux/ipc.h>
4
 
5
/* semop flags */
6
#define SEM_UNDO        0x1000  /* undo the operation on exit */
7
 
8
/* semctl Command Definitions. */
9
#define GETPID  11       /* get sempid */
10
#define GETVAL  12       /* get semval */
11
#define GETALL  13       /* get all semval's */
12
#define GETNCNT 14       /* get semncnt */
13
#define GETZCNT 15       /* get semzcnt */
14
#define SETVAL  16       /* set semval */
15
#define SETALL  17       /* set all semval's */
16
 
17
/* One semid data structure for each set of semaphores in the system. */
18
struct semid_ds {
19
  struct ipc_perm sem_perm;            /* permissions .. see ipc.h */
20
  time_t          sem_otime;           /* last semop time */
21
  time_t          sem_ctime;           /* last change time */
22
  struct sem      *sem_base;           /* ptr to first semaphore in array */
23
  struct sem_queue *sem_pending;       /* pending operations to be processed */
24
  struct sem_queue **sem_pending_last; /* last pending operation */
25
  struct sem_undo *undo;               /* undo requests on this array */
26
  ushort          sem_nsems;           /* no. of semaphores in array */
27
};
28
 
29
/* semop system calls takes an array of these. */
30
struct sembuf {
31
  ushort  sem_num;        /* semaphore index in array */
32
  short   sem_op;         /* semaphore operation */
33
  short   sem_flg;        /* operation flags */
34
};
35
 
36
/* arg for semctl system calls. */
37
union semun {
38
  int val;                      /* value for SETVAL */
39
  struct semid_ds *buf;         /* buffer for IPC_STAT & IPC_SET */
40
  ushort *array;                /* array for GETALL & SETALL */
41
  struct seminfo *__buf;        /* buffer for IPC_INFO */
42
  void *__pad;
43
};
44
 
45
struct  seminfo {
46
    int semmap;
47
    int semmni;
48
    int semmns;
49
    int semmnu;
50
    int semmsl;
51
    int semopm;
52
    int semume;
53
    int semusz;
54
    int semvmx;
55
    int semaem;
56
};
57
 
58
#define SEMMNI  128             /* ?  max # of semaphore identifiers */
59
#define SEMMSL  32              /* <= 512 max num of semaphores per id */
60
#define SEMMNS  (SEMMNI*SEMMSL) /* ? max # of semaphores in system */
61
#define SEMOPM  32              /* ~ 100 max num of ops per semop call */
62
#define SEMVMX  32767           /* semaphore maximum value */
63
 
64
/* unused */
65
#define SEMUME  SEMOPM          /* max num of undo entries per process */
66
#define SEMMNU  SEMMNS          /* num of undo structures system wide */
67
#define SEMAEM  (SEMVMX >> 1)   /* adjust on exit max value */
68
#define SEMMAP  SEMMNS          /* # of entries in semaphore map */
69
#define SEMUSZ  20              /* sizeof struct sem_undo */
70
 
71
#ifdef __KERNEL__
72
 
73
/* One semaphore structure for each semaphore in the system. */
74
struct sem {
75
  short   semval;         /* current value */
76
  short   sempid;         /* pid of last operation */
77
};
78
 
79
/* ipcs ctl cmds */
80
#define SEM_STAT 18
81
#define SEM_INFO 19
82
 
83
/* One queue for each semaphore set in the system. */
84
struct sem_queue {
85
    struct sem_queue *  next;    /* next entry in the queue */
86
    struct sem_queue ** prev;    /* previous entry in the queue, *(q->prev) == q */
87
    struct wait_queue * sleeper; /* sleeping process */
88
    struct sem_undo *   undo;    /* undo structure */
89
    int                 pid;     /* process id of requesting process */
90
    int                 status;  /* completion status of operation */
91
    struct semid_ds *   sma;     /* semaphore array for operations */
92
    struct sembuf *     sops;    /* array of pending operations */
93
    int                 nsops;   /* number of operations */
94
};
95
 
96
/* Each task has a list of undo requests. They are executed automatically
97
 * when the process exits.
98
 */
99
struct sem_undo {
100
    struct sem_undo *  proc_next; /* next entry on this process */
101
    struct sem_undo *  id_next;   /* next entry on this semaphore set */
102
    int                semid;     /* semaphore set identifier */
103
    short *            semadj;    /* array of adjustments, one per semaphore */
104
};
105
 
106
asmlinkage int sys_semget (key_t key, int nsems, int semflg);
107
asmlinkage int sys_semop (int semid, struct sembuf *sops, unsigned nsops);
108
asmlinkage int sys_semctl (int semid, int semnum, int cmd, union semun arg);
109
 
110
#endif /* __KERNEL__ */
111
 
112
#endif /* _LINUX_SEM_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.