From owner-freebsd-realtime@FreeBSD.ORG Fri Feb 13 07:48:20 2004 Return-Path: Delivered-To: freebsd-realtime@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DEFA216A4CE for ; Fri, 13 Feb 2004 07:48:20 -0800 (PST) Received: from bornova.ege.edu.tr (bornova.ege.edu.tr [155.223.64.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 93A4A43D1F for ; Fri, 13 Feb 2004 07:48:18 -0800 (PST) (envelope-from kantarci@bornova.ege.edu.tr) Received: from kantarci (bilmuh24106.bilgmuh.ege.edu.tr [155.223.24.106]) by bornova.ege.edu.tr (8.11.3/8.11.3) with ESMTP id i1DFk4f24295 for ; Fri, 13 Feb 2004 17:46:04 +0200 (EET) From: "Aylin Kantarci" To: Date: Fri, 13 Feb 2004 17:59:56 +0200 Message-ID: <001101c3f24a$6e4a4a50$6a18df9b@compeng.ege.edu.tr> MIME-Version: 1.0 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: A question on pthreads X-BeenThere: freebsd-realtime@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Realtime extensions per POSIX 1003.4 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2004 15:48:21 -0000 Now I have a question about my multithreaded application. I will be very glad if you could be helpful. I am developing the software on Solaris 9 platform and using pthread and posix4 libraries. There are 3 threads in the application and a periodic realtime thread. The 1st thread receives packets from the network at small intervals. The second thread catches signals from the periodic timer. the 3rd thread consumes a group of packets at each clock tick. The second and the third thread synchronizes with a mutex. 2nd thread unlocks the mutex when the clock ticks. the third thread tries to lock the mutex and consumes the packets in a loop All threads arse defined with the scope SYSTEM_SCOPE. I am setting the thread concurrency to 5. I think I am using bounded threads. I observed that when the 2nd thread tries to lock the mutex, the 1st thread also blocks and stops receiving packets from the network. The 1st thread uses an implementation of RTP library which is not thread safe. I want the first thread to continue to receive packets from the network when the second thread blocks on the semaphore. Algorthm for the first thread while (1) { receive a packet from the network . . . _} Algorithm for the 2nd one . . .{ while (1) { . . pthread mutex lock(cont) consume packets . . } Algorithm for the 3rd one { while (1) { wait for a signal to arrive when the periodic timer ticks. pthread mutex unlock( cont) } Thanks in advance Dr. Aylin Kantarci