From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,1d3cf4b7ba25931,start X-Google-Attributes: gidfee84,public From: slale@ge-harris.com (Shripad Lale) Subject: Semaphores and Signals Clash? Date: 1997/04/15 Message-ID: <5j00um$28n$1@Commuter.ge-harris.com>#1/1 X-Deja-AN: 235024152 Organization: GE-Harris Railway Electronics Reply-To: slale@ge-harris.com Newsgroups: comp.unix.osf.osf1 Hi! I am facing a strange problem with Digital Unix (OSF/1) semaphores and signals and wonder if any one of you have encountered something similar. I have two processes called Scheduler and Task. The Scheduler schedules Task in a deterministic manner. It releases the semaphore when it wants to allow the Task to run and sends it a signal when it wants to stop it. The Task releases the semaphore in it's signal handler, so that the semaphore comes back to the Scheduler. In order to time the execution, I give the semaphore to the Task, set the alarm for the required duration and then go into a blocking wait for the semaphore. If the semaphore is released earlier, the wait unblocks and I reset the alarm and proceed. If the semaphore is not released (the Task does not finish its job, I get the sigAlarm signal after the timer expires and I send the SigUsr1 signal to the task. Now, for the problem. If the Task finishes it's processing AND within a very short time (like 10ms) the timer expires THEN the sem_take function, which should unblock (since cronologically the semaphore was given first and the timer expired later), actually 'breaks' indicating that the sem_take was interrupted by a signal. This leads me to believe that the Task has not finished it's job and thus not released the semaphore. So, I send it a signal and expect the semaphore back from it (in it's signal hander). But this is a dead lock situation. The Task does not have a semphore to give, while I keep waiting for one. The question here is, are there any latency issues involved while using semphores and signals? If a semaphore is being transfered from one process to another AND a signal arrives at this time, can the semaphore operation get lost? (This is what seems to happen in my case). Would appreciate some help from someone out there. You may either post your replys to this newsgroup or mail them to me. Thanks in advance for any help, or even for any thought given to this problem! Shripad ------- -- +--------------------------------+------------------------------+ | Shripad Lale | | | Tata Consultancy Services,Pune | Tel(O) : (407)-242-4204 | | c/o General Electric-Harris | Tel(R) : (407)-956-2547 | | 407, John Rodes Blvd, | email : slale@ge-harris.com | | Melbourne, FL 32901, USA | | +--------------------------------+------------------------------+