Return-Path: william@bourbon.usc.edu Delivery-Date: Fri Sep 26 08:05:08 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m8QF58in028856 for ; Fri, 26 Sep 2008 08:05:08 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m8QF8TRS009359 for ; Fri, 26 Sep 2008 08:08:29 -0700 Message-Id: <200809261508.m8QF8TRS009359@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Regarding ctrl+C Date: Fri, 26 Sep 2008 08:08:29 -0700 From: Bill Cheng Someone wrote: > I dont know if this is a proper solution to the problem, but I have a main > thread which spawns the arrival thread and S1 and S2. I set the main thread > to capture and handle the signal. Since the main thread never goes to sleep, > i believe that the signal will not be lost. Is this OK? I cannot answer the "is this okay" type questions. Please see: http://merlot.usc.edu/cs551-f08/description.html#email There is really not much difference whether you use the main thread or the arrival thread to catch . Your main thread *must effectively also sleep*, i.e., get blocked waiting for the ! If you do busy-wait, you will lose 30 points! -- Bill Cheng // bill.cheng@usc.edu On Thu, Sep 25, 2008 at 10:15 PM, Bill Cheng wrote: > Someone wrote: > > > I have a question about the signal handling. Suppose my arrival thread > > has already put 2 customer in the customer queue. The arrival thread is > > currently sleeping for fill up the interarrival time of the 3rd > > customer. Suppose the interarrival of the 3rd customer is 10secs. Thus > > arrival thread sleeps for 10 secs, so it will go in waiting processes > > queue. In this time, ont of the server threads will run. What if I press > > ctrl C in this time? The arrival thread who was responsible for handling > > this signal will not catch the signal (as it is on waiting queue). > > Should we handle ctrl C in S1 and S2 also? This problem doesn't happen > > frequently, but it can be seen in sample trace file when ctrl C is > > pressed after 11secs. > > If you call select() or usleep() to sleep in your arrival thread, > select() or usleep() should return with an error condition and > errno should be set to EINTR. If this is not happening, may > be you did not setup the sigmask correctly. Please do: > > man pthread_sigmask > > to see how to catch in pthread. > -- > Bill Cheng // bill.cheng@usc.edu