From owner-freebsd-current Thu May 31 0:31:28 2001 Delivered-To: freebsd-current@freebsd.org Received: from rina.r.dl.itc.u-tokyo.ac.jp (rina.r.dl.itc.u-tokyo.ac.jp [133.11.199.247]) by hub.freebsd.org (Postfix) with ESMTP id 4EDD637B422 for ; Thu, 31 May 2001 00:31:24 -0700 (PDT) (envelope-from tanimura@r.dl.itc.u-tokyo.ac.jp) Received: from rina.r.dl.itc.u-tokyo.ac.jp (localhost [127.0.0.1]) by rina.r.dl.itc.u-tokyo.ac.jp (8.11.3+3.4W/3.7W-rina.r-20010412) with ESMTP id f4V7VLD29187 ; Thu, 31 May 2001 16:31:22 +0900 (JST) Message-Id: <200105310731.f4V7VLD29187@rina.r.dl.itc.u-tokyo.ac.jp> Date: Thu, 31 May 2001 16:31:21 +0900 From: Seigo Tanimura To: current@FreeBSD.org Subject: Lock of struct filedesc, file, pgrp, session and sigio Cc: Seigo Tanimura User-Agent: Wanderlust/1.1.1 (Purple Rain) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Digital Library Research Division, Information Techinology Centre, The University of Tokyo MIME-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Lock of struct filedesc, file, pgrp, session and sigio is now ready for testing. The patch is at http://people.FreeBSD.org/~tanimura/patches/fd_pgrp.diff.gz Below is the brief description of locking. 1. struct filedesc and struct file - fd_mtx protects struct filedesc. - f_mtx protects struct file. Refer to sys/file.h for detail. - Do not look up a file descriptor table directly but use FFIND* macros defined in sys/filedesc.h. They handle locking a file descriptor table and a file descriptor. - getvnode() locks a file descriptor. - p_fd may change during the life of a process if it is sharing its file descriptor table when the process calls execve(2). As nobody except curproc and the parent process in fork1() touches the file descriptor table of a process, the lock type of p_fd should be "(a) only touched by curproc or parent during fork/wait." 2. struct proc, struct pgrp and struct session - pgrphash_lock and pg_mtx protects struct pgrp. Refer to sys/proc.h for detail. - s_mtx protects struct session. Refer to sys/proc.h for detail. - Introduce p_pgrpmtx to protect p_pgrp of struct proc in cooperation with p_mtx. This allows locking of a process in a process group without lock order reversal. The lock order of them is shown below. 1st: p_pgrpmtx 2st: pg_mtx 3rd: p_mtx - You may lock more than one process groups provided that they belong to an identical session and you lock the session in advance. - psignal() requires the lock of the process group to which a destination process belongs if the property of a signal includes SA_STOP. PROC_LOCK_PSIGNAL() and PROC_UNLOCK_PSIGNAL() handle those lock and unlock. TODO: Pass a signal to PROC_(UN)LOCK_PSIGNAL() to avoid unnecessary lock. - pgsignal() requires the lock of a destination process group. 3. struct sigio - struct sigio forms a list(struct sigiolst), residing in a process or a process group. p_mtx of a process or pg_mtx of a process group is responsible to lock struct sigiolst. The members of struct sigio other than sio_pgsigio never change. - A macro FUNSETOWN locks the list of struct sigio, calls funsetown() and unlocks the list. -- Seigo Tanimura To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message