Return-Path: william@bourbon.usc.edu Delivery-Date: Thu Sep 25 08:19:53 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 m8PFJrBF014602 for ; Thu, 25 Sep 2008 08:19:53 -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 m8PFN0db018743 for ; Thu, 25 Sep 2008 08:23:00 -0700 Message-Id: <200809251523.m8PFN0db018743@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: CS551: warmup2 , calculating times Date: Thu, 25 Sep 2008 08:23:00 -0700 From: Bill Cheng Someone wrote: > While calculating the times, i.e the interarrival time, the queue leaving > time, queue entering time i am facing some trouble about lags. > for eg: when i do a gettimeofday before sleeping for interarrival time and > then display the interarrival time after the sleeping there will a lag of > few milliseconds introduced because of the call to gettimeofday. > > so, say, > time in ms (frome the start of program) = call to gettimeofday(&arrtime, > NULL); > time for sleep = getinterval > interarrival time = time in ms + time for sleep > > wil this be the interarrival time ? The interarrival time is the *measured* time between arrivals. You need a global variable to remember when the last customer arrived, let's call this X. When the current customer arrives, you read the clock and get the time of arrival of the current customer, let's call this Y. The measured interarrival time is Y-X. Then you do X <- Y. Please do not ask me if so many milliseconds of errro is reasonable. You need to convince yourself whether what you have done is correct or not. -- Bill Cheng // bill.cheng@usc.edu