X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=kernel%2Frtmutex-tester.c;h=a56f629b057a75be4ff0428d265b8c833886dd85;hb=83f5b01ffbbaea6f97c9a79d21e240dbfb69f2f1;hp=fe211ba3a5b5df0836712fec7996b716e5b555a7;hpb=61a87122869b6340a63b6f9f84097d3688604b90;p=safe%2Fjmp%2Flinux-2.6 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c index fe211ba..a56f629 100644 --- a/kernel/rtmutex-tester.c +++ b/kernel/rtmutex-tester.c @@ -6,7 +6,6 @@ * Copyright (C) 2006, Timesys Corp., Thomas Gleixner * */ -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include #include "rtmutex.h" @@ -33,7 +33,7 @@ struct test_thread_data { }; static struct test_thread_data thread_data[MAX_RT_TEST_THREADS]; -static task_t *threads[MAX_RT_TEST_THREADS]; +static struct task_struct *threads[MAX_RT_TEST_THREADS]; static struct rt_mutex mutexes[MAX_RT_TEST_MUTEXES]; enum test_opcodes { @@ -46,7 +46,7 @@ enum test_opcodes { RTTEST_LOCKINTNOWAIT, /* 6 Lock interruptible no wait in wakeup, data = lockindex */ RTTEST_LOCKCONT, /* 7 Continue locking after the wakeup delay */ RTTEST_UNLOCK, /* 8 Unlock, data = lockindex */ - RTTEST_LOCKBKL, /* 9 Lock BKL */ + RTTEST_LOCKBKL, /* 9 Lock BKL */ RTTEST_UNLOCKBKL, /* 10 Unlock BKL */ RTTEST_SIGNAL, /* 11 Signal other test thread, data = thread id */ RTTEST_RESETEVENT = 98, /* 98 Reset event counter */ @@ -55,7 +55,6 @@ enum test_opcodes { static int handle_op(struct test_thread_data *td, int lockwakeup) { - struct sched_param schedpar; int i, id, ret = -EINVAL; switch(td->opcode) { @@ -63,17 +62,6 @@ static int handle_op(struct test_thread_data *td, int lockwakeup) case RTTEST_NOP: return 0; - case RTTEST_SCHEDOT: - schedpar.sched_priority = 0; - ret = sched_setscheduler(current, SCHED_NORMAL, &schedpar); - if (!ret) - set_user_nice(current, 0); - return ret; - - case RTTEST_SCHEDRT: - schedpar.sched_priority = td->opdata; - return sched_setscheduler(current, SCHED_FIFO, &schedpar); - case RTTEST_LOCKCONT: td->mutexes[td->opdata] = 1; td->event = atomic_add_return(1, &rttest_event); @@ -272,6 +260,7 @@ static int test_func(void *data) int ret; current->flags |= PF_MUTEX_TESTER; + set_freezable(); allow_signal(SIGHUP); for(;;) { @@ -287,6 +276,7 @@ static int test_func(void *data) /* Wait for the next command to be executed */ schedule(); + try_to_freeze(); if (signal_pending(current)) flush_signals(current); @@ -307,12 +297,13 @@ static int test_func(void *data) * * opcode:data */ -static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, - size_t count) +static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr, + const char *buf, size_t count) { + struct sched_param schedpar; struct test_thread_data *td; char cmdbuf[32]; - int op, dat, tid; + int op, dat, tid, ret; td = container_of(dev, struct test_thread_data, sysdev); tid = td->sysdev.id; @@ -334,6 +325,21 @@ static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, return -EINVAL; switch (op) { + case RTTEST_SCHEDOT: + schedpar.sched_priority = 0; + ret = sched_setscheduler(threads[tid], SCHED_NORMAL, &schedpar); + if (ret) + return ret; + set_user_nice(current, 0); + break; + + case RTTEST_SCHEDRT: + schedpar.sched_priority = dat; + ret = sched_setscheduler(threads[tid], SCHED_FIFO, &schedpar); + if (ret) + return ret; + break; + case RTTEST_SIGNAL: send_sig(SIGHUP, threads[tid], 0); break; @@ -354,11 +360,12 @@ static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf, * @dev: thread to query * @buf: char buffer to be filled with thread status info */ -static ssize_t sysfs_test_status(struct sys_device *dev, char *buf) +static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr, + char *buf) { struct test_thread_data *td; + struct task_struct *tsk; char *curr = buf; - task_t *tsk; int i; td = container_of(dev, struct test_thread_data, sysdev); @@ -388,7 +395,7 @@ static SYSDEV_ATTR(status, 0600, sysfs_test_status, NULL); static SYSDEV_ATTR(command, 0600, NULL, sysfs_test_command); static struct sysdev_class rttest_sysclass = { - set_kset_name("rttest"), + .name = "rttest", }; static int init_test_thread(int id)