Received: from dns.whnet.edu.cn (dns.whnet.edu.cn [202.112.20.131]) by hub.org (8.9.1/8.9.1) with SMTP id VAA27859 for ; Thu, 26 Nov 1998 21:40:52 -0500 (EST) (envelope-from sqyang@nudt.edu.cn) Received: from ns (ns.csit.edu.cn) by dns.whnet.edu.cn (5.x/SMI-SVR4) id AA14013; Fri, 27 Nov 1998 09:39:08 +0800 Received: from ysq ([202.197.11.54]) by ns (4.1/SMI-4.1) id AA16300; Fri, 27 Nov 98 10:39:06 CST Sender: post64@nudt.edu.cn Message-Id: <36620643.1FE37641@nudt.edu.cn> Date: Mon, 30 Nov 1998 10:43:15 +0800 From: sqyang Organization: GalaxyDB Cor. X-Mailer: Mozilla 3.01Gold (X11; I; Linux 2.0.30 i686) Mime-Version: 1.0 To: pgsql-sql@postgreSQL.org Subject: the differences between semaphores and spinlocks Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi: I want to do somework on postgresql's parallelization. I found that postgresql uses two kinds of locks: semaphores and spinlocks. The platform I used now is linux-elf's. In such platform, the default options is spinlocks. The question is: if two processes(p1 and p2) use spinlocks for mutex using of resource, and p1 acquires the lock and p2 has to wait for the lock and enter suspended state. When p1 release the lock, is p2 be activated by os? The real situation is: I want to implement a parallel backend through multi engines and multi I/O processes in multi PCs. Each PC contains an engine and an I/O process. The engine and I/O process share the same buffer pool and through spinlock to mutex-use the buffer pool. They use spinAcquire and SpinRelease to acquire and release the lock. After the engine acquires the lock, if the I/O process needs the lock,it has to wait and enter suspended state. When the engine releases the lock, the I/O process seems to remain suspended. Do semaphores and spinlock have the functions. If one process is blocked by the lock or semaphore, when the lock is released, is the process be activated automatically by os? Thanks in advances! SQYang