Lock of struct filedesc, file, pgrp, session and sigio is now ready
for testing.

The patch is at


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
  those lock and unlock.

  TODO: Pass a signal to PROC_(UN)LOCK_PSIGNAL() to avoid unnecessary

- 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.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to