From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 3 13:27:18 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 50B7616A41C for ; Fri, 3 Jun 2005 13:27:18 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id E431543D49 for ; Fri, 3 Jun 2005 13:27:17 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id 642C97F30D for ; Fri, 3 Jun 2005 15:27:15 +0200 (CEST) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23756-10 for ; Fri, 3 Jun 2005 15:27:10 +0200 (CEST) Received: from firewall.demig (p50838965.dip0.t-ipconnect.de [80.131.137.101]) by server.absolute-media.de (Postfix) with ESMTP id 97FB57982E for ; Fri, 3 Jun 2005 15:27:10 +0200 (CEST) Received: from ws-ew-3 (ws-ew-3.w2kdemig [192.168.1.72]) by firewall.demig (8.13.4/8.13.1) with SMTP id j53DOKjg047520 for ; Fri, 3 Jun 2005 15:24:20 +0200 (CEST) (envelope-from NKoch@demig.de) From: "Norbert Koch" To: "Freebsd-Hackers@Freebsd. Org" Date: Fri, 3 Jun 2005 15:24:19 +0200 Message-ID: <000001c5683f$8c7c1e60$4801a8c0@ws-ew-3.W2KDEMIG> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0 X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Subject: synchronization question about /sys/dev/vkbd/vkbd.c 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: Fri, 03 Jun 2005 13:27:18 -0000 Hello. When looking at /sys/dev/vkbd/vkbd.c I found one thing, that I do not understand. There are three places, where a flag TASK is used: 1. in vkbd_dev_close(): while(state->ks_flag & TASK) VKBD_SLEEP (...); 2. in vkbd_dev_write() VKBD_LOCK (); ... if (!(state->ks_flags & TASK) && task_enqueue(...)) state->ks_flags |= TASK; ... VKBD_UNLOCK (); 3. in vkbd_dev_intr() ... /* call intr */ ... VKBD_LOCK(); state->ks_flags &= ~TASK; wakeup(...); VKBD_UNLOCK(); As I understand: vkbd_dev_write() writes data into its queue and wants vkbd_dev_intr() to process the queue. My question is: Is it not possible, that vkbd_dev_intr() could be interrupted at any position before the VKBD_LOCK() and then vkbd_dev_write() called? If yes, how should vkbd_dev_write() know, that it should call task_enqueue(), as TASK is still set? Why not always call task_enqueue() unconditionally here and leave TASK only to synchronize the close call? Thank you for any help, Norbert Koch