From owner-freebsd-hackers Thu May 11 19:46:54 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from bluerose.windmoon.nu (c255152-a.plstn1.sfba.home.com [24.15.210.246]) by hub.freebsd.org (Postfix) with ESMTP id 5071D37BC8A for ; Thu, 11 May 2000 19:46:49 -0700 (PDT) (envelope-from fengyue@bluerose.windmoon.nu) Received: from localhost (fengyue@localhost) by bluerose.windmoon.nu (Windmoon-Patched/8.9.3/8.9.3) with ESMTP id UAA29109 for ; Thu, 11 May 2000 20:10:54 -0700 (PDT) Date: Thu, 11 May 2000 20:10:54 -0700 (PDT) From: FengYue To: hackers@FreeBSD.ORG Subject: Why this works? In-Reply-To: <20000511210915.A38341@Hamilton-ppp44812.sympatico.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, I've 3 small programs. First one writes 4K of data contains 'A's into a file /tmp/pagetest and then lseek() to the begin of the file. Second one writes 4K of 'Z' into the same file /tmp/pagetest and then lseek() to the begin of the file. They both do that in a tight loop. Now, the third program reads 4K of data from /tmp/pagetest and exit if the 4K data does not contain all 'A's nor 'Z's. 3 programs run concurrently on the same machine (3.4). No lock in the code whatsoever, and all 3 programs use pure write() and read(). I thought the third program would exit pretty quickly since the data in the file may contain mixed of 'A's and 'Z's, but it has been running for hours and nothing happened. Could someone kindly explain this? I was told that this is because the pagesize is 4096 in the kernel, so that read()/write() 4K of data will not get context switched until the call is compeleted. Is that right? I can attach the code if it's necessary. Thanks FengYue To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message