Subject | Re: New feature request (thread priority) |
---|---|
Author | strobel@ait-augsburg.de |
Post date | 2000-11-28T11:08:38Z |
I think we can easily test how lucky we are with higher/lower thread
priorities w/o changing the engine.
On Win32 a UDF can change the priority of the current thread.
Something like this (Delphi, see below).
BTW: Is it for sure that one transaction (or connection?) always
utilizes one thread and the two transactions (connections?) never
share the context of the same thread..?
Cheers,
Karsten Strobel
function QueryThreadPriority: Integer; cdecl; export;
{
DECLARE EXTERNAL FUNCTION QUERY_THREAD_PRIORITY
RETURNS INTEGER BY VALUE
ENTRY_POINT 'QUERY_THREAD_PRIORITY' MODULE_NAME 'COMPLEXUDF';
}
begin
Result := Windows.GetThreadPriority(GetCurrentThread);
end;
function SetThreadPriority(var ANewPrio: Integer): Integer; cdecl;
export;
{
DECLARE EXTERNAL FUNCTION SET_THREAD_PRIORITY
INTEGER
RETURNS INTEGER BY VALUE
ENTRY_POINT 'SET_THREAD_PRIORITY' MODULE_NAME 'COMPLEXUDF';
}
begin
Result := Ord(Windows.SetThreadPriority(GetCurrentThread,
ANewPrio));
end;
FYI about the Parameter of SetThreadPriority:
const
THREAD_BASE_PRIORITY_LOWRT = 15; { value that gets a thread to
LowRealtime-1 }
THREAD_BASE_PRIORITY_MAX = 2; { maximum thread base priority
boost }
THREAD_BASE_PRIORITY_MIN = -2; { minimum thread base priority
boost }
THREAD_BASE_PRIORITY_IDLE = -15; { value that gets a thread to idle
}
THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN;
THREAD_PRIORITY_BELOW_NORMAL = THREAD_PRIORITY_LOWEST + 1;
THREAD_PRIORITY_NORMAL = 0;
THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX;
THREAD_PRIORITY_ABOVE_NORMAL = THREAD_PRIORITY_HIGHEST - 1;
THREAD_PRIORITY_ERROR_RETURN = MAXLONG;
THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT;
THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE;
priorities w/o changing the engine.
On Win32 a UDF can change the priority of the current thread.
Something like this (Delphi, see below).
BTW: Is it for sure that one transaction (or connection?) always
utilizes one thread and the two transactions (connections?) never
share the context of the same thread..?
Cheers,
Karsten Strobel
function QueryThreadPriority: Integer; cdecl; export;
{
DECLARE EXTERNAL FUNCTION QUERY_THREAD_PRIORITY
RETURNS INTEGER BY VALUE
ENTRY_POINT 'QUERY_THREAD_PRIORITY' MODULE_NAME 'COMPLEXUDF';
}
begin
Result := Windows.GetThreadPriority(GetCurrentThread);
end;
function SetThreadPriority(var ANewPrio: Integer): Integer; cdecl;
export;
{
DECLARE EXTERNAL FUNCTION SET_THREAD_PRIORITY
INTEGER
RETURNS INTEGER BY VALUE
ENTRY_POINT 'SET_THREAD_PRIORITY' MODULE_NAME 'COMPLEXUDF';
}
begin
Result := Ord(Windows.SetThreadPriority(GetCurrentThread,
ANewPrio));
end;
FYI about the Parameter of SetThreadPriority:
const
THREAD_BASE_PRIORITY_LOWRT = 15; { value that gets a thread to
LowRealtime-1 }
THREAD_BASE_PRIORITY_MAX = 2; { maximum thread base priority
boost }
THREAD_BASE_PRIORITY_MIN = -2; { minimum thread base priority
boost }
THREAD_BASE_PRIORITY_IDLE = -15; { value that gets a thread to idle
}
THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN;
THREAD_PRIORITY_BELOW_NORMAL = THREAD_PRIORITY_LOWEST + 1;
THREAD_PRIORITY_NORMAL = 0;
THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX;
THREAD_PRIORITY_ABOVE_NORMAL = THREAD_PRIORITY_HIGHEST - 1;
THREAD_PRIORITY_ERROR_RETURN = MAXLONG;
THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT;
THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE;