Changeset 408 for trunk/kernel/kern/thread.h
- Timestamp:
- Dec 5, 2017, 4:20:07 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.h
r407 r408 34 34 #include <spinlock.h> 35 35 #include <core.h> 36 #include <chdev.h> 36 37 #include <cluster.h> 37 38 #include <process.h> … … 96 97 #define THREAD_BLOCKED_RPC 0x0200 /*! thread wait RPC completion */ 97 98 98 #define THREAD_BLOCKED_DEV_QUEUE 0x2000 /*! thread DEV wait queue */99 99 #define THREAD_BLOCKED_DEV_ISR 0x4000 /*! thread DEV wait ISR */ 100 100 … … 132 132 * thread is registered in the local copy of the process descriptor. 133 133 * 134 * WARNING : Don't modify the first 4fields order, as this order is used by the134 * WARNING : Don't modify the first 3 fields order, as this order is used by the 135 135 * hal_kentry assembly code for the TSAR architecture. 136 136 **************************************************************************************/ … … 140 140 typedef struct thread_s 141 141 { 142 void * cpu_context; /*! used for context switch */ 143 void * fpu_context; /*! used for dynamic FPU allocation */ 142 void * cpu_context; /*! pointer on CPU context switch */ 143 void * fpu_context; /*! pointer on FPU context switch */ 144 void * uzone; /*! pointer on uzone for hal_kentry */ 144 145 145 146 intptr_t k_stack_base; /*! kernel stack base address */ … … 172 173 173 174 uint32_t flags; /*! bit vector of flags */ 174 volatile uint32_t blocked; /*! bit vector of blocking causes*/175 volatile uint32_t signals; /*! bit vector of (KILL / SUICIDE) signals*/175 uint32_t signals; /*! bit vector of (KILL / SUICIDE) signals */ 176 uint32_t blocked; /*! bit vector of blocking causes */ 176 177 177 178 error_t errno; /*! errno value set by last system call */ … … 189 190 list_entry_t sched_list; /*! member of threads attached to same core */ 190 191 191 uint32_t dev_channel; /*! device channel for a DEV thread */ 192 chdev_t * chdev; /*! chdev pointer (for a DEV thread only) */ 193 194 reg_t save_sr; /*! used by sched_yield() function */ 192 195 193 196 ioc_command_t ioc_cmd; /*! IOC device generic command */ … … 222 225 223 226 /*************************************************************************************** 224 * This function allocates memory for a user thread descriptor in the local cluster,225 * and initializes it from information contained in the arguments.226 * It is used by the "pthread_create" system call.227 * The CPU context is initialized from scratch , and the "loadable" field is set.228 * The new thread is attached to the core specified in the <attr> argument.227 * This function is used by the pthread_create() system call to create a "new" thread 228 * in an existing process. It allocates memory for an user thread descriptor in the 229 * local cluster, and initializes it from information contained in the arguments. 230 * The CPU context is initialized from scratch. If required by the <attr> argument, 231 * the new thread is attached to the core specified in <attr>. 229 232 * It is registered in the local process descriptor specified by the <pid> argument. 230 233 * The thread descriptor pointer is returned to allow the parent thread to register it … … 246 249 247 250 /*************************************************************************************** 248 * This function is used by the fork() system call to create the child process main249 * thread. It allocates memory for an user thread descriptor in the local cluster,250 * and initializes it from information contained in the calling thread descriptor.251 * This function is used by the sys_fork() system call to create the "child" thread 252 * in the local cluster. It allocates memory for a thread descriptor, and initializes 253 * it from the "parent" thread descriptor defined by the <parent_thread_xp> argument. 251 254 * The new thread is attached to the core that has the lowest load in local cluster. 252 * It is registered in the child process descriptor defined by the <process> argument.255 * It is registered in the "child" process defined by the <child_process> argument. 253 256 * This new thread inherits its user stack from the parent thread, as it uses the 254 257 * Copy-On-Write mechanism to get a private stack when required. … … 256 259 * the Copy-On-Write mechanism cannot be used for kernel segments (because kernel 257 260 * uses physical addressing on some architectures). 258 * The CPU and FPU execution contexts are created and linked to the new thread, 259 * but the actual context copy is NOT done. The THREAD_BLOCKED_GLOBAL bit is set, 260 * and the thread must be explicitely unblocked later to make the new thread runable. 261 *************************************************************************************** 262 * @ process : local pointer on owner process descriptor. 263 * @ stack_base : user stack base address (from parent). 264 * @ stack_size : user stack size (from parent). 265 * @ new_thread : [out] address of buffer for new thread descriptor pointer. 266 * @ returns 0 if success / returns ENOMEM if error. 267 **************************************************************************************/ 268 error_t thread_user_fork( process_t * process, 269 intptr_t stack_base, 270 uint32_t stack_size, 271 thread_t ** new_thread ); 261 * The CPU and FPU execution contexts are created and linked to the new thread. 262 * but the actual context copy is NOT done, and must be done by by the sys_fork(). 263 * The THREAD_BLOCKED_GLOBAL bit is set => the thread must be activated to start. 264 *************************************************************************************** 265 * @ parent_thread_xp : extended pointer on parent thread descriptor. 266 * @ child_process : local pointer on child process descriptor. 267 * @ child_thread : [out] address of buffer for child thread descriptor pointer. 268 * @ returns 0 if success / returns -1 if error. 269 **************************************************************************************/ 270 error_t thread_user_fork( xptr_t parent_thread_xp, 271 process_t * child_process, 272 thread_t ** child_thread ); 272 273 273 274 /*************************************************************************************** 274 275 * This function allocates memory for a kernel thread descriptor in the local cluster, 275 * and initializes it from arguments values, calling the thread_kernel_init() function, 276 * that also allocates and initializes the CPU context. 276 * and initializes it from arguments values. 277 * It is called by kernel_init() to statically create all DEV server threads 278 * It is also called to dynamically create RPC threads when required. 277 279 * The THREAD_BLOCKED_GLOBAL bit is set, and the thread must be activated to start. 278 280 *************************************************************************************** … … 291 293 292 294 /*************************************************************************************** 293 * This function initializes an existing kernelthread descriptor from arguments values.295 * This function initializes an existing thread descriptor from arguments values. 294 296 * The THREAD_BLOCKED_GLOBAL bit is set, and the thread must be activated to start. 297 * It is called by the kernel_init() function to initialize the IDLE thread. 295 298 *************************************************************************************** 296 299 * @ thread : pointer on existing thread descriptor.
Note: See TracChangeset
for help on using the changeset viewer.