Deleted Added
sdiff udiff text old ( 11626 ) new ( 12819 )
full compact
1/* $Id: sysv_sem.c,v 1.9 1995/09/09 18:10:07 davidg 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, int *retval));
30
31struct sem_undo *semu_alloc __P((struct proc *p));
32int semundo_adjust __P((struct proc *p, struct sem_undo **supptr, int semid, int semnum, int adjval));
33void semundo_clear __P((int semid, int semnum));
34void semexit __P((struct proc *p));
35
36/* XXX casting to (sy_call_t *) is bogus, as usual. */
37sy_call_t *semcalls[] = {
38 (sy_call_t *)semctl, (sy_call_t *)semget,
39 (sy_call_t *)semop, (sy_call_t *)semconfig
40};
41
42int semtot = 0;
43struct semid_ds *sema; /* semaphore id pool */
44struct sem *sem; /* semaphore pool */
45struct map *semmap; /* semaphore allocation map */
46struct sem_undo *semu_list; /* list of active undo structures */
47int *semu; /* undo structure pool */
48
49static struct proc *semlock_holder = NULL;
50
51void
52seminit(dummy)
53 void *dummy;
54{

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

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

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

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

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

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

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

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

--- 96 unchanged lines hidden ---