semexit: do nothing if the process has not used semaphores.

This commit is contained in:
ad 2008-04-25 11:21:18 +00:00
parent e691c35842
commit 1ae2046c17
2 changed files with 14 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_sem.c,v 1.80 2008/04/22 12:14:12 njoly Exp $ */
/* $NetBSD: sysv_sem.c,v 1.81 2008/04/25 11:21:18 ad Exp $ */
/*-
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.80 2008/04/22 12:14:12 njoly Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.81 2008/04/25 11:21:18 ad Exp $");
#define SYSVSEM
@ -761,6 +761,13 @@ sys_semop(struct lwp *l, const struct sys_semop_args *uap, register_t *retval)
int do_wakeup, do_undos;
SEM_PRINTF(("call to semop(%d, %p, %zd)\n", semid, SCARG(uap,sops), nsops));
if (__predict_false((p->p_flag & PK_SYSVSEM) == 0)) {
mutex_enter(p->p_lock);
p->p_flag |= PK_SYSVSEM;
mutex_exit(p->p_lock);
}
restart:
if (nsops <= SMALL_SOPS) {
sops = small_sops;
@ -1022,6 +1029,9 @@ semexit(struct proc *p, void *v)
struct sem_undo *suptr;
struct sem_undo **supptr;
if ((p->p_flag & PK_SYSVSEM) == 0)
return;
mutex_enter(&semlock);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.273 2008/04/24 18:39:25 ad Exp $ */
/* $NetBSD: proc.h,v 1.274 2008/04/25 11:21:18 ad Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -349,6 +349,7 @@ struct proc {
*/
#define PK_ADVLOCK 0x00000001 /* Process may hold a POSIX advisory lock */
#define PK_SYSTEM 0x00000002 /* System process (kthread) */
#define PK_SYSVSEM 0x00000004 /* Used SysV semaphores */
#define PK_SUGID 0x00000100 /* Had set id privileges since last exec */
#define PK_EXEC 0x00004000 /* Process called exec */
#define PK_NOCLDWAIT 0x00020000 /* No zombies if child dies */