Added thread::io_priority field and functions to get/set it.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27247 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -48,6 +48,9 @@ int32 thread_used_threads(void);
|
|||||||
|
|
||||||
const char* thread_state_to_text(struct thread* thread, int32 state);
|
const char* thread_state_to_text(struct thread* thread, int32 state);
|
||||||
|
|
||||||
|
int32 thread_get_io_priority(thread_id id);
|
||||||
|
void thread_set_io_priority(int32 priority);
|
||||||
|
|
||||||
#define thread_get_current_thread arch_thread_get_current_thread
|
#define thread_get_current_thread arch_thread_get_current_thread
|
||||||
|
|
||||||
struct thread *thread_get_thread_struct(thread_id id);
|
struct thread *thread_get_thread_struct(thread_id id);
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ struct thread {
|
|||||||
char name[B_OS_NAME_LENGTH];
|
char name[B_OS_NAME_LENGTH];
|
||||||
int32 priority;
|
int32 priority;
|
||||||
int32 next_priority;
|
int32 next_priority;
|
||||||
|
int32 io_priority;
|
||||||
int32 state;
|
int32 state;
|
||||||
int32 next_state;
|
int32 next_state;
|
||||||
struct cpu_ent *cpu;
|
struct cpu_ent *cpu;
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ create_thread_struct(struct thread *inthread, const char *name,
|
|||||||
thread->team_next = NULL;
|
thread->team_next = NULL;
|
||||||
thread->queue_next = NULL;
|
thread->queue_next = NULL;
|
||||||
thread->priority = thread->next_priority = -1;
|
thread->priority = thread->next_priority = -1;
|
||||||
|
thread->io_priority = -1;
|
||||||
thread->args1 = NULL; thread->args2 = NULL;
|
thread->args1 = NULL; thread->args2 = NULL;
|
||||||
thread->alarm.period = 0;
|
thread->alarm.period = 0;
|
||||||
reset_signals(thread);
|
reset_signals(thread);
|
||||||
@@ -1991,6 +1992,37 @@ thread_state_to_text(struct thread* thread, int32 state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
thread_get_io_priority(thread_id id)
|
||||||
|
{
|
||||||
|
// take a shortcut, if it is the current thread
|
||||||
|
struct thread* thread = thread_get_current_thread();
|
||||||
|
int32 priority;
|
||||||
|
if (id == thread->id) {
|
||||||
|
int32 priority = thread->io_priority;
|
||||||
|
return priority < 0 ? thread->priority : priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not the current thread -- get it
|
||||||
|
InterruptsSpinLocker locker(gThreadSpinlock);
|
||||||
|
|
||||||
|
thread = thread_get_thread_struct_locked(id);
|
||||||
|
if (thread == NULL)
|
||||||
|
return B_BAD_THREAD_ID;
|
||||||
|
|
||||||
|
priority = thread->io_priority;
|
||||||
|
return priority < 0 ? thread->priority : priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
thread_set_io_priority(int32 priority)
|
||||||
|
{
|
||||||
|
struct thread* thread = thread_get_current_thread();
|
||||||
|
thread->io_priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
thread_init(kernel_args *args)
|
thread_init(kernel_args *args)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user