Rev 2080 | Rev 2093 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | jermar | 1 | /* |
2071 | jermar | 2 | * Copyright (c) 2001-2004 Jakub Jermar |
1 | jermar | 3 | * All rights reserved. |
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
13 | * documentation and/or other materials provided with the distribution. |
||
14 | * - The name of the author may not be used to endorse or promote products |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
1820 | decky | 29 | /** @addtogroup genericproc |
1702 | cejka | 30 | * @{ |
31 | */ |
||
32 | /** @file |
||
33 | */ |
||
34 | |||
1888 | jermar | 35 | #ifndef KERN_THREAD_H_ |
36 | #define KERN_THREAD_H_ |
||
1 | jermar | 37 | |
2089 | decky | 38 | #include <synch/waitq.h> |
39 | #include <proc/task.h> |
||
40 | #include <cpu.h> |
||
1 | jermar | 41 | #include <synch/rwlock.h> |
1158 | jermar | 42 | #include <adt/btree.h> |
906 | palkovsky | 43 | #include <mm/slab.h> |
2089 | decky | 44 | #include <arch/cpu.h> |
45 | #include <mm/tlb.h> |
||
1078 | jermar | 46 | #include <proc/uarg.h> |
1 | jermar | 47 | |
173 | jermar | 48 | #define THREAD_STACK_SIZE STACK_SIZE |
1 | jermar | 49 | |
50 | extern char *thread_states[]; |
||
51 | |||
1854 | jermar | 52 | /* Thread flags */ |
2089 | decky | 53 | #define THREAD_FLAG_WIRED (1 << 0) /**< Thread cannot be migrated to another CPU. */ |
54 | #define THREAD_FLAG_STOLEN (1 << 1) /**< Thread was migrated to another CPU and has not run yet. */ |
||
55 | #define THREAD_FLAG_USPACE (1 << 2) /**< Thread executes in userspace. */ |
||
1 | jermar | 56 | |
557 | jermar | 57 | /** Thread list lock. |
58 | * |
||
59 | * This lock protects all link_t structures chained in threads_head. |
||
60 | * Must be acquired before T.lock for each T of type thread_t. |
||
61 | * |
||
62 | */ |
||
63 | extern spinlock_t threads_lock; |
||
64 | |||
1158 | jermar | 65 | extern btree_t threads_btree; /**< B+tree containing all threads. */ |
1 | jermar | 66 | |
67 | extern void thread_init(void); |
||
2042 | decky | 68 | extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted); |
1 | jermar | 69 | extern void thread_ready(thread_t *t); |
1595 | palkovsky | 70 | extern void thread_exit(void) __attribute__((noreturn)); |
1 | jermar | 71 | |
1171 | jermar | 72 | #ifndef thread_create_arch |
73 | extern void thread_create_arch(thread_t *t); |
||
74 | #endif |
||
1854 | jermar | 75 | #ifndef thr_constructor_arch |
76 | extern void thr_constructor_arch(thread_t *t); |
||
77 | #endif |
||
78 | #ifndef thr_destructor_arch |
||
79 | extern void thr_destructor_arch(thread_t *t); |
||
80 | #endif |
||
1171 | jermar | 81 | |
1780 | jermar | 82 | extern void thread_sleep(uint32_t sec); |
83 | extern void thread_usleep(uint32_t usec); |
||
1 | jermar | 84 | |
1576 | jermar | 85 | #define thread_join(t) thread_join_timeout((t), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) |
1780 | jermar | 86 | extern int thread_join_timeout(thread_t *t, uint32_t usec, int flags); |
1571 | jermar | 87 | extern void thread_detach(thread_t *t); |
88 | |||
1 | jermar | 89 | extern void thread_register_call_me(void (* call_me)(void *), void *call_me_with); |
777 | palkovsky | 90 | extern void thread_print_list(void); |
787 | palkovsky | 91 | extern void thread_destroy(thread_t *t); |
2030 | decky | 92 | extern void thread_update_accounting(void); |
1158 | jermar | 93 | extern bool thread_exists(thread_t *t); |
2089 | decky | 94 | extern void thread_interrupt_sleep(thread_t *t); |
1 | jermar | 95 | |
906 | palkovsky | 96 | /* Fpu context slab cache */ |
97 | extern slab_cache_t *fpu_context_slab; |
||
98 | |||
1066 | jermar | 99 | /** Thread syscall prototypes. */ |
1780 | jermar | 100 | unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name); |
101 | unative_t sys_thread_exit(int uspace_status); |
||
1066 | jermar | 102 | |
1 | jermar | 103 | #endif |
1702 | cejka | 104 | |
1820 | decky | 105 | /** @} |
1702 | cejka | 106 | */ |