From owner-freebsd-hackers Tue Jan 7 16:16:58 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id QAA27321 for hackers-outgoing; Tue, 7 Jan 1997 16:16:58 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id QAA27315 for ; Tue, 7 Jan 1997 16:16:55 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id RAA15234; Tue, 7 Jan 1997 17:06:47 -0700 From: Terry Lambert Message-Id: <199701080006.RAA15234@phaeton.artisoft.com> Subject: Re: mmap() updates...how often? To: scrappy@hub.org (The Hermit Hacker) Date: Tue, 7 Jan 1997 17:06:47 -0700 (MST) Cc: hackers@FreeBSD.ORG In-Reply-To: from "The Hermit Hacker" at Jan 7, 97 06:18:20 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Not quite sure how to word this one, but how often does > an mmap() region get updated, in so far as client processes seeing > the data that the server process writes to it? If it's MAP_SHARED, then it is updated instantaneously... that is, it's the same physical memory mapped into both processes. > The reason I'm asking is that I have a program that is using > mmap() to pass frames from a central server to client processes. The > central server is writing, on average, 20frames/sec to the mmap()'d > region, and after each write, it sets a counter, also mmap()'d, that > the client uses as, more or less, a position indicator. > > The problem is that the client seems only to see every 20th > frame, as far as the indicator is concerned. I would expect some > "skippage" between client reads (ie. server wrote 2 frames before > the client got a chance to check the indicator again), but it seems > to be *very* consistent at 20... You need to notify the client when the data is available, and not reuse the region until the client has used it. The context switch rate for a compute intensive task is 100HZ or once every 10ms. Most likely, the client isn't getting a chance to run, and the server is monopolizing the CPU. > Not being quite sure of what other data I can provide, does > anyone have any suggestions on what I'm seeing? Since its memory > mapped, I would have made the assumption that changes to the data > would be seen instantaneously by the client, but either I'm missing > something in my code (staring at it too long does that) or I'm once > more missing something with mmap() How are you making sure that the server does not reuse the memory region before the client displays it? If the client is an X client, are you using "XSync( Xdisplay);" to make sure the X servr is not "optimizing" away your screen updates? Other than those, no guesses... Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.