Allow thread priority setting from inside kdl. Right now, a
single priority 12 thread can make the whole GUI appear frozen. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21736 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
696c54d067
commit
4e7050cd09
@ -528,6 +528,47 @@ make_thread_unreal(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
set_thread_prio(int argc, char **argv)
|
||||
{
|
||||
struct thread *thread;
|
||||
struct hash_iterator i;
|
||||
int32 id;
|
||||
int32 prio;
|
||||
|
||||
if (argc > 3 || argc < 2) {
|
||||
kprintf("usage: priority <priority> [thread-id]\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
prio = strtoul(argv[1], NULL, 0);
|
||||
if (prio > B_MAX_PRIORITY)
|
||||
prio = B_MAX_PRIORITY;
|
||||
if (prio < B_MIN_PRIORITY)
|
||||
prio = B_MIN_PRIORITY;
|
||||
|
||||
if (argc > 2)
|
||||
id = strtoul(argv[2], NULL, 0);
|
||||
else
|
||||
id = thread_get_current_thread()->id;
|
||||
|
||||
hash_open(sThreadHash, &i);
|
||||
|
||||
while ((thread = hash_next(sThreadHash, &i)) != NULL) {
|
||||
if (thread->id != id)
|
||||
continue;
|
||||
thread->priority = thread->next_priority = prio;
|
||||
kprintf("thread 0x%lx set to priority %ld\n", id, prio);
|
||||
break;
|
||||
}
|
||||
if (!thread)
|
||||
kprintf("thread 0x%lx not found\n", id);
|
||||
|
||||
hash_close(sThreadHash, &i, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
make_thread_suspended(int argc, char **argv)
|
||||
{
|
||||
@ -1638,6 +1679,7 @@ thread_init(kernel_args *args)
|
||||
add_debugger_command("suspend", &make_thread_suspended, "suspend a thread");
|
||||
add_debugger_command("resume", &make_thread_resumed, "resume a thread");
|
||||
add_debugger_command("drop", &drop_into_debugger, "drop a thread into the user-debugger");
|
||||
add_debugger_command("priority", &set_thread_prio, "set a thread priority");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user