Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!apple!agate!darkstar!rex.cs.tulane.edu From: bdf@rex.cs.tulane.edu (Brett Fleisch) Newsgroups: comp.os.research Subject: Re: Toy Experiment with Shared Memory Programming Message-ID: <8916@darkstar.ucsc.edu> Date: 13 Nov 90 16:17:51 GMT Sender: usenet@darkstar.ucsc.edu Organization: Computer Science Dept., Tulane Univ., New Orleans, LA Lines: 41 Approved: comp-os-research@jupiter.ucsc.edu In article <8754@darkstar.ucsc.edu> jms@central.cis.upenn.edu (Jonathan M. Smith) writes: >Some Notes on Experiences programming shared memory > >In some initial trials, I found that the shared memory program ("mem") >performed far worse than "piper". This surprised me, so I profiled the code >to find out where the time was going, and it was being eaten up by the >calls to "semop()", which are used to implement P() and V(). But the cost >of the calls was not the problem; it was the *number* of calls! For a file >(my "mbox") with 184 8192-byte blocks, about 30-40 K calls to semop were >made! This didn't sem possible from examining the code; and I must admit to >a lot of hacking trying to "fix" the problem, which I was sure was a BUG. > >The problem was that pipes are well-integrated with process synchronization >and scheduling. While executing a "V()" operation freed the semaphore, it >did not give up the processor, so that the process which had just executed >the "V" could now execute a "P" again immediately. After I saw this, I quickly >rewrote the program with two semaphores so that better control over process >control (such as in "sleep" and "wakeup") and response to events could be >achieved. > I observed a similar problem in Mirage. Why not read over the article "Mirage: A Coherent Distributed Shared Memory Design" in SOSP12 noting the yield() instruction which was added to better control UNIX synchronization and scheduling interactions. If you have questions contact me: Brett D. Fleisch Assistant Professor Computer Science Department Tulane University 301 Stanley Thomas Hall New Orleans, LA 70118-5698 (504)865-5840 bdf@cs.tulane.edu -- brett@cs.tulane.edu