1 /* 2 * Copyright 2008, 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 #include <OS.h> 9 10 11 #define THREAD_RETURN_EXIT 0x1 12 #define THREAD_RETURN_INTERRUPTED 0x2 13 #define THREAD_STOPPED 0x3 14 #define THREAD_CONTINUED 0x4 15 16 /** Size of the stack given to teams in user space */ 17 #define USER_STACK_GUARD_PAGES 4 // 16 kB 18 #define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024 \ 19 - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB 20 #define USER_STACK_SIZE (256 * 1024 \ 21 - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 256 kB 22 #define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB 23 #define MAX_USER_STACK_SIZE (16 * 1024 * 1024 \ 24 - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB 25 26 27 // The type of object a thread blocks on (thread::wait::type, set by 28 // thread_prepare_to_block()). 29 enum { 30 THREAD_BLOCK_TYPE_SEMAPHORE = 0, 31 THREAD_BLOCK_TYPE_CONDITION_VARIABLE = 1, 32 THREAD_BLOCK_TYPE_SNOOZE = 2, 33 THREAD_BLOCK_TYPE_SIGNAL = 3, 34 THREAD_BLOCK_TYPE_MUTEX = 4, 35 THREAD_BLOCK_TYPE_RW_LOCK = 5, 36 37 THREAD_BLOCK_TYPE_OTHER = 9999, 38 THREAD_BLOCK_TYPE_USER_BASE = 10000 39 }; 40 41 42 struct thread_creation_attributes { 43 int32 (*entry)(thread_func, void *); 44 const char* name; 45 int32 priority; 46 void* args1; 47 void* args2; 48 void* stack_address; 49 size_t stack_size; 50 51 // when calling from kernel only 52 team_id team; 53 thread_id thread; 54 }; 55 56 #endif /* _SYSTEM_THREAD_DEFS_H */ 57