4 * Copyright (C) 1998 Alexandre Julliard
7 #ifndef __WINE_SERVER_THREAD_H
8 #define __WINE_SERVER_THREAD_H
10 #ifndef __WINE_SERVER__
11 #error This file can only be used in the Wine server
16 /* thread structure */
25 enum run_state
{ STARTING
, RUNNING
, SLEEPING
, TERMINATED
};
29 struct object obj
; /* object header */
30 struct thread
*next
; /* system-wide thread list */
32 struct thread
*proc_next
; /* per-process thread list */
33 struct thread
*proc_prev
;
34 struct process
*process
;
35 struct mutex
*mutex
; /* list of currently owned mutexes */
36 struct debug_ctx
*debug_ctx
; /* debugger context if this thread is a debugger */
37 struct process
*debug_first
; /* head of debugged processes list */
38 struct debug_event
*debug_event
; /* pending debug event for this thread */
39 struct thread_wait
*wait
; /* current wait condition if sleeping */
40 struct thread_apc
*apc
; /* list of async procedure calls */
41 int apc_count
; /* number of outstanding APCs */
42 int error
; /* current error code */
43 enum run_state state
; /* running state */
44 int exit_code
; /* thread exit code */
45 struct client
*client
; /* client for socket communications */
46 int unix_pid
; /* Unix pid of client */
47 void *teb
; /* TEB address (in client address space) */
48 int priority
; /* priority level */
49 int affinity
; /* affinity mask */
50 int suspend
; /* suspend count */
51 void *buffer
; /* buffer for communication with the client */
52 enum request last_req
; /* last request received (for debugging) */
55 extern struct thread
*current
;
57 /* thread functions */
59 extern void create_initial_thread( int fd
);
60 extern struct thread
*get_thread_from_id( void *id
);
61 extern struct thread
*get_thread_from_handle( int handle
, unsigned int access
);
62 extern void suspend_all_threads( void );
63 extern void resume_all_threads( void );
64 extern int add_queue( struct object
*obj
, struct wait_queue_entry
*entry
);
65 extern void remove_queue( struct object
*obj
, struct wait_queue_entry
*entry
);
66 extern void kill_thread( struct thread
*thread
, int exit_code
);
67 extern void thread_killed( struct thread
*thread
, int exit_code
);
68 extern void thread_timeout(void);
69 extern void wake_up( struct object
*obj
, int max
);
71 static inline int get_error(void) { return current
->error
; }
72 static inline void set_error( int err
) { current
->error
= err
; }
73 static inline void clear_error(void) { set_error(0); }
75 #endif /* __WINE_SERVER_THREAD_H */