[stgt] [PATCH] new timer-based work scheduling
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Thu Jan 20 07:42:34 CET 2011
Hey,
On Tue, 18 Jan 2011 12:28:20 +0900
FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp> wrote:
> On Mon, 17 Jan 2011 21:05:11 +0200
> Alexander Nezhinsky <alexandern at Voltaire.COM> wrote:
>
> > +static void work_timer_evt_handler(int fd, int events, void *data)
> > +{
> > + unsigned long long n; /* timer expirations */
> > + int ret;
> > +
> > + ret = read(timer_fd_rd, &n, sizeof(n));
> > + if (ret < 0) {
> > + if (ret == -EAGAIN)
> > + return;
> > + eprintf("Failed to read from pipe, %m\n");
> > + return;
> > + }
> > + current_time += n * WORK_TIMER_INT_MSEC;
>
> Hmm, I think that you need gettimeofday for this signal
> approach. Signals could be lost (the process could miss a signal when
> it's too busy) so the above code doesn't work.
>
> timerfd is nice because reading the file descriptor tells how many
> times the timer expires.
>
> As I wrote, I don't want to add gettimeofday for the timerfd approach
> but using gettimeofday for this signal approach is fine by me.
>
> One thing I want to change in your previous patch is using 'unsigned
> int when' in tgt_work struct instead of struct timeval. It allows the
> timerfd and signal appoaches to share that. The signal appoach can
> convert struct timeval to unsigned int current_time.
I did by myself. Alexander, can you check if this works for you.
Thanks,
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list