/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- * Author: Isaac Huang <isaac@clusterfs.com>
+ * GPL HEADER START
*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/selftest/timer.c
+ *
+ * Author: Isaac Huang <isaac@clusterfs.com>
*/
#define DEBUG_SUBSYSTEM S_LNET
-#include <libcfs/kp30.h>
-#include <libcfs/libcfs.h>
-#include <lnet/lib-lnet.h>
-
#include "selftest.h"
struct list_head stt_hash[STTIMER_NSLOTS];
int stt_shuttingdown;
#ifdef __KERNEL__
+ cfs_waitq_t stt_waitq;
int stt_nthreads;
#endif
} stt_data;
int
stt_timer_main (void *arg)
{
+ int rc = 0;
UNUSED(arg);
cfs_daemonize("st_timer");
while (!stt_data.stt_shuttingdown) {
stt_check_timers(&stt_data.stt_prev_slot);
- set_current_state(CFS_TASK_INTERRUPTIBLE);
- cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE,
- cfs_time_seconds(STTIMER_SLOTTIME));
+ cfs_waitq_wait_event_timeout(stt_data.stt_waitq,
+ stt_data.stt_shuttingdown,
+ cfs_time_seconds(STTIMER_SLOTTIME),
+ rc);
}
spin_lock(&stt_data.stt_lock);
#ifdef __KERNEL__
stt_data.stt_nthreads = 0;
+ cfs_waitq_init(&stt_data.stt_waitq);
rc = stt_start_timer_thread();
if (rc != 0)
- CERROR ("Can't spawn timer, stt_startup() has failed: %d\n", rc);
+ CERROR ("Can't spawn timer thread: %d\n", rc);
#endif
return rc;
stt_data.stt_shuttingdown = 1;
#ifdef __KERNEL__
+ cfs_waitq_signal(&stt_data.stt_waitq);
lst_wait_until(stt_data.stt_nthreads == 0, stt_data.stt_lock,
"waiting for %d threads to terminate\n",
stt_data.stt_nthreads);