Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
54a39e25
Commit
54a39e25
authored
May 29, 1999
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got rid of THREAD_InitDone.
Made THREAD_Current() inline. Moved server tid into TEB.
parent
8e238d04
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
86 additions
and
80 deletions
+86
-80
thread.h
include/thread.h
+22
-12
task.c
loader/task.c
+3
-5
client.c
scheduler/client.c
+14
-10
process.c
scheduler/process.c
+1
-1
sysdeps.c
scheduler/sysdeps.c
+34
-14
syslevel.c
scheduler/syslevel.c
+4
-4
thread.c
scheduler/thread.c
+6
-32
queue.c
windows/queue.c
+1
-1
winproc.c
windows/winproc.c
+1
-1
No files found.
include/thread.h
View file @
54a39e25
...
@@ -29,11 +29,11 @@ typedef struct _TEB
...
@@ -29,11 +29,11 @@ typedef struct _TEB
WORD
flags
;
/* 1c Flags */
WORD
flags
;
/* 1c Flags */
WORD
mutex_count
;
/* 1e Win16 mutex count */
WORD
mutex_count
;
/* 1e Win16 mutex count */
DWORD
debug_context
;
/* 20 Debug context */
DWORD
debug_context
;
/* 20 Debug context */
DWORD
*
ppriority
;
/* 24 Pointer to current priority
*/
void
*
tid
;
/* 24 Thread id
*/
HQUEUE16
queue
;
/* 28 Message queue */
HQUEUE16
queue
;
/* 28 Message queue */
WORD
pad1
;
/* 2a */
WORD
pad1
;
/* 2a */
LPVOID
*
tls_ptr
;
/* 2c Pointer to TLS array */
LPVOID
*
tls_ptr
;
/* 2c Pointer to TLS array */
struct
_PDB
*
process
;
/* 30 owning process (used by NT3.51 applets)*/
struct
_PDB
*
process
;
/* 30 owning process (used by NT3.51 applets)*/
}
TEB
;
}
TEB
;
/* Thread exception flags */
/* Thread exception flags */
...
@@ -84,7 +84,6 @@ typedef struct _THDB
...
@@ -84,7 +84,6 @@ typedef struct _THDB
/* The following are Wine-specific fields */
/* The following are Wine-specific fields */
int
socket
;
/* Socket for server communication */
int
socket
;
/* Socket for server communication */
unsigned
int
seq
;
/* Server sequence number */
unsigned
int
seq
;
/* Server sequence number */
void
*
server_tid
;
/* Server id for this thread */
void
(
*
startup
)(
void
);
/* Thread startup routine */
void
(
*
startup
)(
void
);
/* Thread startup routine */
struct
_THDB
*
next
;
/* Global thread list */
struct
_THDB
*
next
;
/* Global thread list */
DWORD
cleanup
;
/* Cleanup service handle */
DWORD
cleanup
;
/* Cleanup service handle */
...
@@ -96,27 +95,38 @@ typedef struct _THDB
...
@@ -96,27 +95,38 @@ typedef struct _THDB
/* The per-thread signal stack size */
/* The per-thread signal stack size */
#define SIGNAL_STACK_SIZE 16384
#define SIGNAL_STACK_SIZE 16384
#ifdef __i386__
/* On the i386, the current thread is in the %fs register */
# define SET_CUR_THREAD(thdb) SET_FS((thdb)->teb_sel)
#else
extern
THDB
*
pCurrentThread
;
# define SET_CUR_THREAD(thdb) (pCurrentThread = (thdb))
#endif
/* __i386__ */
/* scheduler/thread.c */
/* scheduler/thread.c */
extern
THDB
*
THREAD_CreateInitialThread
(
struct
_PDB
*
pdb
,
int
server_fd
);
extern
THDB
*
THREAD_CreateInitialThread
(
struct
_PDB
*
pdb
,
int
server_fd
);
extern
THDB
*
THREAD_Create
(
struct
_PDB
*
pdb
,
DWORD
flags
,
extern
THDB
*
THREAD_Create
(
struct
_PDB
*
pdb
,
DWORD
flags
,
DWORD
stack_size
,
BOOL
alloc_stack16
,
DWORD
stack_size
,
BOOL
alloc_stack16
,
LPSECURITY_ATTRIBUTES
sa
,
int
*
server_handle
);
LPSECURITY_ATTRIBUTES
sa
,
int
*
server_handle
);
extern
THDB
*
THREAD_Current
(
void
);
extern
BOOL
THREAD_IsWin16
(
THDB
*
thdb
);
extern
BOOL
THREAD_IsWin16
(
THDB
*
thdb
);
extern
THDB
*
THREAD_IdToTHDB
(
DWORD
id
);
extern
THDB
*
THREAD_IdToTHDB
(
DWORD
id
);
/* scheduler/sysdeps.c */
/* scheduler/sysdeps.c */
extern
int
SYSDEPS_SpawnThread
(
THDB
*
thread
);
extern
int
SYSDEPS_SpawnThread
(
THDB
*
thread
);
extern
void
SYSDEPS_SetCurThread
(
THDB
*
thread
);
extern
void
SYSDEPS_ExitThread
(
void
);
extern
void
SYSDEPS_ExitThread
(
void
);
extern
TEB
*
WINAPI
NtCurrentTeb
(
void
);
extern
TEB
*
WINAPI
NtCurrentTeb
(
void
);
/* return the current thread TEB pointer */
static
inline
TEB
*
CURRENT
(
void
)
{
#ifdef __i386__
TEB
*
teb
;
__asm__
(
".byte 0x64
\n\t
movl (0x18),%0"
:
"=r"
(
teb
)
);
return
teb
;
#else
return
NtCurrentTeb
();
#endif
}
/* return the current thread THDB pointer */
static
inline
THDB
*
THREAD_Current
(
void
)
{
TEB
*
teb
=
CURRENT
();
return
(
THDB
*
)((
char
*
)
teb
-
(
int
)
&
((
THDB
*
)
0
)
->
teb
);
}
#endif
/* __WINE_THREAD_H */
#endif
/* __WINE_THREAD_H */
loader/task.c
View file @
54a39e25
...
@@ -66,8 +66,6 @@ static HANDLE TASK_ScheduleEvent = INVALID_HANDLE_VALUE;
...
@@ -66,8 +66,6 @@ static HANDLE TASK_ScheduleEvent = INVALID_HANDLE_VALUE;
static
void
TASK_YieldToSystem
(
void
);
static
void
TASK_YieldToSystem
(
void
);
extern
BOOL
THREAD_InitDone
;
/***********************************************************************
/***********************************************************************
* TASK_InstallTHHook
* TASK_InstallTHHook
...
@@ -239,7 +237,7 @@ static void TASK_CallToStart(void)
...
@@ -239,7 +237,7 @@ static void TASK_CallToStart(void)
NE_MODULE
*
pModule
=
NE_GetPtr
(
pTask
->
hModule
);
NE_MODULE
*
pModule
=
NE_GetPtr
(
pTask
->
hModule
);
SEGTABLEENTRY
*
pSegTable
=
NE_SEG_TABLE
(
pModule
);
SEGTABLEENTRY
*
pSegTable
=
NE_SEG_TABLE
(
pModule
);
S
ET_CUR_THREAD
(
pTask
->
thdb
);
S
YSDEPS_SetCurThread
(
pTask
->
thdb
);
CLIENT_InitThread
();
CLIENT_InitThread
();
/* Terminate the stack frame chain */
/* Terminate the stack frame chain */
...
@@ -825,7 +823,7 @@ BOOL TASK_Reschedule(void)
...
@@ -825,7 +823,7 @@ BOOL TASK_Reschedule(void)
SYSLEVEL_ReleaseWin16Lock
();
SYSLEVEL_ReleaseWin16Lock
();
hCurrentTask
=
hTask
;
hCurrentTask
=
hTask
;
S
ET_CUR_THREAD
(
pNewTask
->
thdb
);
S
YSDEPS_SetCurThread
(
pNewTask
->
thdb
);
pNewTask
->
ss_sp
=
pNewTask
->
thdb
->
cur_stack
;
pNewTask
->
ss_sp
=
pNewTask
->
thdb
->
cur_stack
;
SYSLEVEL_RestoreWin16Lock
();
SYSLEVEL_RestoreWin16Lock
();
...
@@ -1415,7 +1413,7 @@ void WINAPI GetTaskQueueES16( CONTEXT *context )
...
@@ -1415,7 +1413,7 @@ void WINAPI GetTaskQueueES16( CONTEXT *context )
*/
*/
HTASK16
WINAPI
GetCurrentTask
(
void
)
HTASK16
WINAPI
GetCurrentTask
(
void
)
{
{
return
THREAD_InitDone
?
PROCESS_Current
()
->
task
:
0
;
return
PROCESS_Current
()
->
task
;
}
}
DWORD
WINAPI
WIN16_GetCurrentTask
(
void
)
DWORD
WINAPI
WIN16_GetCurrentTask
(
void
)
...
...
scheduler/client.c
View file @
54a39e25
...
@@ -32,9 +32,9 @@
...
@@ -32,9 +32,9 @@
*
*
* Die on protocol errors or socket close
* Die on protocol errors or socket close
*/
*/
static
void
CLIENT_Die
(
THDB
*
thdb
)
static
void
CLIENT_Die
(
void
)
{
{
close
(
thdb
->
socket
);
close
(
THREAD_Current
()
->
socket
);
SYSDEPS_ExitThread
();
SYSDEPS_ExitThread
();
}
}
...
@@ -43,14 +43,13 @@ static void CLIENT_Die( THDB *thdb )
...
@@ -43,14 +43,13 @@ static void CLIENT_Die( THDB *thdb )
*/
*/
void
CLIENT_ProtocolError
(
const
char
*
err
,
...
)
void
CLIENT_ProtocolError
(
const
char
*
err
,
...
)
{
{
THDB
*
thdb
=
THREAD_Current
();
va_list
args
;
va_list
args
;
va_start
(
args
,
err
);
va_start
(
args
,
err
);
fprintf
(
stderr
,
"Client protocol error:%p: "
,
thdb
->
server_
tid
);
fprintf
(
stderr
,
"Client protocol error:%p: "
,
CURRENT
()
->
tid
);
vfprintf
(
stderr
,
err
,
args
);
vfprintf
(
stderr
,
err
,
args
);
va_end
(
args
);
va_end
(
args
);
CLIENT_Die
(
thdb
);
CLIENT_Die
();
}
}
...
@@ -116,7 +115,11 @@ static void CLIENT_SendRequest_v( enum request req, int pass_fd,
...
@@ -116,7 +115,11 @@ static void CLIENT_SendRequest_v( enum request req, int pass_fd,
if
((
ret
=
sendmsg
(
thdb
->
socket
,
&
msghdr
,
0
))
<
len
)
if
((
ret
=
sendmsg
(
thdb
->
socket
,
&
msghdr
,
0
))
<
len
)
{
{
if
(
ret
==
-
1
)
perror
(
"sendmsg"
);
if
(
ret
==
-
1
)
{
if
(
errno
==
EPIPE
)
CLIENT_Die
();
perror
(
"sendmsg"
);
}
CLIENT_ProtocolError
(
"partial msg sent %d/%d
\n
"
,
ret
,
len
);
CLIENT_ProtocolError
(
"partial msg sent %d/%d
\n
"
,
ret
,
len
);
}
}
/* we passed the fd now we can close it */
/* we passed the fd now we can close it */
...
@@ -193,10 +196,11 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
...
@@ -193,10 +196,11 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
while
((
ret
=
recvmsg
(
thdb
->
socket
,
&
msghdr
,
0
))
==
-
1
)
while
((
ret
=
recvmsg
(
thdb
->
socket
,
&
msghdr
,
0
))
==
-
1
)
{
{
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EPIPE
)
CLIENT_Die
();
perror
(
"recvmsg"
);
perror
(
"recvmsg"
);
CLIENT_ProtocolError
(
"recvmsg
\n
"
);
CLIENT_ProtocolError
(
"recvmsg
\n
"
);
}
}
if
(
!
ret
)
CLIENT_Die
(
thdb
);
/* the server closed the connection; time to die... */
if
(
!
ret
)
CLIENT_Die
();
/* the server closed the connection; time to die... */
/* sanity checks */
/* sanity checks */
...
@@ -240,7 +244,7 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
...
@@ -240,7 +244,7 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
perror
(
"recv"
);
perror
(
"recv"
);
CLIENT_ProtocolError
(
"recv
\n
"
);
CLIENT_ProtocolError
(
"recv
\n
"
);
}
}
if
(
!
addlen
)
CLIENT_Die
(
thdb
);
/* the server closed the connection; time to die... */
if
(
!
addlen
)
CLIENT_Die
();
/* the server closed the connection; time to die... */
if
(
len
)
*
len
+=
addlen
;
if
(
len
)
*
len
+=
addlen
;
remaining
-=
addlen
;
remaining
-=
addlen
;
}
}
...
@@ -257,7 +261,7 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
...
@@ -257,7 +261,7 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd,
perror
(
"recv"
);
perror
(
"recv"
);
CLIENT_ProtocolError
(
"recv
\n
"
);
CLIENT_ProtocolError
(
"recv
\n
"
);
}
}
if
(
!
addlen
)
CLIENT_Die
(
thdb
);
/* the server closed the connection; time to die... */
if
(
!
addlen
)
CLIENT_Die
();
/* the server closed the connection; time to die... */
remaining
-=
addlen
;
remaining
-=
addlen
;
}
}
...
@@ -367,7 +371,7 @@ int CLIENT_InitThread(void)
...
@@ -367,7 +371,7 @@ int CLIENT_InitThread(void)
CLIENT_SendRequest
(
REQ_INIT_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_INIT_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
-
1
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
-
1
;
thdb
->
process
->
server_pid
=
reply
.
pid
;
thdb
->
process
->
server_pid
=
reply
.
pid
;
thdb
->
server_
tid
=
reply
.
tid
;
thdb
->
teb
.
tid
=
reply
.
tid
;
return
0
;
return
0
;
}
}
...
...
scheduler/process.c
View file @
54a39e25
...
@@ -606,7 +606,7 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
...
@@ -606,7 +606,7 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
if
(
!
(
thdb
=
THREAD_Create
(
pdb
,
0L
,
size
,
hInstance
==
0
,
tsa
,
&
server_thandle
)))
if
(
!
(
thdb
=
THREAD_Create
(
pdb
,
0L
,
size
,
hInstance
==
0
,
tsa
,
&
server_thandle
)))
goto
error
;
goto
error
;
info
->
hThread
=
server_thandle
;
info
->
hThread
=
server_thandle
;
info
->
dwThreadId
=
(
DWORD
)
thdb
->
server_
tid
;
info
->
dwThreadId
=
(
DWORD
)
thdb
->
teb
.
tid
;
thdb
->
startup
=
PROCESS_Start
;
thdb
->
startup
=
PROCESS_Start
;
if
(
pModule
->
module32
)
if
(
pModule
->
module32
)
...
...
scheduler/sysdeps.c
View file @
54a39e25
...
@@ -54,6 +54,12 @@ extern int clone( int (*fn)(void *arg), void *stack, int flags, void *arg );
...
@@ -54,6 +54,12 @@ extern int clone( int (*fn)(void *arg), void *stack, int flags, void *arg );
# endif
/* CLONE_VM */
# endif
/* CLONE_VM */
#endif
/* HAVE_CLONE_SYSCALL */
#endif
/* HAVE_CLONE_SYSCALL */
static
int
init_done
;
#ifndef __i386__
static
THDB
*
pCurrentThread
;
#endif
#ifndef NO_REENTRANT_LIBC
#ifndef NO_REENTRANT_LIBC
...
@@ -72,11 +78,12 @@ int *__error()
...
@@ -72,11 +78,12 @@ int *__error()
int
*
___errno
()
int
*
___errno
()
#endif
#endif
{
{
THDB
*
thdb
=
THREAD_Current
();
THDB
*
thdb
;
if
(
!
thdb
)
return
perrno
;
if
(
!
init_done
)
return
perrno
;
thdb
=
THREAD_Current
();
#ifdef NO_REENTRANT_X11
#ifdef NO_REENTRANT_X11
/* Use static libc errno while running in Xlib. */
/* Use static libc errno while running in Xlib. */
if
(
X11DRV_CritSection
.
OwningThread
==
(
HANDLE
)
thdb
->
server_
tid
)
if
(
X11DRV_CritSection
.
OwningThread
==
(
HANDLE
)
thdb
->
teb
.
tid
)
return
perrno
;
return
perrno
;
#endif
#endif
return
&
thdb
->
thread_errno
;
return
&
thdb
->
thread_errno
;
...
@@ -89,11 +96,12 @@ int *___errno()
...
@@ -89,11 +96,12 @@ int *___errno()
*/
*/
int
*
__h_errno_location
()
int
*
__h_errno_location
()
{
{
THDB
*
thdb
=
THREAD_Current
();
THDB
*
thdb
;
if
(
!
thdb
)
return
ph_errno
;
if
(
!
init_done
)
return
ph_errno
;
thdb
=
THREAD_Current
();
#ifdef NO_REENTRANT_X11
#ifdef NO_REENTRANT_X11
/* Use static libc h_errno while running in Xlib. */
/* Use static libc h_errno while running in Xlib. */
if
(
X11DRV_CritSection
.
OwningThread
==
(
HANDLE
)
thdb
->
server_
tid
)
if
(
X11DRV_CritSection
.
OwningThread
==
(
HANDLE
)
thdb
->
teb
.
tid
)
return
ph_errno
;
return
ph_errno
;
#endif
#endif
return
&
thdb
->
thread_h_errno
;
return
&
thdb
->
thread_h_errno
;
...
@@ -102,16 +110,33 @@ int *__h_errno_location()
...
@@ -102,16 +110,33 @@ int *__h_errno_location()
#endif
/* NO_REENTRANT_LIBC */
#endif
/* NO_REENTRANT_LIBC */
/***********************************************************************
/***********************************************************************
* SYSDEPS_SetCurThread
*
* Make 'thread' the current thread.
*/
void
SYSDEPS_SetCurThread
(
THDB
*
thread
)
{
#ifdef __i386__
/* On the i386, the current thread is in the %fs register */
SET_FS
(
thread
->
teb_sel
);
#else
/* FIXME: only works if there is no preemptive task-switching going on... */
pCurrentThread
=
thread
;
#endif
/* __i386__ */
init_done
=
1
;
/* now we can use threading routines */
}
/***********************************************************************
* SYSDEPS_StartThread
* SYSDEPS_StartThread
*
*
* Startup routine for a new thread.
* Startup routine for a new thread.
*/
*/
static
void
SYSDEPS_StartThread
(
THDB
*
thdb
)
static
void
SYSDEPS_StartThread
(
THDB
*
thdb
)
{
{
S
ET_CUR_THREAD
(
thdb
);
S
YSDEPS_SetCurThread
(
thdb
);
CLIENT_InitThread
();
CLIENT_InitThread
();
thdb
->
startup
();
thdb
->
startup
();
_exit
(
0
);
/* should never get here */
SYSDEPS_ExitThread
(
);
/* should never get here */
}
}
...
@@ -197,12 +222,7 @@ void SYSDEPS_ExitThread(void)
...
@@ -197,12 +222,7 @@ void SYSDEPS_ExitThread(void)
TEB
*
WINAPI
NtCurrentTeb
(
void
)
TEB
*
WINAPI
NtCurrentTeb
(
void
)
{
{
#ifdef __i386__
#ifdef __i386__
TEB
*
teb
;
return
CURRENT
();
/* Get the TEB self-pointer */
__asm__
(
".byte 0x64
\n\t
movl (%1),%0"
:
"=r"
(
teb
)
:
"r"
(
&
((
TEB
*
)
0
)
->
self
)
);
return
teb
;
#else
#else
return
&
pCurrentThread
->
teb
;
return
&
pCurrentThread
->
teb
;
#endif
/* __i386__ */
#endif
/* __i386__ */
...
...
scheduler/syslevel.c
View file @
54a39e25
...
@@ -75,7 +75,7 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
...
@@ -75,7 +75,7 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
int
i
;
int
i
;
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count before %ld
\n
"
,
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count before %ld
\n
"
,
lock
,
lock
->
level
,
thdb
->
server_
tid
,
thdb
->
teb_sel
,
getpid
(),
lock
,
lock
->
level
,
thdb
->
teb
.
tid
,
thdb
->
teb_sel
,
getpid
(),
thdb
->
sys_count
[
lock
->
level
]
);
thdb
->
sys_count
[
lock
->
level
]
);
for
(
i
=
3
;
i
>
lock
->
level
;
i
--
)
for
(
i
=
3
;
i
>
lock
->
level
;
i
--
)
...
@@ -91,7 +91,7 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
...
@@ -91,7 +91,7 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
thdb
->
sys_mutex
[
lock
->
level
]
=
lock
;
thdb
->
sys_mutex
[
lock
->
level
]
=
lock
;
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count after %ld
\n
"
,
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count after %ld
\n
"
,
lock
,
lock
->
level
,
thdb
->
server_
tid
,
thdb
->
teb_sel
,
getpid
(),
lock
,
lock
->
level
,
thdb
->
teb
.
tid
,
thdb
->
teb_sel
,
getpid
(),
thdb
->
sys_count
[
lock
->
level
]
);
thdb
->
sys_count
[
lock
->
level
]
);
if
(
lock
==
&
Win16Mutex
)
if
(
lock
==
&
Win16Mutex
)
...
@@ -106,7 +106,7 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock)
...
@@ -106,7 +106,7 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock)
THDB
*
thdb
=
THREAD_Current
();
THDB
*
thdb
=
THREAD_Current
();
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count before %ld
\n
"
,
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count before %ld
\n
"
,
lock
,
lock
->
level
,
thdb
->
server_
tid
,
thdb
->
teb_sel
,
getpid
(),
lock
,
lock
->
level
,
thdb
->
teb
.
tid
,
thdb
->
teb_sel
,
getpid
(),
thdb
->
sys_count
[
lock
->
level
]
);
thdb
->
sys_count
[
lock
->
level
]
);
if
(
thdb
->
sys_count
[
lock
->
level
]
<=
0
||
thdb
->
sys_mutex
[
lock
->
level
]
!=
lock
)
if
(
thdb
->
sys_count
[
lock
->
level
]
<=
0
||
thdb
->
sys_mutex
[
lock
->
level
]
!=
lock
)
...
@@ -124,7 +124,7 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock)
...
@@ -124,7 +124,7 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock)
LeaveCriticalSection
(
&
lock
->
crst
);
LeaveCriticalSection
(
&
lock
->
crst
);
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count after %ld
\n
"
,
TRACE
(
"(%p, level %d): thread %p (fs %04x, pid %d) count after %ld
\n
"
,
lock
,
lock
->
level
,
thdb
->
server_
tid
,
thdb
->
teb_sel
,
getpid
(),
lock
,
lock
->
level
,
thdb
->
teb
.
tid
,
thdb
->
teb_sel
,
getpid
(),
thdb
->
sys_count
[
lock
->
level
]
);
thdb
->
sys_count
[
lock
->
level
]
);
}
}
...
...
scheduler/thread.c
View file @
54a39e25
...
@@ -28,13 +28,6 @@
...
@@ -28,13 +28,6 @@
DEFAULT_DEBUG_CHANNEL
(
thread
)
DEFAULT_DEBUG_CHANNEL
(
thread
)
#ifndef __i386__
THDB
*
pCurrentThread
;
#endif
/* Is threading code initialized? */
BOOL
THREAD_InitDone
=
FALSE
;
/* THDB of the initial thread */
/* THDB of the initial thread */
static
THDB
initial_thdb
;
static
THDB
initial_thdb
;
...
@@ -42,17 +35,6 @@ static THDB initial_thdb;
...
@@ -42,17 +35,6 @@ static THDB initial_thdb;
THDB
*
THREAD_First
=
&
initial_thdb
;
THDB
*
THREAD_First
=
&
initial_thdb
;
/***********************************************************************
/***********************************************************************
* THREAD_Current
*
* Return the current thread THDB pointer.
*/
THDB
*
THREAD_Current
(
void
)
{
if
(
!
THREAD_InitDone
)
return
NULL
;
return
(
THDB
*
)((
char
*
)
NtCurrentTeb
()
-
(
int
)
&
((
THDB
*
)
0
)
->
teb
);
}
/***********************************************************************
* THREAD_IsWin16
* THREAD_IsWin16
*/
*/
BOOL
THREAD_IsWin16
(
THDB
*
thdb
)
BOOL
THREAD_IsWin16
(
THDB
*
thdb
)
...
@@ -72,7 +54,7 @@ THDB *THREAD_IdToTHDB( DWORD id )
...
@@ -72,7 +54,7 @@ THDB *THREAD_IdToTHDB( DWORD id )
if
(
!
id
)
return
THREAD_Current
();
if
(
!
id
)
return
THREAD_Current
();
while
(
thdb
)
while
(
thdb
)
{
{
if
((
DWORD
)
thdb
->
server_
tid
==
id
)
return
thdb
;
if
((
DWORD
)
thdb
->
teb
.
tid
==
id
)
return
thdb
;
thdb
=
thdb
->
next
;
thdb
=
thdb
->
next
;
}
}
/* Allow task handles to be used; convert to main thread */
/* Allow task handles to be used; convert to main thread */
...
@@ -202,8 +184,7 @@ THDB *THREAD_CreateInitialThread( PDB *pdb, int server_fd )
...
@@ -202,8 +184,7 @@ THDB *THREAD_CreateInitialThread( PDB *pdb, int server_fd )
MESSAGE
(
"Could not allocate fs register for initial thread
\n
"
);
MESSAGE
(
"Could not allocate fs register for initial thread
\n
"
);
return
NULL
;
return
NULL
;
}
}
SET_CUR_THREAD
(
&
initial_thdb
);
SYSDEPS_SetCurThread
(
&
initial_thdb
);
THREAD_InitDone
=
TRUE
;
/* Now proceed with normal initialization */
/* Now proceed with normal initialization */
...
@@ -259,7 +240,7 @@ THDB *THREAD_Create( PDB *pdb, DWORD flags, DWORD stack_size, BOOL alloc_stack16
...
@@ -259,7 +240,7 @@ THDB *THREAD_Create( PDB *pdb, DWORD flags, DWORD stack_size, BOOL alloc_stack16
request
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
request
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
CLIENT_SendRequest
(
REQ_NEW_THREAD
,
fd
[
1
],
1
,
&
request
,
sizeof
(
request
)
);
CLIENT_SendRequest
(
REQ_NEW_THREAD
,
fd
[
1
],
1
,
&
request
,
sizeof
(
request
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
goto
error
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
goto
error
;
thdb
->
server_
tid
=
reply
.
tid
;
thdb
->
teb
.
tid
=
reply
.
tid
;
*
server_handle
=
reply
.
handle
;
*
server_handle
=
reply
.
handle
;
/* Do the rest of the initialization */
/* Do the rest of the initialization */
...
@@ -321,7 +302,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
...
@@ -321,7 +302,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
CloseHandle
(
handle
);
CloseHandle
(
handle
);
return
INVALID_HANDLE_VALUE
;
return
INVALID_HANDLE_VALUE
;
}
}
if
(
id
)
*
id
=
(
DWORD
)
thread
->
server_
tid
;
if
(
id
)
*
id
=
(
DWORD
)
thread
->
teb
.
tid
;
return
handle
;
return
handle
;
}
}
...
@@ -359,10 +340,7 @@ HANDLE WINAPI GetCurrentThread(void)
...
@@ -359,10 +340,7 @@ HANDLE WINAPI GetCurrentThread(void)
*/
*/
DWORD
WINAPI
GetCurrentThreadId
(
void
)
DWORD
WINAPI
GetCurrentThreadId
(
void
)
{
{
THDB
*
thdb
=
THREAD_Current
();
return
(
DWORD
)
CURRENT
()
->
tid
;
assert
(
thdb
);
assert
(
thdb
->
server_tid
);
return
(
DWORD
)
thdb
->
server_tid
;
}
}
...
@@ -391,12 +369,8 @@ void WINAPI SetLastError(
...
@@ -391,12 +369,8 @@ void WINAPI SetLastError(
DWORD
error
)
/* [in] Per-thread error code */
DWORD
error
)
/* [in] Per-thread error code */
{
{
THDB
*
thread
=
THREAD_Current
();
THDB
*
thread
=
THREAD_Current
();
/* This one must work before we have a thread (FIXME) */
TRACE
(
"%p error=0x%lx
\n
"
,
thread
,
error
);
TRACE
(
"%p error=0x%lx
\n
"
,
thread
,
error
);
thread
->
last_error
=
error
;
if
(
thread
)
thread
->
last_error
=
error
;
}
}
...
...
windows/queue.c
View file @
54a39e25
...
@@ -1370,7 +1370,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process )
...
@@ -1370,7 +1370,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process )
if
(
!
queue
)
return
0
;
if
(
!
queue
)
return
0
;
if
(
process
)
*
process
=
(
DWORD
)
queue
->
thdb
->
process
->
server_pid
;
if
(
process
)
*
process
=
(
DWORD
)
queue
->
thdb
->
process
->
server_pid
;
retvalue
=
(
DWORD
)
queue
->
thdb
->
server_
tid
;
retvalue
=
(
DWORD
)
queue
->
thdb
->
teb
.
tid
;
QUEUE_Unlock
(
queue
);
QUEUE_Unlock
(
queue
);
return
retvalue
;
return
retvalue
;
...
...
windows/winproc.c
View file @
54a39e25
...
@@ -1114,7 +1114,7 @@ INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
...
@@ -1114,7 +1114,7 @@ INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
message queues.
message queues.
*/
*/
HTASK16
htask
=
(
HTASK16
)
*
plparam
;
HTASK16
htask
=
(
HTASK16
)
*
plparam
;
DWORD
idThread
=
(
DWORD
)((
TDB
*
)
GlobalLock16
(
htask
))
->
thdb
->
server_
tid
;
DWORD
idThread
=
(
DWORD
)((
TDB
*
)
GlobalLock16
(
htask
))
->
thdb
->
teb
.
tid
;
*
plparam
=
(
LPARAM
)
idThread
;
*
plparam
=
(
LPARAM
)
idThread
;
}
}
return
1
;
return
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment