* Removed B_{MIN|MAX}_PRIORITY from OS.h - they were never really intended
as public defines. They are now called THREAD_{MIN|MAX}_SET_PRIORITY to
better reflect what they are for. Minimum priority is now 1, ie. you no
longer can set another thread to the idle priority. This fixes part of
ticket #2959.
* set_thread_priority() will no longer allow to change the priority of the
idle thread to something else. This fixes the rest of ticket #2959.
* Automatic whitespace cleanup in OS.h.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28521 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+20
-22
@@ -65,17 +65,17 @@ typedef struct area_info {
|
|||||||
} area_info;
|
} area_info;
|
||||||
|
|
||||||
/* area locking */
|
/* area locking */
|
||||||
#define B_NO_LOCK 0
|
#define B_NO_LOCK 0
|
||||||
#define B_LAZY_LOCK 1
|
#define B_LAZY_LOCK 1
|
||||||
#define B_FULL_LOCK 2
|
#define B_FULL_LOCK 2
|
||||||
#define B_CONTIGUOUS 3
|
#define B_CONTIGUOUS 3
|
||||||
#define B_LOMEM 4
|
#define B_LOMEM 4
|
||||||
|
|
||||||
/* address spec for create_area(), and clone_area() */
|
/* address spec for create_area(), and clone_area() */
|
||||||
#define B_ANY_ADDRESS 0
|
#define B_ANY_ADDRESS 0
|
||||||
#define B_EXACT_ADDRESS 1
|
#define B_EXACT_ADDRESS 1
|
||||||
#define B_BASE_ADDRESS 2
|
#define B_BASE_ADDRESS 2
|
||||||
#define B_CLONE_ADDRESS 3
|
#define B_CLONE_ADDRESS 3
|
||||||
#define B_ANY_KERNEL_ADDRESS 4
|
#define B_ANY_KERNEL_ADDRESS 4
|
||||||
|
|
||||||
/* area protection */
|
/* area protection */
|
||||||
@@ -153,7 +153,7 @@ typedef struct port_message_info {
|
|||||||
} port_message_info;
|
} port_message_info;
|
||||||
|
|
||||||
// similar to port_buffer_size_etc(), but returns (more) info
|
// similar to port_buffer_size_etc(), but returns (more) info
|
||||||
extern status_t _get_port_message_info_etc(port_id port,
|
extern status_t _get_port_message_info_etc(port_id port,
|
||||||
port_message_info *info, size_t infoSize, uint32 flags,
|
port_message_info *info, size_t infoSize, uint32 flags,
|
||||||
bigtime_t timeout);
|
bigtime_t timeout);
|
||||||
|
|
||||||
@@ -303,12 +303,10 @@ typedef struct {
|
|||||||
#define B_URGENT_PRIORITY 110
|
#define B_URGENT_PRIORITY 110
|
||||||
#define B_REAL_TIME_PRIORITY 120
|
#define B_REAL_TIME_PRIORITY 120
|
||||||
|
|
||||||
#define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
|
|
||||||
#define B_MIN_PRIORITY B_IDLE_PRIORITY
|
|
||||||
#define B_MAX_PRIORITY B_REAL_TIME_PRIORITY
|
|
||||||
|
|
||||||
#define B_SYSTEM_TIMEBASE 0
|
#define B_SYSTEM_TIMEBASE 0
|
||||||
|
|
||||||
|
#define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
|
||||||
|
|
||||||
typedef status_t (*thread_func)(void *);
|
typedef status_t (*thread_func)(void *);
|
||||||
#define thread_entry thread_func
|
#define thread_entry thread_func
|
||||||
/* thread_entry is for backward compatibility only! Use thread_func */
|
/* thread_entry is for backward compatibility only! Use thread_func */
|
||||||
@@ -381,7 +379,7 @@ extern void debugger(const char *message);
|
|||||||
point errors, SIGILL for illegal instructions, etc).
|
point errors, SIGILL for illegal instructions, etc).
|
||||||
|
|
||||||
to re-enable the default debugger pass a zero.
|
to re-enable the default debugger pass a zero.
|
||||||
*/
|
*/
|
||||||
extern int disable_debugger(int state);
|
extern int disable_debugger(int state);
|
||||||
|
|
||||||
// TODO: Remove. Temporary debug helper.
|
// TODO: Remove. Temporary debug helper.
|
||||||
@@ -452,9 +450,9 @@ typedef enum cpu_types {
|
|||||||
B_CPU_PPC_IBM_POWER3 = 46,
|
B_CPU_PPC_IBM_POWER3 = 46,
|
||||||
|
|
||||||
/* Intel */
|
/* Intel */
|
||||||
|
|
||||||
/* Updated according to Intel(R) Processor Identification and
|
/* Updated according to Intel(R) Processor Identification and
|
||||||
* the CPUID instruction (Table 4)
|
* the CPUID instruction (Table 4)
|
||||||
* AP-485 Intel - 24161832.pdf
|
* AP-485 Intel - 24161832.pdf
|
||||||
*/
|
*/
|
||||||
B_CPU_INTEL_x86 = 0x1000,
|
B_CPU_INTEL_x86 = 0x1000,
|
||||||
@@ -489,11 +487,11 @@ typedef enum cpu_types {
|
|||||||
B_CPU_INTEL_PENTIUM_IV_MODEL_4,
|
B_CPU_INTEL_PENTIUM_IV_MODEL_4,
|
||||||
|
|
||||||
/* AMD */
|
/* AMD */
|
||||||
|
|
||||||
/* Checked with "AMD Processor Recognition Application Note"
|
/* Checked with "AMD Processor Recognition Application Note"
|
||||||
* (Table 3)
|
* (Table 3)
|
||||||
* 20734.pdf
|
* 20734.pdf
|
||||||
*/
|
*/
|
||||||
B_CPU_AMD_x86 = 0x1100,
|
B_CPU_AMD_x86 = 0x1100,
|
||||||
B_CPU_AMD_K5_MODEL_0 = 0x1150,
|
B_CPU_AMD_K5_MODEL_0 = 0x1150,
|
||||||
B_CPU_AMD_K5_MODEL_1,
|
B_CPU_AMD_K5_MODEL_1,
|
||||||
@@ -517,15 +515,15 @@ typedef enum cpu_types {
|
|||||||
B_CPU_AMD_ATHLON_XP_MODEL_7,
|
B_CPU_AMD_ATHLON_XP_MODEL_7,
|
||||||
B_CPU_AMD_ATHLON_XP_MODEL_8,
|
B_CPU_AMD_ATHLON_XP_MODEL_8,
|
||||||
B_CPU_AMD_ATHLON_XP_MODEL_10 = 0x116a, /* Barton */
|
B_CPU_AMD_ATHLON_XP_MODEL_10 = 0x116a, /* Barton */
|
||||||
|
|
||||||
B_CPU_AMD_SEMPRON_MODEL_8 = B_CPU_AMD_ATHLON_XP_MODEL_8,
|
B_CPU_AMD_SEMPRON_MODEL_8 = B_CPU_AMD_ATHLON_XP_MODEL_8,
|
||||||
B_CPU_AMD_SEMPRON_MODEL_10 = B_CPU_AMD_ATHLON_XP_MODEL_10,
|
B_CPU_AMD_SEMPRON_MODEL_10 = B_CPU_AMD_ATHLON_XP_MODEL_10,
|
||||||
|
|
||||||
/* According to "Revision Guide for AMD Family 10h
|
/* According to "Revision Guide for AMD Family 10h
|
||||||
* Processors" (41322.pdf)
|
* Processors" (41322.pdf)
|
||||||
*/
|
*/
|
||||||
B_CPU_AMD_PHENOM = 0x11f2,
|
B_CPU_AMD_PHENOM = 0x11f2,
|
||||||
|
|
||||||
/* According to "Revision guide for AMD Athlon 64
|
/* According to "Revision guide for AMD Athlon 64
|
||||||
* and AMD Opteron Processors" (25759.pdf)
|
* and AMD Opteron Processors" (25759.pdf)
|
||||||
*/
|
*/
|
||||||
@@ -633,7 +631,7 @@ typedef union {
|
|||||||
uint32 ebx;
|
uint32 ebx;
|
||||||
uint32 edx;
|
uint32 edx;
|
||||||
uint32 ecx;
|
uint32 ecx;
|
||||||
} regs;
|
} regs;
|
||||||
} cpuid_info;
|
} cpuid_info;
|
||||||
|
|
||||||
extern status_t get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 cpuNum);
|
extern status_t get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 cpuNum);
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ enum additional_thread_state {
|
|||||||
// THREAD_STATE_BIRTH // thread is being created
|
// THREAD_STATE_BIRTH // thread is being created
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define THREAD_MIN_SET_PRIORITY B_LOWEST_ACTIVE_PRIORITY
|
||||||
|
#define THREAD_MAX_SET_PRIORITY B_REAL_TIME_PRIORITY
|
||||||
|
|
||||||
enum team_state {
|
enum team_state {
|
||||||
TEAM_STATE_NORMAL, // normal state
|
TEAM_STATE_NORMAL, // normal state
|
||||||
TEAM_STATE_BIRTH, // being contructed
|
TEAM_STATE_BIRTH, // being contructed
|
||||||
@@ -49,6 +52,7 @@ typedef enum job_control_state {
|
|||||||
JOB_CONTROL_STATE_DEAD
|
JOB_CONTROL_STATE_DEAD
|
||||||
} job_control_state;
|
} job_control_state;
|
||||||
|
|
||||||
|
|
||||||
struct image; // defined in image.c
|
struct image; // defined in image.c
|
||||||
struct realtime_sem_context; // defined in realtime_sem.cpp
|
struct realtime_sem_context; // defined in realtime_sem.cpp
|
||||||
struct select_info;
|
struct select_info;
|
||||||
|
|||||||
@@ -873,10 +873,10 @@ set_thread_prio(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
prio = strtoul(argv[1], NULL, 0);
|
prio = strtoul(argv[1], NULL, 0);
|
||||||
if (prio > B_MAX_PRIORITY)
|
if (prio > THREAD_MAX_SET_PRIORITY)
|
||||||
prio = B_MAX_PRIORITY;
|
prio = THREAD_MAX_SET_PRIORITY;
|
||||||
if (prio < B_MIN_PRIORITY)
|
if (prio < THREAD_MIN_SET_PRIORITY)
|
||||||
prio = B_MIN_PRIORITY;
|
prio = THREAD_MIN_SET_PRIORITY;
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
id = strtoul(argv[2], NULL, 0);
|
id = strtoul(argv[2], NULL, 0);
|
||||||
@@ -2502,33 +2502,35 @@ set_thread_priority(thread_id id, int32 priority)
|
|||||||
int32 oldPriority;
|
int32 oldPriority;
|
||||||
|
|
||||||
// make sure the passed in priority is within bounds
|
// make sure the passed in priority is within bounds
|
||||||
if (priority > B_MAX_PRIORITY)
|
if (priority > THREAD_MAX_SET_PRIORITY)
|
||||||
priority = B_MAX_PRIORITY;
|
priority = THREAD_MAX_SET_PRIORITY;
|
||||||
if (priority < B_MIN_PRIORITY)
|
if (priority < THREAD_MIN_SET_PRIORITY)
|
||||||
priority = B_MIN_PRIORITY;
|
priority = THREAD_MIN_SET_PRIORITY;
|
||||||
|
|
||||||
thread = thread_get_current_thread();
|
thread = thread_get_current_thread();
|
||||||
if (thread->id == id) {
|
if (thread->id == id) {
|
||||||
// it's ourself, so we know we aren't in the run queue, and we can manipulate
|
if (thread_is_idle_thread(thread))
|
||||||
// our structure directly
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
|
// It's ourself, so we know we aren't in the run queue, and we can
|
||||||
|
// manipulate our structure directly
|
||||||
oldPriority = thread->priority;
|
oldPriority = thread->priority;
|
||||||
// note that this might not return the correct value if we are preempted
|
// Note that this might not return the correct value if we are
|
||||||
// here, and another thread changes our priority before the next line is
|
// preempted here, and another thread changes our priority before
|
||||||
// executed
|
// the next line is executed.
|
||||||
thread->priority = thread->next_priority = priority;
|
thread->priority = thread->next_priority = priority;
|
||||||
} else {
|
} else {
|
||||||
cpu_status state = disable_interrupts();
|
InterruptsSpinLocker _(gThreadSpinlock);
|
||||||
GRAB_THREAD_LOCK();
|
|
||||||
|
|
||||||
thread = thread_get_thread_struct_locked(id);
|
thread = thread_get_thread_struct_locked(id);
|
||||||
if (thread) {
|
if (thread == NULL)
|
||||||
oldPriority = thread->priority;
|
return B_BAD_THREAD_ID;
|
||||||
scheduler_set_thread_priority(thread, priority);
|
|
||||||
} else
|
|
||||||
oldPriority = B_BAD_THREAD_ID;
|
|
||||||
|
|
||||||
RELEASE_THREAD_LOCK();
|
if (thread_is_idle_thread(thread))
|
||||||
restore_interrupts(state);
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
|
oldPriority = thread->priority;
|
||||||
|
scheduler_set_thread_priority(thread, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldPriority;
|
return oldPriority;
|
||||||
|
|||||||
Reference in New Issue
Block a user