コード例 #1
0
static void timer_task_proc(void *arg)
{
	struct rt_tmbench_context *ctx = arg;
	int count;

	/* first event: one millisecond from now. */
	ctx->date = rtdm_clock_read_monotonic() + 1000000;

	while (1) {
		int err;

		for (count = 0; count < ctx->samples_per_sec; count++) {
			RTDM_EXECUTE_ATOMICALLY(
				ctx->start_time = rtdm_clock_read_monotonic();
				err =
				    rtdm_task_sleep_abs(ctx->date,
							RTDM_TIMERMODE_ABSOLUTE);
			);

			if (err)
				return;

			eval_inner_loop(ctx,
					(long)(rtdm_clock_read_monotonic() -
					       ctx->date));
		}
		eval_outer_loop(ctx);
	}
コード例 #2
0
static irqreturn_t
timer_proc (int irq, void *dev_id, struct pt_regs *regs)
{
    struct rt_tmbench_context *ctx = (struct rt_tmbench_context *) dev_id;
    volatile unsigned long long tsc;

    read_tsc (tsc);
    eval_inner_loop (ctx, (long) (tsc - ctx->date));

    tb_timer_stop ();

    read_tsc (ctx->start_time);

    tb_timer_start ((long) (ctx->date - ctx->start_time));

    if (++ctx->curr.test_loops < ctx->samples_per_sec)
        return IRQ_HANDLED;

    ctx->curr.test_loops = 0;
    eval_outer_loop (ctx);

    return IRQ_HANDLED;
}