Deleted Added
sdiff udiff text old ( 11626 ) new ( 12819 )
full compact
1/* $Id: sysv_sem.c,v 1.10 1995/10/21 19:49:59 bde Exp $ */
2
3/*
4 * Implementation of SVID semaphores
5 *
6 * Author: Daniel Boulet
7 *
8 * This software is provided ``AS IS'' without any warranties of any kind.
9 */

--- 11 unchanged lines hidden (view full) ---

21
22struct semctl_args;
23static int semctl __P((struct proc *p, struct semctl_args *uap, int *retval));
24struct semget_args;
25static int semget __P((struct proc *p, struct semget_args *uap, int *retval));
26struct semop_args;
27static int semop __P((struct proc *p, struct semop_args *uap, int *retval));
28struct semconfig_args;
29static int semconfig __P((struct proc *p, struct semconfig_args *uap,
30 int *retval));
31
32static struct sem_undo *semu_alloc __P((struct proc *p));
33static int semundo_adjust __P((struct proc *p, struct sem_undo **supptr,
34 int semid, int semnum, int adjval));
35static void semundo_clear __P((int semid, int semnum));
36static void semexit __P((struct proc *p));
37
38/* XXX casting to (sy_call_t *) is bogus, as usual. */
39static sy_call_t *semcalls[] = {
40 (sy_call_t *)semctl, (sy_call_t *)semget,
41 (sy_call_t *)semop, (sy_call_t *)semconfig
42};
43
44static int semtot = 0;
45struct semid_ds *sema; /* semaphore id pool */
46struct sem *sem; /* semaphore pool */
47static struct map *semmap; /* semaphore allocation map */
48static struct sem_undo *semu_list; /* list of active undo structures */
49int *semu; /* undo structure pool */
50
51static struct proc *semlock_holder = NULL;
52
53void
54seminit(dummy)
55 void *dummy;
56{

--- 88 unchanged lines hidden (view full) ---

145 return(eval);
146}
147
148/*
149 * Allocate a new sem_undo structure for a process
150 * (returns ptr to structure or NULL if no more room)
151 */
152
153static struct sem_undo *
154semu_alloc(p)
155 struct proc *p;
156{
157 register int i;
158 register struct sem_undo *suptr;
159 register struct sem_undo **supptr;
160 int attempt;
161

--- 53 unchanged lines hidden (view full) ---

215 }
216 return (NULL);
217}
218
219/*
220 * Adjust a particular entry for a particular proc
221 */
222
223static int
224semundo_adjust(p, supptr, semid, semnum, adjval)
225 register struct proc *p;
226 struct sem_undo **supptr;
227 int semid, semnum;
228 int adjval;
229{
230 register struct sem_undo *suptr;
231 register struct undo *sunptr;

--- 50 unchanged lines hidden (view full) ---

282 suptr->un_cnt++;
283 sunptr->un_adjval = adjval;
284 sunptr->un_id = semid; sunptr->un_num = semnum;
285 } else
286 return(EINVAL);
287 return(0);
288}
289
290static void
291semundo_clear(semid, semnum)
292 int semid, semnum;
293{
294 register struct sem_undo *suptr;
295
296 for (suptr = semu_list; suptr != NULL; suptr = suptr->un_next) {
297 register struct undo *sunptr = &suptr->un_ent[0];
298 register int i = 0;

--- 561 unchanged lines hidden (view full) ---

860 *retval = 0;
861 return(0);
862}
863
864/*
865 * Go through the undo structures for this process and apply the adjustments to
866 * semaphores.
867 */
868static void
869semexit(p)
870 struct proc *p;
871{
872 register struct sem_undo *suptr;
873 register struct sem_undo **supptr;
874 int did_something;
875
876 /*

--- 96 unchanged lines hidden ---