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_PAGES 4 // 16 kB 16 #define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024 \ 17 - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB 18 #define USER_STACK_SIZE (256 * 1024 \ 19 - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 256 kB 20 #define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB 21 #define MAX_USER_STACK_SIZE (16 * 1024 * 1024 \ 22 - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB 23 24 25 // The type of object a thread blocks on (thread::wait::type, set by 26 // thread_prepare_to_block()). 27 enum { 28 THREAD_BLOCK_TYPE_SEMAPHORE = 0, 29 THREAD_BLOCK_TYPE_CONDITION_VARIABLE = 1, 30 THREAD_BLOCK_TYPE_SNOOZE = 2, 31 THREAD_BLOCK_TYPE_SIGNAL = 3, 32 THREAD_BLOCK_TYPE_MUTEX = 4, 33 THREAD_BLOCK_TYPE_RW_LOCK = 5, 34 35 THREAD_BLOCK_TYPE_OTHER = 9999, 36 THREAD_BLOCK_TYPE_USER_BASE = 10000 37 }; 38 39 40 #define THREAD_CREATION_FLAG_DEFER_SIGNALS 0x01 41 // create the thread with signals deferred, i.e. with 42 // user_thread::defer_signals set to 1 43 44 45 struct thread_creation_attributes { 46 int32 (*entry)(void*, void*); 47 const char* name; 48 int32 priority; 49 void* args1; 50 void* args2; 51 void* stack_address; 52 size_t stack_size; 53 pthread_t pthread; 54 uint32 flags; 55 }; 56 57 #endif /* _SYSTEM_THREAD_DEFS_H */ 58