thread_defs.h revision 95118262
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()).
24enum {
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
32	THREAD_BLOCK_TYPE_OTHER					= 9999,
33	THREAD_BLOCK_TYPE_USER_BASE				= 10000
34};
35
36
37#define THREAD_CREATION_FLAG_DEFER_SIGNALS	0x01
38	// create the thread with signals deferred, i.e. with
39	// user_thread::defer_signals set to 1
40#ifdef _COMPAT_MODE
41#	define THREAD_CREATION_FLAG_COMPAT_MODE	0x02
42	// create the thread with a compatibility mode
43#endif
44
45
46struct thread_creation_attributes {
47	int32		(*entry)(void*, void*);
48	const char*	name;
49	int32		priority;
50	void*		args1;
51	void*		args2;
52	void*		stack_address;
53	size_t		stack_size;
54	size_t		guard_size;
55	pthread_t	pthread;
56	uint32		flags;
57};
58
59#endif	/* _SYSTEM_THREAD_DEFS_H */
60