From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 16 15:51:15 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 828B9106566C for ; Tue, 16 Nov 2010 15:51:15 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id 37DE88FC13 for ; Tue, 16 Nov 2010 15:51:14 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PINoO-0000uv-RC for freebsd-hackers@freebsd.org; Tue, 16 Nov 2010 16:51:12 +0100 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 16 Nov 2010 16:51:12 +0100 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 16 Nov 2010 16:51:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-hackers@freebsd.org From: Ivan Voras Date: Tue, 16 Nov 2010 16:51:04 +0100 Lines: 24 Message-ID: References: <20101116151903.GA2361@britannica.bec.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.12) Gecko/20101102 Thunderbird/3.1.6 In-Reply-To: <20101116151903.GA2361@britannica.bec.de> X-Enigmail-Version: 1.1.2 Subject: Re: Network socket concurrency (userland) 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: Tue, 16 Nov 2010 15:51:15 -0000 On 11/16/10 16:19, Joerg Sonnenberger wrote: > On Tue, Nov 16, 2010 at 03:37:59PM +0100, Ivan Voras wrote: >> Are there any standard-defined guarantees for TCP network sockets >> used by multiple threads to do IO on them? > > System calls are atomic relative to each other. They may be partially > executed from the perspective of a remote system, e.g. due to > segmentation, but one system call will finish before the next call of > the same category is started. It seems to me that with a multithreaded kernel and multithreaded userland that cannot really be guaranteed in general (and really should not be guaranteed for performance reasons), but maybe it's true for e.g. sockets if they are protected by a mutex or two within the kernel? >> Specifically, will multiple write() or send() calls on the same >> socket execute serially (i.e. not interfere with each other) and >> blocking (until completion) even for large buffer sizes? What about >> read() / recv()? > > All write operations are serialised against each other, just like all > read operations are serialised against. To what degree is such serialization standardized (by POSIX?)?