|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
001 /* Copyright (C) 2004,2005 David Decotigny 001 /* Copyright (C) 2004,2005 David Decotigny 002 002 003 This program is free software; you can redi 003 This program is free software; you can redistribute it and/or 004 modify it under the terms of the GNU Genera 004 modify it under the terms of the GNU General Public License 005 as published by the Free Software Foundatio 005 as published by the Free Software Foundation; either version 2 006 of the License, or (at your option) any lat 006 of the License, or (at your option) any later version. 007 007 008 This program is distributed in the hope tha 008 This program is distributed in the hope that it will be useful, 009 but WITHOUT ANY WARRANTY; without even the 009 but WITHOUT ANY WARRANTY; without even the implied warranty of 010 MERCHANTABILITY or FITNESS FOR A PARTICULAR 010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 011 GNU General Public License for more details 011 GNU General Public License for more details. 012 012 013 You should have received a copy of the GNU 013 You should have received a copy of the GNU General Public License 014 along with this program; if not, write to t 014 along with this program; if not, write to the Free Software 015 Foundation, Inc., 59 Temple Place - Suite 3 015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 016 USA. 016 USA. 017 */ 017 */ 018 #ifndef _SOS_THREAD_H_ 018 #ifndef _SOS_THREAD_H_ 019 #define _SOS_THREAD_H_ 019 #define _SOS_THREAD_H_ 020 020 021 /** 021 /** 022 * @file thread.h 022 * @file thread.h 023 * 023 * 024 * SOS Thread management API 024 * SOS Thread management API 025 */ 025 */ 026 026 027 #include <sos/errno.h> 027 #include <sos/errno.h> 028 028 029 /* Forward declaration */ 029 /* Forward declaration */ 030 struct sos_thread; 030 struct sos_thread; 031 031 032 #include <hwcore/cpu_context.h> 032 #include <hwcore/cpu_context.h> 033 #include <sos/sched.h> 033 #include <sos/sched.h> 034 #include <sos/kwaitq.h> 034 #include <sos/kwaitq.h> 035 #include <sos/time.h> 035 #include <sos/time.h> 036 #include <sos/process.h> 036 #include <sos/process.h> >> 037 #include <sos/umem_vmm.h> 037 038 038 /** 039 /** 039 * The possible states of a valid thread 040 * The possible states of a valid thread 040 */ 041 */ 041 typedef enum { SOS_THR_CREATED, /**< Thread cr 042 typedef enum { SOS_THR_CREATED, /**< Thread created, not fully initialized */ 042 SOS_THR_READY, /**< Thread fu 043 SOS_THR_READY, /**< Thread fully initialized or 043 waiting f 044 waiting for CPU after having been 044 blocked o 045 blocked or preempted */ 045 SOS_THR_RUNNING, /**< Thread cu 046 SOS_THR_RUNNING, /**< Thread currently running on CPU */ 046 SOS_THR_BLOCKED, /**< Thread wa 047 SOS_THR_BLOCKED, /**< Thread waiting for I/O (+ in at LEAST 047 one kwait 048 one kwaitq) and/or sleeping (+ in NO 048 kwaitq) * 049 kwaitq) */ 049 SOS_THR_ZOMBIE, /**< Thread te 050 SOS_THR_ZOMBIE, /**< Thread terminated execution, waiting to 050 be delete 051 be deleted by kernel */ 051 } sos_thread_state_t; 052 } sos_thread_state_t; 052 053 053 054 054 /** 055 /** 055 * TCB (Thread Control Block): structure descr 056 * TCB (Thread Control Block): structure describing a thread. Don't 056 * access these fields directly: prefer using 057 * access these fields directly: prefer using the accessor functions 057 * below. 058 * below. 058 */ 059 */ 059 struct sos_thread 060 struct sos_thread 060 { 061 { 061 #define SOS_THR_MAX_NAMELEN 32 062 #define SOS_THR_MAX_NAMELEN 32 062 char name[SOS_THR_MAX_NAMELEN]; 063 char name[SOS_THR_MAX_NAMELEN]; 063 064 064 sos_thread_state_t state; 065 sos_thread_state_t state; 065 sos_sched_priority_t priority; 066 sos_sched_priority_t priority; 066 067 067 /** 068 /** 068 * The hardware context of the thread. 069 * The hardware context of the thread. 069 * 070 * 070 * It will reflect the CPU state of the thre 071 * It will reflect the CPU state of the thread: 071 * - From an interrupt handler: the state o 072 * - From an interrupt handler: the state of the thread at the time 072 * of the OUTERMOST irq. An IRQ is not al 073 * of the OUTERMOST irq. An IRQ is not allowed to make context 073 * switches, so this context will remain 074 * switches, so this context will remain valid from the begining of 074 * the outermost IRQ handler to the end o 075 * the outermost IRQ handler to the end of it, no matter if there 075 * are other IRQ handlers nesting in one 076 * are other IRQ handlers nesting in one another. You may safely 076 * use it from IRQ handlers to query the 077 * use it from IRQ handlers to query the state of the interrupted 077 * thread, no matter if there has been ot 078 * thread, no matter if there has been other IRQ handlers 078 * executing meanwhile. 079 * executing meanwhile. 079 * - From normal kernel code, exceptions an 080 * - From normal kernel code, exceptions and syscall: the state of 080 * the thread the last time there was a c 081 * the thread the last time there was a context switch from this 081 * thread to another one. Thus this field 082 * thread to another one. Thus this field WON'T reflect the 082 * current's thread cpu_state in these ca 083 * current's thread cpu_state in these cases. So, in these cases, 083 * simply DO NOT USE IT outside thread.c 084 * simply DO NOT USE IT outside thread.c ! Note: for syscall and 084 * exception handlers, the VALID state of 085 * exception handlers, the VALID state of the interrupted thread is 085 * passed as an argument to the handlers. 086 * passed as an argument to the handlers. 086 */ 087 */ 087 struct sos_cpu_state *cpu_state; 088 struct sos_cpu_state *cpu_state; 088 089 089 /* Kernel stack parameters */ 090 /* Kernel stack parameters */ 090 sos_vaddr_t kernel_stack_base_addr; 091 sos_vaddr_t kernel_stack_base_addr; 091 sos_size_t kernel_stack_size; 092 sos_size_t kernel_stack_size; 092 093 093 /* Process this thread belongs to. Always NU 094 /* Process this thread belongs to. Always NULL for a kernel 094 thread */ 095 thread */ 095 struct sos_process *process; 096 struct sos_process *process; 096 097 097 /** 098 /** 098 * Address space currently "squatted" by the 099 * Address space currently "squatted" by the thread, or used to be 099 * active when the thread was interrupted/pr 100 * active when the thread was interrupted/preempted. This is the MMU 100 * configuration expected before the cpu_sta 101 * configuration expected before the cpu_state of the thread is 101 * restored on CPU. 102 * restored on CPU. 102 * - For kernel threads: should normally b 103 * - For kernel threads: should normally be NULL, meaning that the 103 * thread will squat the current mm_cont 104 * thread will squat the current mm_context currently set in the 104 * MMU. Might be NON NULL when a kernel 105 * MMU. Might be NON NULL when a kernel thread squats a given 105 * process to manipulate its address spa 106 * process to manipulate its address space. 106 * - For user threads: should normally be 107 * - For user threads: should normally be NULL. More precisely: 107 * - in user mode: the thread->process 108 * - in user mode: the thread->process.mm_context is ALWAYS 108 * set on MMU. squatted_mm_context i 109 * set on MMU. squatted_mm_context is ALWAYS NULL in this 109 * situation, meaning that the threa 110 * situation, meaning that the thread in user mode uses its 110 * process-space as expected 111 * process-space as expected 111 * - in kernel mode: NULL means that w 112 * - in kernel mode: NULL means that we keep on using the 112 * mm_context currently set on MMU, 113 * mm_context currently set on MMU, which might be the 113 * mm_context of another process. Th 114 * mm_context of another process. This is natural since a 114 * thread in kernel mode normally on 115 * thread in kernel mode normally only uses data in kernel 115 * space. BTW, this limits the numbe 116 * space. BTW, this limits the number of TLB flushes. However, 116 * there are exceptions where this s 117 * there are exceptions where this squatted_mm_context will 117 * NOT be NULL. One is the copy_from 118 * NOT be NULL. One is the copy_from/to_user API, which can 118 * force the effective mm_context so 119 * force the effective mm_context so that the MMU will be 119 * (re)configured upon every context 120 * (re)configured upon every context to the thread to match 120 * the squatted_mm_context. Another 121 * the squatted_mm_context. Another exception is when a parent 121 * thread creates the address space 122 * thread creates the address space of a child process, in 122 * which case the parent thread migh 123 * which case the parent thread might temporarilly decide to 123 * switch to the child's process spa 124 * switch to the child's process space. 124 * 125 * 125 * This is the SOS implementation of the Lin 126 * This is the SOS implementation of the Linux "Lazy TLB" and 126 * address-space loaning. 127 * address-space loaning. 127 */ 128 */ 128 struct sos_mm_context *squatted_mm_context; 129 struct sos_mm_context *squatted_mm_context; 129 130 130 /* Data specific to each state */ 131 /* Data specific to each state */ 131 union 132 union 132 { 133 { 133 struct 134 struct 134 { 135 { 135 struct sos_sched_queue *rdy_queue; 136 struct sos_sched_queue *rdy_queue; 136 struct sos_thread *rdy_prev, *rdy_ne 137 struct sos_thread *rdy_prev, *rdy_next; 137 } ready; 138 } ready; 138 << 139 struct << 140 { << 141 struct sos_time user_time_spent_in_slice << 142 } running; << 143 }; /* Anonymous union (gcc extenion) */ 139 }; /* Anonymous union (gcc extenion) */ 144 140 >> 141 struct sos_time user_time_spent_in_slice; >> 142 >> 143 >> 144 /** >> 145 * When a thread in kernel mode is accessing the user space, it may >> 146 * page fault in the usual way only if return_vaddr below is >> 147 * set. This structure holds information regarding what to do when a >> 148 * page fault from kernel into user space could not be resolved. >> 149 * >> 150 * @note the fields below should be considered read-only. @see >> 151 * sos_thread_prepare_user_space_access() and @see >> 152 * sos_thread_end_user_space_access() to modify them. >> 153 */ >> 154 struct >> 155 { >> 156 /** This is the address (in kernel code) to return to when a >> 157 user-space page fault from a kernel-mode thread could not be >> 158 resolved. @see sos_thread_prepare_user_space_access() */ >> 159 sos_vaddr_t return_vaddr; >> 160 >> 161 /** This is the address of the user-space address that caused the >> 162 unresolved page fault (set by the page fault handler) */ >> 163 sos_uaddr_t faulted_uaddr; >> 164 } fixup_uaccess; >> 165 145 166 146 /* 167 /* 147 * Data used by the kwaitq subsystem: list o 168 * Data used by the kwaitq subsystem: list of kwaitqueues the thread 148 * is waiting for. 169 * is waiting for. 149 * 170 * 150 * @note: a RUNNING or READY thread might be 171 * @note: a RUNNING or READY thread might be in one or more 151 * waitqueues ! The only property we have is 172 * waitqueues ! The only property we have is that, among these 152 * waitqueues (if any), _at least_ one has w 173 * waitqueues (if any), _at least_ one has woken the thread. 153 */ 174 */ 154 struct sos_kwaitq_entry *kwaitq_list; 175 struct sos_kwaitq_entry *kwaitq_list; 155 176 156 177 157 /** 178 /** 158 * Some statistics 179 * Some statistics 159 */ 180 */ 160 struct rusage 181 struct rusage 161 { 182 { 162 /* Updated by sched.c */ 183 /* Updated by sched.c */ 163 struct sos_time ru_utime; /* Time spent in 184 struct sos_time ru_utime; /* Time spent in user mode */ 164 struct sos_time ru_stime; /* Time spent in 185 struct sos_time ru_stime; /* Time spent in kernel mode */ 165 } rusage; 186 } rusage; 166 187 167 188 168 /** 189 /** 169 * Chaining pointers for the list of threads 190 * Chaining pointers for the list of threads in the parent process 170 */ 191 */ 171 struct sos_thread *prev_in_process, *next_in 192 struct sos_thread *prev_in_process, *next_in_process; 172 193 173 194 174 /** 195 /** 175 * Chaining pointers for global ("gbl") list 196 * Chaining pointers for global ("gbl") list of threads (debug) 176 */ 197 */ 177 struct sos_thread *gbl_prev, *gbl_next; 198 struct sos_thread *gbl_prev, *gbl_next; 178 }; 199 }; 179 200 180 201 181 /** 202 /** 182 * Definition of the function executed by a ke 203 * Definition of the function executed by a kernel thread 183 */ 204 */ 184 typedef void (*sos_kernel_thread_start_routine 205 typedef void (*sos_kernel_thread_start_routine_t)(void *arg); 185 206 186 207 187 /** 208 /** 188 * Initialize the subsystem responsible for th 209 * Initialize the subsystem responsible for thread management 189 * 210 * 190 * Initialize the primary kernel thread so tha 211 * Initialize the primary kernel thread so that it can be handled the 191 * same way as an ordinary thread created by s 212 * same way as an ordinary thread created by sos_thread_create(). 192 */ 213 */ 193 sos_ret_t sos_thread_subsystem_setup(sos_vaddr 214 sos_ret_t sos_thread_subsystem_setup(sos_vaddr_t init_thread_stack_base_addr, 194 sos_size_ 215 sos_size_t init_thread_stack_size); 195 216 196 217 197 /** 218 /** 198 * Create a new kernel thread 219 * Create a new kernel thread 199 */ 220 */ 200 struct sos_thread * 221 struct sos_thread * 201 sos_create_kernel_thread(const char *name, 222 sos_create_kernel_thread(const char *name, 202 sos_kernel_thread_sta 223 sos_kernel_thread_start_routine_t start_func, 203 void *start_arg, 224 void *start_arg, 204 sos_sched_priority_t 225 sos_sched_priority_t priority); 205 226 206 227 207 /** 228 /** 208 * Create a new user thread 229 * Create a new user thread 209 */ 230 */ 210 struct sos_thread * 231 struct sos_thread * 211 sos_create_user_thread(const char *name, 232 sos_create_user_thread(const char *name, 212 struct sos_process *pro 233 struct sos_process *process, 213 sos_uaddr_t user_initia 234 sos_uaddr_t user_initial_PC, 214 sos_ui32_t user_start_ 235 sos_ui32_t user_start_arg1, 215 sos_ui32_t user_start_ 236 sos_ui32_t user_start_arg2, 216 sos_uaddr_t user_initia 237 sos_uaddr_t user_initial_SP, 217 sos_sched_priority_t pr 238 sos_sched_priority_t priority); 218 239 219 240 220 /** 241 /** >> 242 * Create a new user thread, copy of the given user thread with the >> 243 * given user context >> 244 */ >> 245 struct sos_thread * >> 246 sos_duplicate_user_thread(const char *name, >> 247 struct sos_process *process, >> 248 const struct sos_thread * model_thread, >> 249 const struct sos_cpu_state * model_uctxt, >> 250 sos_ui32_t retval); >> 251 >> 252 >> 253 /** 221 * Terminate the execution of the current thre 254 * Terminate the execution of the current thread. For kernel threads, 222 * it is called by default when the start rout 255 * it is called by default when the start routine returns. 223 */ 256 */ 224 void sos_thread_exit() __attribute__((noreturn 257 void sos_thread_exit() __attribute__((noreturn)); 225 258 226 259 227 /** 260 /** 228 * Get the identifier of the thread currently 261 * Get the identifier of the thread currently running on CPU. Trivial 229 * function. 262 * function. 230 */ 263 */ 231 struct sos_thread *sos_thread_get_current(); 264 struct sos_thread *sos_thread_get_current(); 232 265 233 266 234 /** 267 /** 235 * If thr == NULL, set the priority of the cur 268 * If thr == NULL, set the priority of the current thread. Trivial 236 * function. 269 * function. 237 * 270 * 238 * @note NOT protected against interrupts 271 * @note NOT protected against interrupts 239 */ 272 */ 240 sos_sched_priority_t sos_thread_get_priority(s 273 sos_sched_priority_t sos_thread_get_priority(struct sos_thread *thr); 241 274 242 275 243 /** 276 /** 244 * If thr == NULL, get the state of the curren 277 * If thr == NULL, get the state of the current thread. Trivial 245 * function. 278 * function. 246 * 279 * 247 * @note NOT protected against interrupts 280 * @note NOT protected against interrupts 248 */ 281 */ 249 sos_thread_state_t sos_thread_get_state(struct 282 sos_thread_state_t sos_thread_get_state(struct sos_thread *thr); 250 283 251 284 252 /** 285 /** 253 * If thr == NULL, set the priority of the cur 286 * If thr == NULL, set the priority of the current thread 254 * 287 * 255 * @note NO context-switch ever occurs in this 288 * @note NO context-switch ever occurs in this function ! 256 */ 289 */ 257 sos_ret_t sos_thread_set_priority(struct sos_t 290 sos_ret_t sos_thread_set_priority(struct sos_thread *thr, 258 sos_sched_pr 291 sos_sched_priority_t priority); 259 292 260 293 261 /** 294 /** 262 * Yield CPU to another ready thread. 295 * Yield CPU to another ready thread. 263 * 296 * 264 * @note This is a BLOCKING FUNCTION 297 * @note This is a BLOCKING FUNCTION 265 */ 298 */ 266 sos_ret_t sos_thread_yield(); 299 sos_ret_t sos_thread_yield(); 267 300 268 301 269 /** 302 /** 270 * Release the CPU for (at least) the given de 303 * Release the CPU for (at least) the given delay. 271 * 304 * 272 * @param delay The delay to wait for. If dela 305 * @param delay The delay to wait for. If delay == NULL then wait 273 * forever that any event occurs. 306 * forever that any event occurs. 274 * 307 * 275 * @return SOS_OK when delay expired (and dela 308 * @return SOS_OK when delay expired (and delay is reset to zero), 276 * -SOS_EINTR otherwise (and delay contains th 309 * -SOS_EINTR otherwise (and delay contains the amount of time 277 * remaining). 310 * remaining). 278 * 311 * 279 * @note This is a BLOCKING FUNCTION 312 * @note This is a BLOCKING FUNCTION 280 */ 313 */ 281 sos_ret_t sos_thread_sleep(/* in/out */struct 314 sos_ret_t sos_thread_sleep(/* in/out */struct sos_time *delay); 282 315 283 316 284 /** 317 /** 285 * Mark the given thread as READY (if not alre 318 * Mark the given thread as READY (if not already ready) even if it is 286 * blocked in a kwaitq or in a sleep ! As a re 319 * blocked in a kwaitq or in a sleep ! As a result, the interrupted 287 * kwaitq/sleep function call of the thread wi 320 * kwaitq/sleep function call of the thread will return with 288 * -SOS_EINTR. 321 * -SOS_EINTR. 289 * 322 * 290 * @return -SOS_EINVAL if thread does not exis 323 * @return -SOS_EINVAL if thread does not exist, or -SOS_EFATAL if 291 * marked ZOMBIE. 324 * marked ZOMBIE. 292 * 325 * 293 * @note As a result, the semaphore/mutex/cond 326 * @note As a result, the semaphore/mutex/conditions/... functions 294 * return values SHOULD ALWAYS be checked ! If 327 * return values SHOULD ALWAYS be checked ! If they are != SOS_OK, 295 * then the caller should consider that the re 328 * then the caller should consider that the resource is not aquired 296 * because somebody woke the thread by some wa 329 * because somebody woke the thread by some way. 297 */ 330 */ 298 sos_ret_t sos_thread_force_unblock(struct sos_ 331 sos_ret_t sos_thread_force_unblock(struct sos_thread *thread); 299 332 300 /** 333 /** 301 * Dump the backtrace of the current thread to 334 * Dump the backtrace of the current thread to console and/or bochs 302 */ 335 */ 303 void sos_thread_dump_backtrace(sos_bool_t on_c 336 void sos_thread_dump_backtrace(sos_bool_t on_console, 304 sos_bool_t on_b 337 sos_bool_t on_bochs); 305 338 306 339 307 /* ******************************************* 340 /* ********************************************** 308 * Restricted functions 341 * Restricted functions 309 */ 342 */ 310 343 311 344 312 /** 345 /** 313 * Restricted function to change the current m !! 346 * Restricted function to indicate that we are to access the given 314 * squatted_mm_context of the current thread i !! 347 * user address space from inside the kernel. 315 * in this context !! 348 * 316 * !! 349 * @param dest_as The address space we want to access, or NULL to 317 * @param mm_ctxt The mm_ctxt to restore. Mi !! 350 * access current thread's address space 318 * - for a Kernel thread: the current MMU c << 319 * modified. The address space to use is << 320 * space, user space might change due to << 321 * processes << 322 * - for a User thread in kernel mode: same << 323 * - when a User thread will go back in use << 324 * be reconfigured to match the mm_contex << 325 * process << 326 * << 327 * @note A non NULL parameter is allowed only << 328 * squatted_mm_context is not already set. A N << 329 * only if the squatted_mm_context was already << 330 * 351 * 331 * @note The use of this function is RESERVED !! 352 * @param fixup_retvaddr When != 0, then dest_as MUST BE NULL (we 332 * and the copy_from/to_user functions !! 353 * don't allow controlled access from kernel into user space from a >> 354 * foreign thread). In this case, the page fault handler should accept >> 355 * page faults from the kernel in user space, and resolve them in the >> 356 * usual way. The value in retvaddr is where the page fault handler >> 357 * has to return to in case the page fault remains unresolved. The >> 358 * address of the faulting address is kept in >> 359 * éthread->fixup_uaccess.faulted_uaddr >> 360 * >> 361 * @note typical values for fixup_retvaddr are obtained by "Labels as >> 362 * values" (see gcc's doc: operator "&&"). See uaccess.c for example >> 363 * code. >> 364 */ >> 365 sos_ret_t >> 366 sos_thread_prepare_user_space_access(struct sos_umem_vmm_as * dest_as, >> 367 sos_vaddr_t fixup_retvaddr); >> 368 >> 369 >> 370 /** >> 371 * Restricted function to signal we are not accessing any user address >> 372 * space anymore 333 */ 373 */ 334 sos_ret_t 374 sos_ret_t 335 sos_thread_change_current_mm_context(struct so !! 375 sos_thread_end_user_space_access(void); 336 376 337 377 338 /** 378 /** 339 * Restricted callback called when a syscall g 379 * Restricted callback called when a syscall goes back in user mode, 340 * to reconfigure the MMU to match that of the 380 * to reconfigure the MMU to match that of the current thread's 341 * process MMU context. 381 * process MMU context. 342 * 382 * 343 * @note The use of this function is RESERVED 383 * @note The use of this function is RESERVED to the syscall wrapper 344 */ 384 */ 345 void sos_thread_prepare_syscall_switch_back(st 385 void sos_thread_prepare_syscall_switch_back(struct sos_cpu_state *cpu_state); 346 386 347 387 348 /** 388 /** 349 * Restricted callback called when an exceptio 389 * Restricted callback called when an exception handler goes back to 350 * the interrupted thread to reconfigure the M 390 * the interrupted thread to reconfigure the MMU to match that of the 351 * current thread's process MMU context. 391 * current thread's process MMU context. 352 * 392 * 353 * @note The use of this function is RESERVED 393 * @note The use of this function is RESERVED to the exception wrappers 354 */ 394 */ 355 void sos_thread_prepare_exception_switch_back( 395 void sos_thread_prepare_exception_switch_back(struct sos_cpu_state *cpu_state); 356 396 357 397 358 /** 398 /** 359 * Restricted callback called when an IRQ is e 399 * Restricted callback called when an IRQ is entered while the CPU was 360 * NOT already servicing any other IRQ (ie the 400 * NOT already servicing any other IRQ (ie the outermost IRQ handler 361 * is entered). This callback simply updates t 401 * is entered). This callback simply updates the "cpu_state" field so 362 * that IRQ handlers always know the state of 402 * that IRQ handlers always know the state of the interrupted thread, 363 * even if they are imbricated in other IRQ ha 403 * even if they are imbricated in other IRQ handlers. 364 * 404 * 365 * @note The use of this function is RESERVED 405 * @note The use of this function is RESERVED to the irq wrappers 366 */ 406 */ 367 void 407 void 368 sos_thread_prepare_irq_servicing(struct sos_cp 408 sos_thread_prepare_irq_servicing(struct sos_cpu_state *interrupted_state); 369 409 370 410 371 /** 411 /** 372 * Restricted callback called when the outermo 412 * Restricted callback called when the outermost IRQ handler returns, 373 * to select the thread to return to. This cal 413 * to select the thread to return to. This callbacks implements: 374 * - preemption of user threads in user mode 414 * - preemption of user threads in user mode (time sharing / FIFO) 375 * - non-preemption of user threads in kerne 415 * - non-preemption of user threads in kernel mode (interrupted thread 376 * is restored on CPU "as is") 416 * is restored on CPU "as is") 377 * - non-preemption of kernel threads (same 417 * - non-preemption of kernel threads (same remark) 378 * The MMU is reconfigured correctly to match 418 * The MMU is reconfigured correctly to match the address space of the 379 * selected thread. 419 * selected thread. 380 * 420 * 381 * @return The CPU context of the thread to re 421 * @return The CPU context of the thread to return to 382 * 422 * 383 * @note The use of this function is RESERVED 423 * @note The use of this function is RESERVED to the irq wrappers 384 */ 424 */ 385 struct sos_cpu_state * 425 struct sos_cpu_state * 386 sos_thread_prepare_irq_switch_back(void); 426 sos_thread_prepare_irq_switch_back(void); 387 427 388 428 389 #endif /* _SOS_THREAD_H_ */ 429 #endif /* _SOS_THREAD_H_ */
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |