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	THREAD_BLOCK_TYPE_USER					= 6,
32
33	THREAD_BLOCK_TYPE_OTHER					= 9999,
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
41
42struct thread_creation_attributes {
43	int32		(*entry)(void*, void*);
44	const char*	name;
45	int32		priority;
46	void*		args1;
47	void*		args2;
48	void*		stack_address;
49	size_t		stack_size;
50	size_t		guard_size;
51	pthread_t	pthread;
52	uint32		flags;
53};
54
55#endif	/* _SYSTEM_THREAD_DEFS_H */
56