xref: /haiku/headers/private/system/thread_defs.h (revision 445d4fd926c569e7b9ae28017da86280aaecbae2)
1 /*
2  * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _SYSTEM_THREAD_DEFS_H
6 #define _SYSTEM_THREAD_DEFS_H
7 
8 
9 #include <pthread.h>
10 
11 #include <OS.h>
12 
13 
14 /** Size of the stack given to teams in user space */
15 #define USER_STACK_GUARD_SIZE		(4 * B_PAGE_SIZE)		// 16 kB
16 #define MIN_USER_STACK_SIZE			(2 * B_PAGE_SIZE)		// 8 kB
17 #define MAX_USER_STACK_SIZE			(4096 * B_PAGE_SIZE)	// 16 MB
18 #define USER_MAIN_THREAD_STACK_SIZE	MAX_USER_STACK_SIZE
19 #define USER_STACK_SIZE				(64 * B_PAGE_SIZE)		// 256 kB
20 
21 
22 // The type of object a thread blocks on (thread::wait::type, set by
23 // thread_prepare_to_block()).
24 enum {
25 	THREAD_BLOCK_TYPE_SEMAPHORE				= 0,
26 	THREAD_BLOCK_TYPE_CONDITION_VARIABLE	= 1,
27 	THREAD_BLOCK_TYPE_SNOOZE				= 2,
28 	THREAD_BLOCK_TYPE_SIGNAL				= 3,
29 	THREAD_BLOCK_TYPE_MUTEX					= 4,
30 	THREAD_BLOCK_TYPE_RW_LOCK				= 5,
31 	THREAD_BLOCK_TYPE_USER					= 6,
32 
33 	THREAD_BLOCK_TYPE_OTHER_OBJECT			= 9998,
34 	THREAD_BLOCK_TYPE_OTHER					= 9999,
35 };
36 
37 
38 #define THREAD_CREATION_FLAG_DEFER_SIGNALS	0x01
39 	// create the thread with signals deferred, i.e. with
40 	// user_thread::defer_signals set to 1
41 
42 
43 struct thread_creation_attributes {
44 	int32		(*entry)(void*, void*);
45 	const char*	name;
46 	int32		priority;
47 	void*		args1;
48 	void*		args2;
49 	void*		stack_address;
50 	size_t		stack_size;
51 	size_t		guard_size;
52 	pthread_t	pthread;
53 	uint32		flags;
54 };
55 
56 #endif	/* _SYSTEM_THREAD_DEFS_H */
57