From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56730 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PtiJB-0006az-3u for qemu-devel@nongnu.org; Sun, 27 Feb 2011 10:13:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PtiJ9-00030g-Vt for qemu-devel@nongnu.org; Sun, 27 Feb 2011 10:13:17 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:63352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PtiJ9-00030Z-Kh for qemu-devel@nongnu.org; Sun, 27 Feb 2011 10:13:15 -0500 Received: by wyb29 with SMTP id 29so3143638wyb.4 for ; Sun, 27 Feb 2011 07:13:14 -0800 (PST) Sender: Paolo Bonzini Message-ID: <4D6A6A08.8000300@redhat.com> Date: Sun, 27 Feb 2011 16:13:12 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1298818682-5404-1-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1298818682-5404-1-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] simpletrace: Thread-safe tracing List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , qemu-devel@nongnu.org, Prerna Saxena On 02/27/2011 03:58 PM, Stefan Hajnoczi wrote: > + * Trace records are written out by a dedicated thread. The thread waits for > + * records to become available, writes them out, and then waits again. > + */ > +static pthread_mutex_t trace_lock = PTHREAD_MUTEX_INITIALIZER; > +static pthread_cond_t trace_available_cond = PTHREAD_COND_INITIALIZER; > +static pthread_cond_t trace_empty_cond = PTHREAD_COND_INITIALIZER; > +static bool trace_available; > +static bool trace_writeout_enabled; Please use QemuThread. > + > + pthread_attr_init(&attr); > + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); > > - tp = find_trace_event_by_name(tname); > - if (tp) { > - tp->state = tstate; > - return true; > + sigfillset(&set); > + pthread_sigmask(SIG_SETMASK, &set, &oldset); > + ret = pthread_create(&thread, &attr, writeout_thread, NULL); > + pthread_sigmask(SIG_SETMASK, &oldset, NULL); This is also taken care of by QemuThread. Paolo