Re: [PATCH] new timer-based work scheduling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 17 Jan 2011 21:05:11 +0200
Alexander Nezhinsky <alexandern@xxxxxxxxxxxx> 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.

Thanks,
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux