From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 11 19:57:46 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5D7D106566C for ; Mon, 11 Jan 2010 19:57:46 +0000 (UTC) (envelope-from fazaeli@sepehrs.com) Received: from sepehrs.com (sepehrs.com [213.217.59.98]) by mx1.freebsd.org (Postfix) with ESMTP id 454A98FC0A for ; Mon, 11 Jan 2010 19:57:43 +0000 (UTC) Received: from [192.168.1.180] ([192.168.3.1]) by sepehrs.com (8.14.3/8.14.3) with ESMTP id o0BJIGcK039719 for ; Mon, 11 Jan 2010 22:48:16 +0330 (IRST) Message-ID: <4B4B7A7F.2090808@sepehrs.com> Date: Mon, 11 Jan 2010 22:52:39 +0330 From: "H.Fazaeli" User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: uiomove and mutex X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jan 2010 19:57:46 -0000 dear gurus man mutex(9) states that: "No mutexes should be held (except for Giant) across functions which access memory in userspace, such as copyin(9), copyout(9), uiomove(9), fuword(9), etc. No locks are needed when calling these functions." can someone pls. explain why it is so? Suppose I have a kernel buffer to which kernel writes and userland processes read via a character device. In the device read method, If we unlock the mutex just before uiomove, is it guaranteed that kernel does not write to the buffer in the middle of uiomove? If yes, how? What is the solution in such a situation? rwlocks? an intermediate buffer? -- Best regards. Hooman Fazaeli