From owner-freebsd-threads@FreeBSD.ORG Wed Feb 10 14:09:02 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1AAD8106568B for ; Wed, 10 Feb 2010 14:09:02 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:213:d4ff:fef3:2d8d]) by mx1.freebsd.org (Postfix) with ESMTP id C420D8FC16 for ; Wed, 10 Feb 2010 14:09:01 +0000 (UTC) Received: from [192.168.2.224] (pool-96-249-204-75.snfcca.dsl-w.verizon.net [96.249.204.75]) (authenticated bits=0) by lakerest.net (8.14.3/8.14.3) with ESMTP id o1AE8ws0001121 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 10 Feb 2010 09:09:00 -0500 (EST) (envelope-from rrs@lakerest.net) Message-Id: <3581A86D-9C9C-4E08-9AD3-CD550B180CED@lakerest.net> From: Randall Stewart To: threads@freebsd.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Date: Wed, 10 Feb 2010 06:08:53 -0800 X-Mailer: Apple Mail (2.936) Cc: Subject: Thinking about kqueue's and pthread_cond_wait X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2010 14:09:02 -0000 All: I have once again come around to thinking about joining pthread cond waits and kqueue's. After thinking about it, I think its doable.. with something like a: pthread_cond_wait_kqueue_np(kev, cond, mtx, ucontext) Then you can use kev inside a kqueue i.e. ret = kevent(kq, kev, 1, outkev, 1, NULL); Now when you saw the event: if (kev.filter == EVFILT_UMTX){ /* not sure about the name here */ pthread_kqueue_cond_wait_ret_np(kev, cond, mtx, ucontext) do_user_action(cond,mtx, ucontext); } Which would fill in the cond/mtx and ucontext for the user. Now does this sound useful to anyone.. i.e. should I spend the time making it work? The only down side to this is that it would have to allocate memory so one would need to do a: pthread_kqueue_cond_wait_free_np(kev) After you were done.. and I think it would be best for this to be a ONE_SHOT.. i.e. you have to re-arm it if the event happens... Of course until you free it that can be as simple as passing the kev back down again (i.e. no pthread_cond_wait_kqueue_np() needed). Comments? Thoughts? i.e. especially is it worthwhile doing? Thanks R ------------------------------ Randall Stewart 803-317-4952 (cell)